diff --git a/conf/messages.xml b/conf/messages.xml index ab5566b83d..29a1b1b0c5 100644 --- a/conf/messages.xml +++ b/conf/messages.xml @@ -450,6 +450,10 @@ + + + + diff --git a/sw/ground_segment/tmtc/server.ml b/sw/ground_segment/tmtc/server.ml index 5cad1b1539..383ac97ec6 100644 --- a/sw/ground_segment/tmtc/server.ml +++ b/sw/ground_segment/tmtc/server.ml @@ -256,8 +256,8 @@ let ac_msg = fun log ac_name a m -> let msg = Tele_Pprz.message_of_id msg_id in log_and_parse log ac_name a msg values with - Pprz.Unknown_msg_name x -> - fprintf stderr "Unknown message %s from %s: %s\n" x ac_name m + Pprz.Unknown_msg_name (x, c) -> + fprintf stderr "Unknown message %s in class %s from %s: %s\n" x c ac_name m | x -> prerr_endline (Printexc.to_string x) @@ -464,12 +464,17 @@ let periodic_airprox_check = fun name -> let list_ac = List.map (fun name -> Hashtbl.find aircrafts name) ac_names in let check_airprox = fun ac -> - match Airprox.check_airprox thisac ac with - None -> () - | Some level -> - let vs = - ["ac_id", Pprz.String (thisac.id ^ "," ^ ac.id) ; "level", Pprz.String level; "value", Pprz.String ac.id] in - Alerts_Pprz.message_send my_id "AIR_PROX" vs in + try + match Airprox.check_airprox thisac ac with + None -> () + | Some level -> + let vs = + ["ac_id", Pprz.String (thisac.id ^ "," ^ ac.id) ; "level", Pprz.String level] in + Alerts_Pprz.message_send my_id "AIR_PROX" vs + with + x -> fprintf stderr "check_airprox: %s\n%!" (Printexc.to_string x) + + in List.iter (fun ac -> diff --git a/sw/lib/ocaml/pprz.ml b/sw/lib/ocaml/pprz.ml index 764ad558b6..49d9dad39d 100644 --- a/sw/lib/ocaml/pprz.ml +++ b/sw/lib/ocaml/pprz.ml @@ -209,7 +209,7 @@ let sprint_value = fun buf i field_type v -> module type CLASS = sig val name : string end -exception Unknown_msg_name of string +exception Unknown_msg_name of string * string module Protocol(Class:CLASS) = struct let stx = Char.chr 0x05 @@ -222,7 +222,11 @@ module Protocol(Class:CLASS) = struct with Not_found -> failwith (sprintf "Unknown message class: %s" Class.name) let message_of_id = fun id -> Hashtbl.find messages_by_id id - let message_of_name = fun name -> Hashtbl.find messages_by_name name + let message_of_name = fun name -> + try + Hashtbl.find messages_by_name name + with + Not_found -> raise (Unknown_msg_name (name, Class.name)) let length = fun buf start -> let len = String.length buf - start in @@ -289,8 +293,7 @@ module Protocol(Class:CLASS) = struct let values = List.map2 (fun (field_name, field) v -> (field_name, value field._type v)) msg.fields args in (msg_id, values) with - Not_found -> raise (Unknown_msg_name msg_name) - | Invalid_argument "List.map2" -> failwith (sprintf "Pprz.values_of_string: '%s'" s) + Invalid_argument "List.map2" -> failwith (sprintf "Pprz.values_of_string: '%s'" s) end | [] -> invalid_arg "Pprz.values_of_string" diff --git a/sw/lib/ocaml/pprz.mli b/sw/lib/ocaml/pprz.mli index c92ccd1732..1cd7c9038f 100644 --- a/sw/lib/ocaml/pprz.mli +++ b/sw/lib/ocaml/pprz.mli @@ -55,7 +55,9 @@ val int_assoc : string -> values -> int val int32_assoc : string -> values -> int (** May raise Not_found or Invalid_argument *) -exception Unknown_msg_name of string +exception Unknown_msg_name of string * string +(** [Unknown_msg_name (name, class_name)] Raised if message [name] is not +found in class [class_name]. *) module type CLASS = sig val name : string end module Protocol : functor (Class : CLASS) -> sig