diff --git a/Makefile.ac b/Makefile.ac
index 77b09b4389..08371f8a04 100644
--- a/Makefile.ac
+++ b/Makefile.ac
@@ -34,13 +34,13 @@ PERIODIC_H=$(ACINCLUDE)/periodic.h
RADIO_H=$(ACINCLUDE)/radio.h
FLIGHT_PLAN_H=$(ACINCLUDE)/flight_plan.h
FLIGHT_PLAN_XML=$(ACINCLUDE)/flight_plan.xml
-INFLIGHT_CALIB_H=$(ACINCLUDE)/inflight_calib.h
+SETTINGS_H=$(ACINCLUDE)/settings.h
MAKEFILE_AC=$(ACINCLUDE)/Makefile.ac
# "make Q=''" to get full echo
Q=@
-all: $(AIRFRAME_H) $(RADIO_H) $(CONTROL_H) $(CONTROL_C) $(FLIGHT_PLAN_H) $(FLIGHT_PLAN_XML) $(INFLIGHT_CALIB_H) $(MAKEFILE_AC) $(PERIODIC_H)
+all: $(AIRFRAME_H) $(RADIO_H) $(CONTROL_H) $(CONTROL_C) $(FLIGHT_PLAN_H) $(FLIGHT_PLAN_XML) $(SETTINGS_H) $(MAKEFILE_AC) $(PERIODIC_H)
$(AIRFRAME_H) : $(CONF)/$(AIRFRAME) $(CONF_XML)
@echo BUILD $@
@@ -54,36 +54,34 @@ $(RADIO_H) : $(CONF)/$(RADIO) $(CONF_XML) $(TOOLS)/gen_radio.out
$(PERIODIC_H) : $(MESSAGES_XML) $(CONF_XML) $(CONF)/$(TELEMETRY)
@echo BUILD $@
- $(Q)TMP_FILE=`mktemp`;\
- $(TOOLS)/gen_periodic.out $(MESSAGES_XML) $(CONF)/$(TELEMETRY) > $$TMP_FILE;\
- mv $$TMP_FILE $@
+ $(Q)$(TOOLS)/gen_periodic.out $(MESSAGES_XML) $(CONF)/$(TELEMETRY) > $@
$(Q)chmod a+r $@
$(CONTROL_H) : $(CONF)/$(AIRFRAME) $(CONF_XML)
@echo BUILD $@
- $(Q)$(TOOLS)/gen_control.out h $< > /tmp/control.h
- $(Q)mv /tmp/control.h $@
+ $(Q)$(TOOLS)/gen_control.out h $< > $@
+ $(Q)chmod a+r $@
$(CONTROL_C) : $(CONF)/$(AIRFRAME) $(CONF_XML)
@echo BUILD $@
$(Q)mkdir -p $(ACINCLUDE)/ap
- $(Q)$(TOOLS)/gen_control.out c $< > /tmp/control.c
- $(Q)mv /tmp/control.c $@
+ $(Q)$(TOOLS)/gen_control.out c $< > $@
+ $(Q)chmod a+r $@
$(FLIGHT_PLAN_H) : $(CONF)/$(FLIGHT_PLAN) $(CONF_XML) $(TOOLS)/gen_flight_plan.out
@echo BUILD $@
- $(Q)$(TOOLS)/gen_flight_plan.out $< > /tmp/fp.h
- $(Q)mv /tmp/fp.h $@
+ $(Q)$(TOOLS)/gen_flight_plan.out $< > $@
+ $(Q)chmod a+r $@
$(FLIGHT_PLAN_XML) : $(CONF)/$(FLIGHT_PLAN) $(CONF_XML) $(TOOLS)/gen_flight_plan.out
@echo BUILD $@
- $(Q)$(TOOLS)/gen_flight_plan.out -dump $< > /tmp/fp.xml
- $(Q)mv /tmp/fp.xml $@
+ $(Q)$(TOOLS)/gen_flight_plan.out -dump $< > $@
+ $(Q)chmod a+r $@
-$(INFLIGHT_CALIB_H) : $(CONF)/$(FLIGHT_PLAN) $(CONF_XML) $(TOOLS)/gen_calib.out
+$(SETTINGS_H) : $(CONF)/$(SETTINGS) $(CONF_XML) $(TOOLS)/gen_settings.out
@echo BUILD $@
- $(Q)$(TOOLS)/gen_calib.out $< > /tmp/c.h
- $(Q)mv /tmp/c.h $@
+ $(Q)$(TOOLS)/gen_settings.out $< > $@
+ $(Q)chmod a+r $@
$(MAKEFILE_AC) : $(CONF)/$(AIRFRAME)
@echo BUILD $@
diff --git a/conf/control_panel.xml.example b/conf/control_panel.xml.example
index 34f1334140..fc0b2ab827 100644
--- a/conf/control_panel.xml.example
+++ b/conf/control_panel.xml.example
@@ -23,7 +23,7 @@
-
+
@@ -69,7 +69,7 @@
-
+
@@ -80,7 +80,7 @@
-
+
diff --git a/conf/flight_plans/dummy.xml b/conf/flight_plans/dummy.xml
index ab5b2342d0..de005bf586 100644
--- a/conf/flight_plans/dummy.xml
+++ b/conf/flight_plans/dummy.xml
@@ -1,11 +1,6 @@
-
-
-
-
-
diff --git a/conf/flight_plans/example.xml b/conf/flight_plans/example.xml
index 2f87d72230..df208f548f 100644
--- a/conf/flight_plans/example.xml
+++ b/conf/flight_plans/example.xml
@@ -1,16 +1,6 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/conf/flight_plans/flight_plan.dtd b/conf/flight_plans/flight_plan.dtd
index b940209a30..f4a17382ce 100644
--- a/conf/flight_plans/flight_plan.dtd
+++ b/conf/flight_plans/flight_plan.dtd
@@ -1,13 +1,7 @@
-
+
-
-
-
-
-
-
@@ -47,24 +41,6 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/conf/flight_plans/generic.xml b/conf/flight_plans/generic.xml
index 6a08fabfa2..854867d816 100644
--- a/conf/flight_plans/generic.xml
+++ b/conf/flight_plans/generic.xml
@@ -1,43 +1,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -45,6 +6,7 @@
+
diff --git a/conf/flight_plans/grosslobke_start.xml b/conf/flight_plans/grosslobke_start.xml
index 246f722aa5..7227d2cea3 100644
--- a/conf/flight_plans/grosslobke_start.xml
+++ b/conf/flight_plans/grosslobke_start.xml
@@ -1,27 +1,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/conf/flight_plans/huit.xml b/conf/flight_plans/huit.xml
index dc93a0eb1a..520e714a92 100644
--- a/conf/flight_plans/huit.xml
+++ b/conf/flight_plans/huit.xml
@@ -3,20 +3,6 @@
ref_pos="ricou"
qfu="225" ground_alt="390" security_height="25" alt = "490">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/conf/flight_plans/mav05.xml b/conf/flight_plans/mav05.xml
index 1066423665..174c2f24af 100644
--- a/conf/flight_plans/mav05.xml
+++ b/conf/flight_plans/mav05.xml
@@ -1,17 +1,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/conf/flight_plans/mav05_ccw.xml b/conf/flight_plans/mav05_ccw.xml
index c1549a4d3f..7eeb6a3460 100644
--- a/conf/flight_plans/mav05_ccw.xml
+++ b/conf/flight_plans/mav05_ccw.xml
@@ -1,22 +1,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/conf/flight_plans/mav05_cw.xml b/conf/flight_plans/mav05_cw.xml
index e8bb303ced..befdccdd1f 100644
--- a/conf/flight_plans/mav05_cw.xml
+++ b/conf/flight_plans/mav05_cw.xml
@@ -1,33 +1,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/conf/flight_plans/muret1.xml b/conf/flight_plans/muret1.xml
index ff095d7e8a..c48e00bbdc 100644
--- a/conf/flight_plans/muret1.xml
+++ b/conf/flight_plans/muret1.xml
@@ -1,16 +1,7 @@
-
-
-
-
-
-
-
-
-
-
+
diff --git a/conf/flight_plans/muret2.xml b/conf/flight_plans/muret2.xml
index 07f9ec994b..c38f1296dc 100644
--- a/conf/flight_plans/muret2.xml
+++ b/conf/flight_plans/muret2.xml
@@ -1,16 +1,7 @@
-
-
-
-
-
-
-
-
-
-
+
diff --git a/conf/flight_plans/muret3.xml b/conf/flight_plans/muret3.xml
index 07f9ec994b..c38f1296dc 100644
--- a/conf/flight_plans/muret3.xml
+++ b/conf/flight_plans/muret3.xml
@@ -1,16 +1,7 @@
-
-
-
-
-
-
-
-
-
-
+
diff --git a/conf/flight_plans/muret4.xml b/conf/flight_plans/muret4.xml
index 6601f05c2b..3280cc0b79 100644
--- a/conf/flight_plans/muret4.xml
+++ b/conf/flight_plans/muret4.xml
@@ -1,20 +1,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/conf/flight_plans/muret_cam.xml b/conf/flight_plans/muret_cam.xml
index 7d3fd8ffbf..d146c92c43 100644
--- a/conf/flight_plans/muret_cam.xml
+++ b/conf/flight_plans/muret_cam.xml
@@ -1,16 +1,7 @@
-
-
-
-
-
-
-
-
-
-
+
diff --git a/conf/flight_plans/muret_clover.xml b/conf/flight_plans/muret_clover.xml
index 4468922614..644534e621 100644
--- a/conf/flight_plans/muret_clover.xml
+++ b/conf/flight_plans/muret_clover.xml
@@ -1,20 +1,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/conf/flight_plans/muret_demo_1.xml b/conf/flight_plans/muret_demo_1.xml
index 8e658f8769..a5e55e018e 100644
--- a/conf/flight_plans/muret_demo_1.xml
+++ b/conf/flight_plans/muret_demo_1.xml
@@ -1,9 +1,6 @@
-
-
-
-
-
+
+
diff --git a/conf/flight_plans/muret_follow.xml b/conf/flight_plans/muret_follow.xml
index 9cc9594d78..cb8b82d419 100644
--- a/conf/flight_plans/muret_follow.xml
+++ b/conf/flight_plans/muret_follow.xml
@@ -1,21 +1,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/conf/flight_plans/muret_for.xml b/conf/flight_plans/muret_for.xml
index 8e1ebba3ff..a3a0cbab01 100644
--- a/conf/flight_plans/muret_for.xml
+++ b/conf/flight_plans/muret_for.xml
@@ -1,16 +1,7 @@
-
-
-
-
-
-
-
-
-
-
+
diff --git a/conf/flight_plans/sinsat.xml b/conf/flight_plans/sinsat.xml
index 03195d6b77..d5a85a9046 100644
--- a/conf/flight_plans/sinsat.xml
+++ b/conf/flight_plans/sinsat.xml
@@ -1,14 +1,5 @@
-
-
-
-
-
-
-
-
-
-
+
diff --git a/conf/messages.xml b/conf/messages.xml
index b3165c88c7..42842e6b51 100644
--- a/conf/messages.xml
+++ b/conf/messages.xml
@@ -443,6 +443,7 @@
+
diff --git a/conf/settings/settings.dtd b/conf/settings/settings.dtd
new file mode 100644
index 0000000000..9d55b0d6c6
--- /dev/null
+++ b/conf/settings/settings.dtd
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sw/airborne/main_ap.c b/sw/airborne/main_ap.c
index 2e252c02a9..df2fe62d92 100644
--- a/sw/airborne/main_ap.c
+++ b/sw/airborne/main_ap.c
@@ -45,6 +45,7 @@
#include "autopilot.h"
#include "estimator.h"
#include "rc_settings.h"
+#include "settings.h"
#include "cam.h"
#include "traffic_info.h"
#include "link_mcu.h"
diff --git a/sw/airborne/rc_settings.c b/sw/airborne/rc_settings.c
index 771acba3ad..6b7daa38ff 100644
--- a/sw/airborne/rc_settings.c
+++ b/sw/airborne/rc_settings.c
@@ -43,4 +43,9 @@
#define RcChannel(x) (fbw_state->channels[x])
/** Includes generated code from airframe.xml */
-#include "inflight_calib.h"
+#include "settings.h"
+
+
+void rc_settings(bool_t mode_changed __attribute__ ((unused))) {
+ RCSettings(mode_changed);
+}
diff --git a/sw/airborne/sim/sim_ap.c b/sw/airborne/sim/sim_ap.c
index 4ae6bb446e..61b99a58f0 100644
--- a/sw/airborne/sim/sim_ap.c
+++ b/sw/airborne/sim/sim_ap.c
@@ -12,12 +12,14 @@
#include "gps.h"
#include "traffic_info.h"
#include "flight_plan.h"
+#include "settings.h"
#include "nav.h"
#include "pid.h"
#include "infrared.h"
#include "cam.h"
#include "commands.h"
#include "main_ap.h"
+#include "ap_downlink.h"
#include
#include
@@ -105,6 +107,9 @@ value send_event(value event_id) {
value dl_setting(value index __attribute__ ((unused)),
value val __attribute__ ((unused))) {
/** DlSetting macro may be empty: unused attr to get rid of the warnings */
- DlSetting(Int_val(index), Double_val(val));
+ uint8_t i = Int_val(index);
+ float var = Double_val(val);
+ DlSetting(i, var);
+ DOWNLINK_SEND_DL_VALUE(&i, &var);
return Val_unit;
}
diff --git a/sw/ground_segment/cockpit/live.ml b/sw/ground_segment/cockpit/live.ml
index 36cd6aa054..079f5473a2 100644
--- a/sw/ground_segment/cockpit/live.ml
+++ b/sw/ground_segment/cockpit/live.ml
@@ -318,17 +318,17 @@ let create_ac = fun (geomap:G.widget) (acs_notebook:GPack.notebook) ac_id config
let misc_page = new Pages.misc ~packing:misc_frame#add misc_frame in
let settings_page =
- try
- let xml_settings = Xml.children (ExtXml.child fp_xml "dl_settings") in
- let callback = fun idx value ->
- let vs = ["ac_id", Pprz.String ac_id; "index", Pprz.Int idx;"value", Pprz.Float value] in
- Ground_Pprz.message_send "dl" "DL_SETTING" vs in
- let settings_tab = new Pages.settings ~visible xml_settings callback in
- let tab_label = (GMisc.label ~text:"Settings" ())#coerce in
- ac_notebook#append_page ~tab_label settings_tab#widget;
- Some settings_tab
- with
- _ -> None in
+ let settings_url = Pprz.string_assoc "settings" config in
+ let settings_file = Http.file_of_url settings_url in
+ let settings_xml = Xml.parse_file settings_file in
+ let xml_settings = Xml.children (ExtXml.child settings_xml "dl_settings") in
+ let callback = fun idx value ->
+ let vs = ["ac_id", Pprz.String ac_id; "index", Pprz.Int idx;"value", Pprz.Float value] in
+ Ground_Pprz.message_send "dl" "DL_SETTING" vs in
+ let settings_tab = new Pages.settings ~visible xml_settings callback in
+ let tab_label = (GMisc.label ~text:"Settings" ())#coerce in
+ ac_notebook#append_page ~tab_label settings_tab#widget;
+ Some settings_tab in
(** Add a strip and connect it to the A/C notebook *)
let select_this_tab =
@@ -400,7 +400,8 @@ let get_engine_status_msg = fun _sender vs ->
let get_if_calib_msg = fun _sender vs ->
let ac = get_ac vs in
- Strip.set_label ac.strip "settings" (Pprz.string_assoc "if_mode" vs)
+ (** No longer in the strip Strip.set_label ac.strip "settings" (Pprz.string_assoc "if_mode" vs) *)
+ ()
let listen_wind_msg = fun () ->
safe_bind "WIND" get_wind_msg
diff --git a/sw/ground_segment/cockpit/strip.ml b/sw/ground_segment/cockpit/strip.ml
index 09c1cf4d13..086b7f93b9 100644
--- a/sw/ground_segment/cockpit/strip.ml
+++ b/sw/ground_segment/cockpit/strip.ml
@@ -14,13 +14,11 @@ type t = {
}
let labels_name = [|
- [| "AP" ; "alt" ; "->" |]; [| "RC"; "climb"; "/" |]; [| "GPS"; "speed"; "" |];
- [| "settings" ; "throttle"; "" |]
+ [| "AP" ; "alt" ; "->" |]; [| "RC"; "climb"; "/" |]; [| "GPS"; "speed"; "throttle" |]
|]
let labels_print = [|
- [| "AP" ; "alt" ; "->" |]; [| "RC"; "climb"; "->" |]; [| "GPS"; "speed"; "" |];
- [| "CAL" ; "throttle"; "" |]
+ [| "AP" ; "alt" ; "->" |]; [| "RC"; "climb"; "->" |]; [| "GPS"; "speed"; "throttle" |]
|]
let gen_int = let i = ref (-1) in fun () -> incr i; !i
diff --git a/sw/ground_segment/tmtc/server.ml b/sw/ground_segment/tmtc/server.ml
index 0dca8b1051..afbc0db10a 100644
--- a/sw/ground_segment/tmtc/server.ml
+++ b/sw/ground_segment/tmtc/server.ml
@@ -638,16 +638,19 @@ let send_config = fun http _asker args ->
else
sprintf "file://%s" Env.paparazzi_home in
let prefix = fun s -> sprintf "%s/%s%s" protocol root_dir s in
+ let settings_file = try ExtXml.attrib conf "settings" with _ -> "settings/basic.xml" in (* c.f. gen_aircraft.ml *)
(** Expanded flight plan has been compiled in var/ *)
let fp = prefix ("var" // ac_name // "flight_plan.xml")
and af = prefix ("conf" // ExtXml.attrib conf "airframe")
- and rc = prefix ("conf" // ExtXml.attrib conf "radio") in
+ and rc = prefix ("conf" // ExtXml.attrib conf "radio")
+ and settings = prefix ("conf" // settings_file) in
let col = try Xml.attrib conf "gui_color" with _ -> new_color () in
let ac_name = try Xml.attrib conf "name" with _ -> "" in
["ac_id", Pprz.String ac_id;
"flight_plan", Pprz.String fp;
"airframe", Pprz.String af;
"radio", Pprz.String rc;
+ "settings", Pprz.String settings;
"default_gui_color", Pprz.String col;
"ac_name", Pprz.String ac_name
]
diff --git a/sw/tools/Makefile b/sw/tools/Makefile
index 74a2a61738..63f2e98798 100644
--- a/sw/tools/Makefile
+++ b/sw/tools/Makefile
@@ -27,7 +27,7 @@ OCAMLC=ocamlc -I ../lib/ocaml
OCAMLLEX=ocamllex
OCAMLYACC=ocamlyacc
-all: gen_aircraft.out gen_airframe.out gen_calib.out gen_messages.out gen_ubx.out gen_flight_plan.out gen_radio.out extract_makefile.out gen_control.out gen_periodic.out
+all: gen_aircraft.out gen_airframe.out gen_calib.out gen_messages.out gen_ubx.out gen_flight_plan.out gen_radio.out extract_makefile.out gen_control.out gen_periodic.out gen_settings.out
FP_CMO = fp_syntax.cmo fp_parser.cmo fp_lexer.cmo fp_proc.cmo gen_flight_plan.ml
ABS_FP = $(FP_CMO:%=$$PAPARAZZI_SRC/sw/tools/%)
diff --git a/sw/tools/gen_aircraft.ml b/sw/tools/gen_aircraft.ml
index 7423cf22a3..111bfe1ff9 100644
--- a/sw/tools/gen_aircraft.ml
+++ b/sw/tools/gen_aircraft.ml
@@ -41,8 +41,14 @@ let _ =
mkdir (aircraft_dir // "fbw");
mkdir (aircraft_dir // "autopilot");
mkdir (aircraft_dir // "sim");
+
+ let settings =
+ try value "settings" with
+ _ ->
+ fprintf stderr "\nWARNING: No 'settings' attribute specified for A/C '%s', using 'settings/basic.xml'\n\n%!" aircraft;
+ "settings/basic.xml" in
- let c = sprintf "make -f Makefile.ac AIRCRAFT=%s AC_ID=%s AIRFRAME=%s RADIO=%s FLIGHT_PLAN=%s TELEMETRY=%s" aircraft (value "ac_id") (value "airframe") (value "radio") (value "flight_plan") (value "telemetry") in
+ let c = sprintf "make -f Makefile.ac AIRCRAFT=%s AC_ID=%s AIRFRAME=%s RADIO=%s FLIGHT_PLAN=%s TELEMETRY=%s SETTINGS=%s" aircraft (value "ac_id") (value "airframe") (value "radio") (value "flight_plan") (value "telemetry") settings in
begin (** Quiet is speficied in the Makefile *)
try if Sys.getenv "Q" <> "@" then raise Not_found with
Not_found -> prerr_endline c
diff --git a/sw/tools/gen_calib.ml b/sw/tools/gen_calib.ml
deleted file mode 100644
index e6cf73da91..0000000000
--- a/sw/tools/gen_calib.ml
+++ /dev/null
@@ -1,105 +0,0 @@
-(*
- * $Id$
- *
- * XML preprocessing for in flight calibration
- *
- * Copyright (C) 2003-2006 Pascal Brisset, Antoine Drouin
- *
- * This file is part of paparazzi.
- *
- * paparazzi is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * paparazzi is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with paparazzi; see the file COPYING. If not, write to
- * the Free Software Foundation, 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- *)
-
-(** Generates code for tuning parameters using RC sliders *)
-
-open Printf
-open Xml2h
-
-let margin = ref 0
-let step = 2
-let tab () = printf "%s" (String.make !margin ' ')
-let right () = margin := !margin + step
-let left () = margin := !margin - step
-
-let lprintf = fun f -> tab (); printf f
-
-
-let calib_mode_of_rc = function
- "gain_1_up" -> 1, "up"
- | "gain_1_down" -> 1, "down"
- | "gain_2_up" -> 2, "up"
- | "gain_2_down" -> 2, "down"
- | x -> failwith (sprintf "Unknown rc: %s" x)
-
-let param_macro_of_type = fun x -> "ParamVal"^String.capitalize x
-
-let inttype = function
- "int16" -> "int16_t"
- | "float" -> "float"
- | x -> failwith (sprintf "Gen_calib.inttype: unknown type '%s'" x)
-
-let parse_setting = fun xml ->
- let cursor, cm = calib_mode_of_rc (ExtXml.attrib xml "rc")
- and var = ExtXml.attrib xml "var"
- and range = float_of_string (ExtXml.attrib xml "range") in
- let t = (ExtXml.attrib xml "type") in
- let param_macro = param_macro_of_type t in
- let var_init = var ^ "_init" in
-
- lprintf "if (rc_settings_mode == RC_SETTINGS_MODE_%s) {\n" (String.uppercase cm);
- right ();
- lprintf "static %s %s;\n" (inttype t) var_init;
- lprintf "static int16_t slider%d_init;\n" cursor;
- lprintf "if (mode_changed) {\n";
- right ();
- lprintf "%s = %s;\n" var_init var;
- lprintf "slider%d_init = RcChannel(RADIO_GAIN%d);\n" cursor cursor;
- left (); lprintf "}\n";
- lprintf "%s = %s(%s, %f, RcChannel(RADIO_GAIN%d), slider%d_init);\n" var param_macro var_init range cursor cursor;
- lprintf "slider_%d_val = (float)%s;\n" cursor var;
- left (); lprintf "}\n"
-
-
-let parse_mode = fun xml ->
- lprintf "if (pprz_mode == PPRZ_MODE_%s) {\n" (ExtXml.attrib xml "name");
- right ();
- List.iter parse_setting (Xml.children xml);
- left (); lprintf "}\n"
-
-let parse_modes = fun xml ->
- List.iter parse_mode (Xml.children xml)
-
-
-let _ =
- if Array.length Sys.argv < 2 then
- failwith (Printf.sprintf "Usage: %s xml_file" Sys.argv.(0));
- let xml_file = Sys.argv.(1) in
- let h_name = "INFLIGHT_CALIB_H" in
- try
- let xml = start_and_begin xml_file h_name in
-
- let rc_control =
- try ExtXml.child xml "rc_control" with Not_found -> Xml.Element("",[],[]) in
- lprintf "void rc_settings(bool_t mode_changed __attribute__ ((unused))) {\n";
- right ();
- parse_modes rc_control;
- left (); lprintf "}\n";
-
- finish h_name
- with
- Xml.Error e -> prerr_endline (Xml.error e)
- | Dtd.Prove_error e -> prerr_endline (Dtd.prove_error e); exit 1
diff --git a/sw/tools/gen_flight_plan.ml b/sw/tools/gen_flight_plan.ml
index c4c8ac028d..445641ddcc 100644
--- a/sw/tools/gen_flight_plan.ml
+++ b/sw/tools/gen_flight_plan.ml
@@ -591,57 +591,6 @@ let print_heights = fun xml wgs84 alt ->
end
-let rec flatten = fun xml r ->
- if ExtXml.tag_is xml "dl_setting" then
- xml::r
- else
- match Xml.children xml with
- [] -> r
- | x::xs ->
- List.iter (fun y -> assert(ExtXml.tag_is y (Xml.tag x))) xs;
- List.fold_right flatten (x::xs) r
-
-let print_dl_settings = fun settings ->
- let settings = flatten settings [] in
- (** Macro to call to set one variable *)
- lprintf "#define DlSetting(_idx, _value) { \\\n";
- right ();
- lprintf "switch (_idx) { \\\n";
- right ();
- let idx = ref 0 in
- List.iter
- (fun s ->
- let v = ExtXml.attrib s "var" in
- lprintf "case %d: %s = _value; break;\\\n" !idx v; incr idx)
- settings;
- left ();
- lprintf "}\\\n";
- left ();
- lprintf "}\n";
- let nb_values = !idx in
-
- (** Macro to call to download current values *)
- lprintf "#define PeriodicSendDlValue() { \\\n";
- if nb_values > 0 then begin
- right ();
- lprintf "static uint8_t i;\\\n";
- lprintf "float var;\\\n";
- lprintf "if (i >= %d) i = 0;;\\\n" nb_values;
- let idx = ref 0 in
- lprintf "switch (i) { \\\n";
- right ();
- List.iter
- (fun s ->
- let v = ExtXml.attrib s "var" in
- lprintf "case %d: var = %s; break;\\\n" !idx v; incr idx)
- settings;
- left ();
- lprintf "}\\\n";
- lprintf "DOWNLINK_SEND_DL_VALUE(&i, &var);\\\n";
- lprintf "i++;\\\n";
- left ()
- end;
- lprintf "}\n"
let print_inside_polygon = fun pts ->
@@ -709,7 +658,6 @@ let _ =
let xml = Fp_proc.process_relative_waypoints xml in
let xml = ExtXml.subst_child "blocks" (index_blocks (ExtXml.child xml "blocks")) xml in
let waypoints = ExtXml.child xml "waypoints"
- and dl_settings = try (ExtXml.child xml "dl_settings") with Not_found -> Xml.Element("dl_settings",[],[])
and blocks = Xml.children (ExtXml.child xml "blocks")
and global_exceptions = try Xml.children (ExtXml.child xml "exceptions") with _ -> [] in
@@ -790,8 +738,6 @@ let _ =
print_heights xml wgs84 (int_of_string alt);
- print_dl_settings dl_settings;
-
begin
try
let airspace = Xml.attrib xml "airspace" in
@@ -804,7 +750,7 @@ let _ =
end
with
Xml.Error e -> prerr_endline (Xml.error e); exit 1
- | Dtd.Prove_error e -> fprintf stderr "DTD error:%s\n%!" (Dtd.prove_error e); exit 1
- | Dtd.Check_error e -> fprintf stderr "DTD error:%s\n%!" (Dtd.check_error e); exit 1
- | Dtd.Parse_error e -> fprintf stderr "DTD error:%s\n%!" (Dtd.parse_error e); exit 1
+ | Dtd.Prove_error e -> fprintf stderr "%s: DTD error:%s\n%!" !xml_file (Dtd.prove_error e); exit 1
+ | Dtd.Check_error e -> fprintf stderr "%s: DTD error:%s\n%!" !xml_file (Dtd.check_error e); exit 1
+ | Dtd.Parse_error e -> fprintf stderr "%s: DTD error:%s\n%!" !xml_file (Dtd.parse_error e); exit 1
diff --git a/sw/tools/gen_settings.ml b/sw/tools/gen_settings.ml
new file mode 100644
index 0000000000..12d8050659
--- /dev/null
+++ b/sw/tools/gen_settings.ml
@@ -0,0 +1,166 @@
+(*
+ * $Id$
+ *
+ * XML preprocessing for dynamic tuning
+ *
+ * Copyright (C) 2006 Pascal Brisset, Antoine Drouin
+ *
+ * This file is part of paparazzi.
+ *
+ * paparazzi is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * paparazzi is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with paparazzi; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ *)
+
+(** Generates code for tuning parameters using RC sliders and datalink *)
+
+open Printf
+open Xml2h
+
+let margin = ref 0
+let step = 2
+let tab () = printf "%s" (String.make !margin ' ')
+let right () = margin := !margin + step
+let left () = margin := !margin - step
+
+let lprintf = fun f -> tab (); printf f
+
+let rec flatten = fun xml r ->
+ if ExtXml.tag_is xml "dl_setting" then
+ xml::r
+ else
+ match Xml.children xml with
+ [] -> r
+ | x::xs ->
+ List.iter (fun y -> assert(ExtXml.tag_is y (Xml.tag x))) xs;
+ List.fold_right flatten (x::xs) r
+
+
+let print_dl_settings = fun settings ->
+ let settings = flatten settings [] in
+ (** Macro to call to set one variable *)
+ lprintf "#define DlSetting(_idx, _value) { \\\n";
+ right ();
+ lprintf "switch (_idx) { \\\n";
+ right ();
+ let idx = ref 0 in
+ List.iter
+ (fun s ->
+ let v = ExtXml.attrib s "var" in
+ lprintf "case %d: %s = _value; break;\\\n" !idx v; incr idx)
+ settings;
+ left ();
+ lprintf "}\\\n";
+ left ();
+ lprintf "}\n";
+ let nb_values = !idx in
+
+ (** Macro to call to download current values *)
+ lprintf "#define PeriodicSendDlValue() { \\\n";
+ if nb_values > 0 then begin
+ right ();
+ lprintf "static uint8_t i;\\\n";
+ lprintf "float var;\\\n";
+ lprintf "if (i >= %d) i = 0;;\\\n" nb_values;
+ let idx = ref 0 in
+ lprintf "switch (i) { \\\n";
+ right ();
+ List.iter
+ (fun s ->
+ let v = ExtXml.attrib s "var" in
+ lprintf "case %d: var = %s; break;\\\n" !idx v; incr idx)
+ settings;
+ left ();
+ lprintf "}\\\n";
+ lprintf "DOWNLINK_SEND_DL_VALUE(&i, &var);\\\n";
+ lprintf "i++;\\\n";
+ left ()
+ end;
+ lprintf "}\n"
+
+
+
+
+let calib_mode_of_rc = function
+ "gain_1_up" -> 1, "up"
+ | "gain_1_down" -> 1, "down"
+ | "gain_2_up" -> 2, "up"
+ | "gain_2_down" -> 2, "down"
+ | x -> failwith (sprintf "Unknown rc: %s" x)
+
+let param_macro_of_type = fun x -> "ParamVal"^String.capitalize x
+
+let inttype = function
+ "int16" -> "int16_t"
+ | "float" -> "float"
+ | x -> failwith (sprintf "Gen_calib.inttype: unknown type '%s'" x)
+
+let parse_rc_setting = fun xml ->
+ let cursor, cm = calib_mode_of_rc (ExtXml.attrib xml "rc")
+ and var = ExtXml.attrib xml "var"
+ and range = float_of_string (ExtXml.attrib xml "range") in
+ let t = (ExtXml.attrib xml "type") in
+ let param_macro = param_macro_of_type t in
+ let var_init = var ^ "_init" in
+
+ lprintf "if (rc_settings_mode == RC_SETTINGS_MODE_%s) { \\\n" (String.uppercase cm);
+ right ();
+ lprintf "static %s %s; \\\n" (inttype t) var_init;
+ lprintf "static int16_t slider%d_init; \\\n" cursor;
+ lprintf "if (mode_changed) { \\\n";
+ right ();
+ lprintf "%s = %s; \\\n" var_init var;
+ lprintf "slider%d_init = RcChannel(RADIO_GAIN%d); \\\n" cursor cursor;
+ left (); lprintf "} \\\n";
+ lprintf "%s = %s(%s, %f, RcChannel(RADIO_GAIN%d), slider%d_init); \\\n" var param_macro var_init range cursor cursor;
+ lprintf "slider_%d_val = (float)%s; \\\n" cursor var;
+ left (); lprintf "} \\\n"
+
+
+let parse_rc_mode = fun xml ->
+ lprintf "if (pprz_mode == PPRZ_MODE_%s) { \\\n" (ExtXml.attrib xml "name");
+ right ();
+ List.iter parse_rc_setting (Xml.children xml);
+ left (); lprintf "} \\\n"
+
+let parse_rc_modes = fun xml ->
+ List.iter parse_rc_mode (Xml.children xml)
+
+
+let _ =
+ if Array.length Sys.argv < 2 then
+ failwith (Printf.sprintf "Usage: %s xml_file" Sys.argv.(0));
+ let xml_file = Sys.argv.(1) in
+ let h_name = "SETTINGS_H" in
+ try
+ let xml = start_and_begin xml_file h_name in
+
+ let rc_control =
+ try ExtXml.child xml "rc_settings" with Not_found -> Xml.Element("",[],[]) in
+ lprintf "#define RCSettings(mode_changed) { \\\n";
+ right ();
+ parse_rc_modes rc_control;
+ left (); lprintf "}\n";
+
+
+ let dl_settings = try (ExtXml.child xml "dl_settings") with Not_found -> Xml.Element("dl_settings",[],[]) in
+
+ print_dl_settings dl_settings;
+
+
+ finish h_name
+ with
+ Xml.Error e -> prerr_endline (Xml.error e)
+ | Dtd.Prove_error e -> prerr_endline (Dtd.prove_error e); exit 1