mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-02 05:17:03 +08:00
add settings to start and stop the modules
This commit is contained in:
+5
-4
@@ -45,6 +45,7 @@ FLIGHT_PLAN_XML=$(ACINCLUDE)/flight_plan.xml
|
|||||||
SETTINGS_H=$(ACINCLUDE)/settings.h
|
SETTINGS_H=$(ACINCLUDE)/settings.h
|
||||||
SETTINGS_XMLS=$(patsubst %,$(CONF)/%,$(SETTINGS))
|
SETTINGS_XMLS=$(patsubst %,$(CONF)/%,$(SETTINGS))
|
||||||
SETTINGS_XML=$(ACINCLUDE)/settings.xml
|
SETTINGS_XML=$(ACINCLUDE)/settings.xml
|
||||||
|
SETTINGS_MODULES=$(ACINCLUDE)/settings_modules.xml
|
||||||
MAKEFILE_AC=$(ACINCLUDE)/Makefile.ac
|
MAKEFILE_AC=$(ACINCLUDE)/Makefile.ac
|
||||||
SETTINGS_FILE=$(SETTINGS:settings%=%)
|
SETTINGS_FILE=$(SETTINGS:settings%=%)
|
||||||
#TUNING_FILE=$(subst ,_,$(SETTINGS:settings/%.xml=%)).h
|
#TUNING_FILE=$(subst ,_,$(SETTINGS:settings/%.xml=%)).h
|
||||||
@@ -67,7 +68,7 @@ init:
|
|||||||
demo:
|
demo:
|
||||||
$(SUPERVISION)
|
$(SUPERVISION)
|
||||||
|
|
||||||
all_ac_h: $(AIRFRAME_H) $(SETTINGS_H) $(TUNING_H) $(MAKEFILE_AC) $(PERIODIC_H) $(MODULES_H)
|
all_ac_h: $(AIRFRAME_H) $(MODULES_H) $(SETTINGS_H) $(TUNING_H) $(MAKEFILE_AC) $(PERIODIC_H)
|
||||||
|
|
||||||
radio_ac_h : $(RADIO_H) $(CONF_RADIO_CONTROL_PPM_H)
|
radio_ac_h : $(RADIO_H) $(CONF_RADIO_CONTROL_PPM_H)
|
||||||
|
|
||||||
@@ -116,9 +117,9 @@ $(FLIGHT_PLAN_XML) : $(CONF)/$(FLIGHT_PLAN) $(CONF_XML) $(TOOLS)/gen_flight_plan
|
|||||||
$(Q)$(TOOLS)/gen_flight_plan.out -dump $< > $@
|
$(Q)$(TOOLS)/gen_flight_plan.out -dump $< > $@
|
||||||
$(Q)chmod a+r $@
|
$(Q)chmod a+r $@
|
||||||
|
|
||||||
$(SETTINGS_H) : $(SETTINGS_XMLS) $(CONF_XML) $(TOOLS)/gen_settings.out
|
$(SETTINGS_H) : $(SETTINGS_XMLS) $(CONF_XML) $(SETTINGS_MODULES) $(TOOLS)/gen_settings.out
|
||||||
@echo BUILD $@
|
@echo BUILD $@
|
||||||
$(Q)$(TOOLS)/gen_settings.out $(SETTINGS_XML) $(SETTINGS_XMLS) > $@
|
$(Q)$(TOOLS)/gen_settings.out $(SETTINGS_XML) $(SETTINGS_XMLS) $(SETTINGS_MODULES) > $@
|
||||||
$(Q)chmod a+r $@
|
$(Q)chmod a+r $@
|
||||||
$(Q)cp $(SETTINGS_XMLS) $(AIRCRAFT_CONF_DIR)/settings
|
$(Q)cp $(SETTINGS_XMLS) $(AIRCRAFT_CONF_DIR)/settings
|
||||||
|
|
||||||
@@ -130,7 +131,7 @@ $(TUNING_H) : $(SETTINGS_XMLS) $(CONF_XML) $(TOOLS)/gen_tuning.out
|
|||||||
|
|
||||||
$(MODULES_H) : $(CONF)/$(AIRFRAME_XML) $(TOOLS)/gen_modules.out $(CONF)/modules/*.xml
|
$(MODULES_H) : $(CONF)/$(AIRFRAME_XML) $(TOOLS)/gen_modules.out $(CONF)/modules/*.xml
|
||||||
@echo BUILD $@
|
@echo BUILD $@
|
||||||
$(Q)$(TOOLS)/gen_modules.out $(MODULES_DIR) $(MODULES_C) $< > $@
|
$(Q)$(TOOLS)/gen_modules.out $(MODULES_DIR) $(MODULES_C) $(SETTINGS_MODULES) $< > $@
|
||||||
$(Q)chmod a+r $@
|
$(Q)chmod a+r $@
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+35
-3
@@ -58,6 +58,10 @@ let get_status_name = fun f n ->
|
|||||||
let func = (Xml.attrib f "fun") in
|
let func = (Xml.attrib f "fun") in
|
||||||
n^"_"^String.sub func 0 (try String.index func '(' with _ -> (String.length func))^"_status"
|
n^"_"^String.sub func 0 (try String.index func '(' with _ -> (String.length func))^"_status"
|
||||||
|
|
||||||
|
let get_status_shortname = fun f ->
|
||||||
|
let func = (Xml.attrib f "fun") in
|
||||||
|
String.sub func 0 (try String.index func '(' with _ -> (String.length func))
|
||||||
|
|
||||||
let is_status_lock = fun p ->
|
let is_status_lock = fun p ->
|
||||||
let mode = ExtXml.attrib_or_default p "autorun" "LOCK" in
|
let mode = ExtXml.attrib_or_default p "autorun" "LOCK" in
|
||||||
mode = "LOCK"
|
mode = "LOCK"
|
||||||
@@ -247,13 +251,39 @@ let check_dependencies = fun modules names ->
|
|||||||
with _ -> ()
|
with _ -> ()
|
||||||
) modules
|
) modules
|
||||||
|
|
||||||
|
let write_settings = fun xml_file out_set modules ->
|
||||||
|
fprintf out_set "<!-- This file has been generated from %s -->\n" xml_file;
|
||||||
|
fprintf out_set "<!-- Please DO NOT EDIT -->\n\n";
|
||||||
|
fprintf out_set "<settings>\n";
|
||||||
|
fprintf out_set " <dl_settings>\n";
|
||||||
|
let setting_exist = ref false in
|
||||||
|
List.iter (fun m ->
|
||||||
|
let module_name = ExtXml.attrib m "name" in
|
||||||
|
List.iter (fun i ->
|
||||||
|
match Xml.tag i with
|
||||||
|
"periodic" ->
|
||||||
|
if not (is_status_lock i) then begin
|
||||||
|
if (not !setting_exist) then begin
|
||||||
|
fprintf out_set " <dl_settings name=\"Modules\">\n";
|
||||||
|
setting_exist := true;
|
||||||
|
end;
|
||||||
|
fprintf out_set " <dl_setting min=\"2\" max=\"3\" step=\"1\" var=\"%s\" shortname=\"%s\" values=\"START|STOP\"/>\n"
|
||||||
|
(get_status_name i module_name) (get_status_shortname i)
|
||||||
|
end
|
||||||
|
| _ -> ())
|
||||||
|
(Xml.children m))
|
||||||
|
modules;
|
||||||
|
if !setting_exist then fprintf out_set " </dl_settings>\n";
|
||||||
|
fprintf out_set " </dl_settings>\n";
|
||||||
|
fprintf out_set "</settings>\n"
|
||||||
|
|
||||||
let h_name = "MODULES_H"
|
let h_name = "MODULES_H"
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
if Array.length Sys.argv <> 4 then
|
if Array.length Sys.argv <> 5 then
|
||||||
failwith (Printf.sprintf "Usage: %s conf_modules_dir out_c_file out_settings_file xml_file" Sys.argv.(0));
|
failwith (Printf.sprintf "Usage: %s conf_modules_dir out_c_file out_settings_file xml_file" Sys.argv.(0));
|
||||||
let xml_file = Sys.argv.(3)
|
let xml_file = Sys.argv.(4)
|
||||||
(*and out_set = open_out Sys.argv.(3)*)
|
and out_set = open_out Sys.argv.(3)
|
||||||
and out_c = open_out Sys.argv.(2)
|
and out_c = open_out Sys.argv.(2)
|
||||||
and modules_dir = Sys.argv.(1) in
|
and modules_dir = Sys.argv.(1) in
|
||||||
try
|
try
|
||||||
@@ -281,6 +311,8 @@ let () =
|
|||||||
fprintf out_c "\n#endif // USE_MODULES\n";
|
fprintf out_c "\n#endif // USE_MODULES\n";
|
||||||
finish h_name;
|
finish h_name;
|
||||||
close_out out_c;
|
close_out out_c;
|
||||||
|
write_settings xml_file out_set modules_list;
|
||||||
|
close_out out_set;
|
||||||
with
|
with
|
||||||
Xml.Error e -> fprintf stderr "%s: XML error:%s\n" xml_file (Xml.error e); exit 1
|
Xml.Error e -> fprintf stderr "%s: XML error:%s\n" xml_file (Xml.error e); exit 1
|
||||||
| Dtd.Prove_error e -> fprintf stderr "%s: DTD error:%s\n%!" xml_file (Dtd.prove_error e); exit 1
|
| Dtd.Prove_error e -> fprintf stderr "%s: DTD error:%s\n%!" xml_file (Dtd.prove_error e); exit 1
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ let print_dl_settings = fun settings ->
|
|||||||
|
|
||||||
lprintf "\n";
|
lprintf "\n";
|
||||||
StringSet.iter (fun m -> lprintf "#include \"%s.h\"\n" m) !modules;
|
StringSet.iter (fun m -> lprintf "#include \"%s.h\"\n" m) !modules;
|
||||||
|
lprintf "#include \"modules.h\"\n";
|
||||||
lprintf "\n";
|
lprintf "\n";
|
||||||
|
|
||||||
(** Macro to call to set one variable *)
|
(** Macro to call to set one variable *)
|
||||||
@@ -186,8 +187,8 @@ let join_xml_files = fun xml_files ->
|
|||||||
|
|
||||||
|
|
||||||
let _ =
|
let _ =
|
||||||
if Array.length Sys.argv < 3 then
|
if Array.length Sys.argv < 4 then
|
||||||
failwith (Printf.sprintf "Usage: %s output_xml_file input_xml_file(s)" Sys.argv.(0));
|
failwith (Printf.sprintf "Usage: %s output_xml_file input_xml_file(s) input_xml_modules" Sys.argv.(0));
|
||||||
let h_name = "SETTINGS_H"
|
let h_name = "SETTINGS_H"
|
||||||
and xml_files = ref [] in
|
and xml_files = ref [] in
|
||||||
for i = 2 to Array.length Sys.argv - 1 do
|
for i = 2 to Array.length Sys.argv - 1 do
|
||||||
|
|||||||
Reference in New Issue
Block a user