[fix] check FP and AP modules for correct firmware (#2581)

This commit is contained in:
Gautier Hattenberger
2020-09-16 10:59:41 +02:00
committed by GitHub
parent e83643812c
commit 3c5e7d0f08
+6 -6
View File
@@ -151,8 +151,8 @@ let sort_airframe_by_target = fun config_by_target airframe ->
) conf a.Airframe.modules in
Hashtbl.add config_by_target name conf
) l;
(* return list of targets *)
fst (List.split l)
(* return list of targets * firmwares *)
l
(** Extract a configuration element from aircraft config,
* returns a tuple with absolute file path and element object
@@ -198,7 +198,6 @@ let get_all_modules = fun config_by_target ->
) conf.modules
) config_by_target;
List.sort (fun m1 m2 -> compare m1.Module.name m2.Module.name) !modules
let parse_aircraft = fun ?(parse_af=false) ?(parse_ap=false) ?(parse_fp=false) ?(parse_rc=false) ?(parse_tl=false) ?(parse_set=false) ?(parse_all=false) ?(verbose=false) target aircraft_xml ->
@@ -217,6 +216,7 @@ let parse_aircraft = fun ?(parse_af=false) ?(parse_ap=false) ?(parse_fp=false) ?
if verbose then
Printf.printf ", sorting by target%!";
let target_list = sort_airframe_by_target config_by_target airframe in
let firmware = try let (_, f) = List.find (fun (t, f) -> t.AfT.name = target) target_list in f.AfF.name with Not_found -> "none" in
if verbose then
Printf.printf ", extracting and parsing autopilot...%!";
let autopilots = if parse_ap || parse_all then
@@ -249,7 +249,7 @@ let parse_aircraft = fun ?(parse_af=false) ?(parse_ap=false) ?(parse_fp=false) ?
let c = { c with
configures = c.configures @ m.Module.configures;
defines = c.defines @ m.Module.defines } in
target_conf_add_module c target "" m.Module.name m.Module.mtype UserLoad
target_conf_add_module c target firmware m.Module.name m.Module.mtype UserLoad
) conf ap.Autopilot.modules in
Hashtbl.replace config_by_target target conf
) config_by_target;
@@ -261,7 +261,7 @@ let parse_aircraft = fun ?(parse_af=false) ?(parse_ap=false) ?(parse_fp=false) ?
Some autopilots
with Not_found ->
(* target not found or not defined, add in all targets instead *)
List.iter (fun t ->
List.iter (fun (t, _) ->
let c = Hashtbl.find config_by_target t.AfT.name in
Hashtbl.replace config_by_target target { c with autopilot = true }
) target_list;
@@ -287,7 +287,7 @@ let parse_aircraft = fun ?(parse_af=false) ?(parse_ap=false) ?(parse_fp=false) ?
let c = { c with
configures = c.configures @ m.Module.configures;
defines = c.defines @ m.Module.defines } in
target_conf_add_module c target "" m.Module.name m.Module.mtype UserLoad
target_conf_add_module c target firmware m.Module.name m.Module.mtype UserLoad
) conf fp.Flight_plan.modules in
Hashtbl.replace config_by_target target conf
) config_by_target