Skip to content

Commit

Permalink
[tools] generated MODULES_FREQUENCY defaults to PERIODIC_FREQUENCY
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Sep 13, 2013
1 parent ae0a26a commit 6ea53c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 10 additions & 2 deletions Makefile.ac
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,19 @@ Q=@
#
ifeq ($(MAKECMDGOALS),all_ac_h)
-include $(MAKEFILE_AC)
endif

# telemetry periodic frequency defaults to 60Hz
TELEMETRY_FREQUENCY ?= 60

ifdef PERIODIC_FREQUENCY
DEFAULT_MODULES_FREQUENCY = $(PERIODIC_FREQUENCY)
else
$(error Error: PERIODIC_FREQUENCY not configured)
endif

endif


init:
@[ -d $(PAPARAZZI_HOME) ] || (echo "Copying config example in your $(PAPARAZZI_HOME) directory"; mkdir -p $(PAPARAZZI_HOME); cp -a conf $(PAPARAZZI_HOME); cp -a data $(PAPARAZZI_HOME); mkdir -p $(PAPARAZZI_HOME)/var/maps; mkdir -p $(PAPARAZZI_HOME)/var/include)

Expand Down Expand Up @@ -147,7 +155,7 @@ $(MODULES_H) : $(CONF)/$(AIRFRAME_XML) $(TOOLS)/gen_modules.out $(CONF)/modules/
$(Q)test -d $(AC_GENERATED) || mkdir -p $(AC_GENERATED)
@echo GENERATE $@
$(eval $@_TMP := $(shell $(MKTEMP)))
$(Q)$(TOOLS)/gen_modules.out $(SETTINGS_MODULES) $< > $($@_TMP)
$(Q)$(TOOLS)/gen_modules.out $(SETTINGS_MODULES) $(DEFAULT_MODULES_FREQUENCY) $< > $($@_TMP)
$(Q)mv $($@_TMP) $@
$(Q)chmod a+r $@

Expand Down
9 changes: 5 additions & 4 deletions sw/tools/gen_modules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,10 @@ let write_settings = fun xml_file out_set modules ->
let h_name = "MODULES_H"

let () =
if Array.length Sys.argv <> 3 then
failwith (Printf.sprintf "Usage: %s out_settings_file xml_file" Sys.argv.(0));
let xml_file = Sys.argv.(2)
if Array.length Sys.argv <> 4 then
failwith (Printf.sprintf "Usage: %s out_settings_file default_freq xml_file" Sys.argv.(0));
let xml_file = Sys.argv.(3)
and default_freq = int_of_string(Sys.argv.(2))
and out_set = open_out Sys.argv.(1) in
try
let xml = start_and_begin xml_file h_name in
Expand All @@ -357,7 +358,7 @@ let () =
nl ();
(* Extract main_freq parameter *)
let modules = try (ExtXml.child xml "modules") with _ -> Xml.Element("modules",[],[]) in
let main_freq = try (int_of_string (Xml.attrib modules "main_freq")) with _ -> !freq in
let main_freq = try (int_of_string (Xml.attrib modules "main_freq")) with _ -> default_freq in
freq := main_freq;
fprintf out_h "#define MODULES_FREQUENCY %d\n" !freq;
nl ();
Expand Down

0 comments on commit 6ea53c5

Please sign in to comment.