diff --git a/sw/ground_segment/cockpit/page_settings.ml b/sw/ground_segment/cockpit/page_settings.ml index 5021a4c450..9468fba30b 100644 --- a/sw/ground_segment/cockpit/page_settings.ml +++ b/sw/ground_segment/cockpit/page_settings.ml @@ -222,7 +222,7 @@ let one_setting = fun (i:int) (do_change:int -> float -> unit) packing dl_settin let same_tag_for_all = function -[] -> failwith "Page_settings: unreachable, empty dl_settings element" + [] -> failwith "Page_settings: unreachable, empty dl_settings element" | x::xs -> let tag_first = Xml.tag x in List.iter (fun y -> assert(ExtXml.tag_is y tag_first)) xs; diff --git a/sw/tools/gen_periodic.ml b/sw/tools/gen_periodic.ml index 1fdb99a7b4..56ff7b6433 100644 --- a/sw/tools/gen_periodic.ml +++ b/sw/tools/gen_periodic.ml @@ -92,31 +92,35 @@ let output_modes = fun out_h process_name modes freq modules -> modes let write_settings = fun xml_file out_set telemetry_xml -> + (* filter xml file to remove unneeded process and modes (more than 1 mode per process) *) + let filtered_xml = List.filter (fun p -> List.length (Xml.children p) > 1) (Xml.children telemetry_xml) in fprintf out_set "\n" xml_file; fprintf out_set "\n\n"; fprintf out_set "\n"; - fprintf out_set " \n"; - fprintf out_set " \n"; - List.iter (fun p -> - (* for each process *) - let process_name = Xml.attrib p "name" in - (* convert the xml list of mode to a string list *) - let modes = List.map (fun m -> Xml.attrib m "name") (Xml.children p) in - let nb_modes = List.length modes in - match nb_modes with - 0 | 1 -> () (* Nothing to do if 1 or zero mode *) + if List.length filtered_xml > 0 then begin + fprintf out_set " \n"; + fprintf out_set " \n"; + List.iter (fun p -> + (* for each (pre-filtered) process *) + let process_name = Xml.attrib p "name" in + (* convert the xml list of mode to a string list *) + let modes = List.map (fun m -> Xml.attrib m "name") (Xml.children p) in + let nb_modes = List.length modes in + match nb_modes with + | 0 | 1 -> () (* Nothing to do if 1 or zero mode *) | _ -> (* add settings with all modes *) - fprintf out_set " \n" (nb_modes-1) process_name process_name (String.concat "|" modes); - let i = ref 0 in - List.iter (fun m -> try - let key = Xml.attrib m "key_press" in - fprintf out_set " \n" key (string_of_int !i); - incr i + fprintf out_set " \n" (nb_modes-1) process_name process_name (String.concat "|" modes); + let i = ref 0 in + List.iter (fun m -> try + let key = Xml.attrib m "key_press" in + fprintf out_set " \n" key (string_of_int !i); + incr i with _ -> incr i) (Xml.children p); - fprintf out_set " \n" - ) (Xml.children telemetry_xml); - fprintf out_set " \n"; - fprintf out_set " \n"; + fprintf out_set " \n" + ) filtered_xml; + fprintf out_set " \n"; + fprintf out_set " \n"; + end; fprintf out_set "\n"