Skip to content

Commit

Permalink
[ground_segment] input2ivy: improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Feb 16, 2014
1 parent 69fa744 commit 744e321
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions sw/ground_segment/joystick/input2ivy.ml
Expand Up @@ -220,7 +220,9 @@ let parse_value = fun s ->
(** Parse a message field and eval *)
let parse_msg_field = fun msg_descr field ->
let name = Xml.attrib field "name" in
let field_descr = List.assoc name msg_descr.Pprz.fields in
let field_descr = try List.assoc name msg_descr.Pprz.fields with _ ->
Printf.printf "parse_msg_field: field %s not found\n" name;
raise (Failure "field not found") in

let value = eval_settings_and_blocks field_descr (parse_value (Xml.attrib field "value")) in
(name, value)
Expand All @@ -234,9 +236,14 @@ let parse_msg = fun msg ->
let fields, has_ac_id =
match get_message_type msg_class with
"Message" ->
let msg_descr = get_message msg_class msg_name in
(List.map (parse_msg_field msg_descr) (Xml.children msg),
List.mem_assoc "ac_id" msg_descr.Pprz.fields)
begin
let msg_descr = get_message msg_class msg_name in
try
(List.map (parse_msg_field msg_descr) (Xml.children msg),
List.mem_assoc "ac_id" msg_descr.Pprz.fields)
with _ ->
failwith (sprintf "Couldn't parse message %s" msg_name)
end
| "Trim" -> ([], false)
| _ -> failwith ("Unknown message class type") in

Expand Down Expand Up @@ -592,7 +599,8 @@ let () =
hash_index_of_settings !ac_name;
hash_index_of_blocks !ac_name;

Printf.printf "Joystick ID: %u\n" !joystick_id;
Printf.printf "Joystick ID (option -id): %u\n" !joystick_id;
Printf.printf "Joystick SDL device index (option -d): %u\n" !device_index;

let joystick_conf_dir = conf_dir ^ "/joystick/" in
let xml_descr_full = joystick_conf_dir ^ !xml_descr in
Expand Down

0 comments on commit 744e321

Please sign in to comment.