diff --git a/sw/lib/ocaml/pprz.ml b/sw/lib/ocaml/pprz.ml index 3d17054290..ce7a9f89d5 100644 --- a/sw/lib/ocaml/pprz.ml +++ b/sw/lib/ocaml/pprz.ml @@ -40,7 +40,8 @@ type value = type field = { _type : _type; fformat : format; - alt_unit_coef : string + alt_unit_coef : string; + enum : string list } type link_mode = Forwarded | Broadcasted @@ -153,12 +154,16 @@ let payload_size_of_message = fun message -> message.fields 2 (** + message id + aircraft id *) +let pipe_regexp = Str.regexp "|" let field_of_xml = fun xml -> let t = ExtXml.attrib xml "type" in let t = if is_array_type t then ArrayType (type_of_array_type t) else Scalar t in let f = try Xml.attrib xml "format" with _ -> default_format t in let auc = try Xml.attrib xml "alt_unit_coef" with _ -> "" in - (String.lowercase (ExtXml.attrib xml "name"), { _type = t; fformat = f; alt_unit_coef = auc }) + let values = try Str.split pipe_regexp (Xml.attrib xml "values") with _ -> [] in + + ( String.lowercase (ExtXml.attrib xml "name"), + { _type = t; fformat = f; alt_unit_coef = auc; enum=values }) let string_of_values = fun vs -> String.concat " " (List.map (fun (a,v) -> sprintf "%s=%s" a (string_of_value v)) vs) diff --git a/sw/lib/ocaml/pprz.mli b/sw/lib/ocaml/pprz.mli index 967e6334e3..00db36e358 100644 --- a/sw/lib/ocaml/pprz.mli +++ b/sw/lib/ocaml/pprz.mli @@ -39,7 +39,8 @@ type value = type field = { _type : _type; fformat : format; - alt_unit_coef : string (* May be empty *) + alt_unit_coef : string; (* May be empty *) + enum : string list (* 'values' attribute *) } type link_mode = Forwarded | Broadcasted type message = { @@ -116,6 +117,7 @@ module type MESSAGES = sig val messages : (message_id, message) Hashtbl.t val message_of_id : message_id -> message val message_of_name : string -> message_id * message + val values_of_payload : Serial.payload -> message_id * ac_id * values (** [values_of_bin payload] Parses a raw payload, returns the message id, the A/C id and the list of (field_name, value) *)