diff --git a/conf/flash_modes.xml b/conf/flash_modes.xml index 597e1fd325..00289ba17c 100644 --- a/conf/flash_modes.xml +++ b/conf/flash_modes.xml @@ -1,31 +1,88 @@ - + + + + + + + + + + + + + - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - + + + + + + + - + + + + + diff --git a/sw/supervision/pc_aircraft.ml b/sw/supervision/pc_aircraft.ml index 0c8757652c..a939a363ac 100644 --- a/sw/supervision/pc_aircraft.ml +++ b/sw/supervision/pc_aircraft.ml @@ -207,10 +207,15 @@ let parse_ac_flash = fun target flash_combo ac_file -> let af_xml = Xml.parse_file (Env.paparazzi_home // "conf" // ac_file) in let targets = get_targets_list af_xml in let board = Xml.attrib (List.find (fun t -> Xml.attrib t "name" = target) targets) "board" in - let flash_modes = try Hashtbl.find (snd CP.flash_modes) board with _ -> [] in (* not a valid board *) - List.iter (fun m -> Gtk_tools.add_to_combo flash_combo m) flash_modes; + (* board names as regexp *) + let flash_modes = ref [] in + Hashtbl.iter (fun b m -> + if Str.string_match (Str.regexp b) board 0 then + flash_modes := !flash_modes @ m; + ) (snd CP.flash_modes); + List.iter (fun m -> Gtk_tools.add_to_combo flash_combo m) !flash_modes; Gtk_tools.select_in_combo flash_combo "Default"; - (Gtk_tools.combo_widget flash_combo)#misc#set_sensitive (List.length flash_modes > 0) + (Gtk_tools.combo_widget flash_combo)#misc#set_sensitive (List.length !flash_modes > 0) with _ -> (* not a valid airframe file *) (Gtk_tools.combo_widget flash_combo)#misc#set_sensitive false diff --git a/sw/supervision/pc_control_panel.ml b/sw/supervision/pc_control_panel.ml index fb2a1c3228..40d9a81350 100644 --- a/sw/supervision/pc_control_panel.ml +++ b/sw/supervision/pc_control_panel.ml @@ -67,11 +67,12 @@ let flash_modes = List.iter (fun m -> let mode = Xml.attrib m "name" in (* list of boards *) - let board_list = Str.split (Str.regexp "|") (Xml.attrib m "boards") in + let board_list = try Xml.children (ExtXml.child m "boards") with _ -> [] in + let board_list = List.map (fun x -> Xml.attrib x "name") board_list in (* build options for this mode *) let options = List.map (fun o -> sprintf "%s=%s" (Xml.attrib o "name") (Xml.attrib o "value") - ) (Xml.children m) in + ) (List.filter (fun t -> Xml.tag t = "variable") (Xml.children m)) in let options = String.concat " " options in (* add to hash tables *) Hashtbl.add modes mode options; @@ -82,6 +83,7 @@ let flash_modes = Hashtbl.replace boards b ([mode] @ _modes) ) board_list; ) (fm_common @ fm_custom); + (* convert string to regexp *) modes, boards