mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
[fix] allow float values for delay in module XML (#2652)
* [fix] allow float values for delay in module XML see comments in #2553 * [conf] update delay parameters and add warning in generator
This commit is contained in:
committed by
GitHub
parent
494e3f3ad9
commit
b6a300d03e
@@ -18,7 +18,7 @@
|
||||
<file name="MPPT.h"/>
|
||||
</header>
|
||||
<init fun="MPPT_init()"/>
|
||||
<periodic fun="MPPT_periodic()" freq="8." delay="4" autorun="TRUE"/>
|
||||
<periodic fun="MPPT_periodic()" freq="8." delay="0.15" autorun="TRUE"/>
|
||||
<makefile target="ap">
|
||||
<file name="MPPT.c"/>
|
||||
</makefile>
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
<file name="alt_srf08.h"/>
|
||||
</header>
|
||||
<init fun="srf08_init()"/>
|
||||
<periodic fun="srf08_initiate_ranging()" freq="1"/>
|
||||
<!-- 65ms since initiate_ranging() (the spec ask for 65ms),
|
||||
delay="4", 60Hz, 4x 16.7ms = 66.7ms -->
|
||||
<periodic fun="srf08_receive()" freq="1" delay="4"/>
|
||||
<periodic fun="srf08_initiate_ranging()" freq="1" delay="0."/>
|
||||
<!-- 70ms (delay 0.7 with freq = 1Hz since initiate_ranging()
|
||||
(the spec ask for 65ms) -->
|
||||
<periodic fun="srf08_receive()" freq="1" delay="0.07"/>
|
||||
<event fun="srf08_event()"/>
|
||||
<makefile>
|
||||
<file name="alt_srf08.c"/>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<file name="dust_gp2y.h"/>
|
||||
</header>
|
||||
<init fun="dust_gp2y_init()"/>
|
||||
<periodic fun="dust_gp2y_periodic()" freq="4" delay="1"/>
|
||||
<periodic fun="dust_gp2y_periodic()" freq="4" delay="0.6"/>
|
||||
<event fun="dust_gp2y_event()"/>
|
||||
<makefile target="ap">
|
||||
<file name="dust_gp2y.c"/>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<file name="gsm.h"/>
|
||||
</header>
|
||||
<init fun="gsm_init()"/>
|
||||
<periodic fun="gsm_init_report()" period="60." delay="3599" autorun="TRUE"/>
|
||||
<periodic fun="gsm_init_report()" period="60." delay="0.95" autorun="TRUE"/>
|
||||
<periodic fun="gsm_send_report()" period="60." autorun="FALSE"/>
|
||||
<event fun="gsm_event()"/>
|
||||
<makefile>
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<file name="humid_htm_b71.h"/>
|
||||
</header>
|
||||
<init fun="humid_htm_init()"/>
|
||||
<periodic fun="humid_htm_start()" freq="4" delay="10"/>
|
||||
<periodic fun="humid_htm_read()" freq="4" delay="14"/>
|
||||
<periodic fun="humid_htm_start()" freq="4" delay="0.66"/>
|
||||
<periodic fun="humid_htm_read()" freq="4" delay="0.9"/>
|
||||
<event fun="humid_htm_event()"/>
|
||||
<makefile target="ap">
|
||||
<configure name="HTM_I2C_DEV" default="i2c0" case="upper|lower"/>
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
<file name="humid_sht_i2c.h"/>
|
||||
</header>
|
||||
<init fun="humid_sht_init_i2c()"/>
|
||||
<periodic fun="humid_sht_periodic_i2c()" freq="4" delay="0"/>
|
||||
<periodic fun="humid_sht_p_temp()" freq="4" delay="6"/>
|
||||
<periodic fun="humid_sht_p_humid()" freq="4" delay="9"/>
|
||||
<periodic fun="humid_sht_periodic_i2c()" freq="4" delay="0."/>
|
||||
<periodic fun="humid_sht_p_temp()" freq="4" delay="0.4"/>
|
||||
<periodic fun="humid_sht_p_humid()" freq="4" delay="0.6"/>
|
||||
<event fun="humid_sht_event_i2c()"/>
|
||||
<makefile target="ap">
|
||||
<file name="humid_sht_i2c.c"/>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<file name="wind_gfi.h"/>
|
||||
</header>
|
||||
<init fun="wind_gfi_init()"/>
|
||||
<periodic fun="wind_gfi_periodic()" freq="4" delay="2"/>
|
||||
<periodic fun="wind_gfi_periodic()" freq="4" delay="0.13"/>
|
||||
<event fun="wind_gfi_event()"/>
|
||||
<makefile target="ap">
|
||||
<file name="wind_gfi.c"/>
|
||||
|
||||
@@ -141,7 +141,7 @@ type periodic = {
|
||||
call: string;
|
||||
fname: string;
|
||||
period_freq: period_freq;
|
||||
delay: int option;
|
||||
delay: float option;
|
||||
start: string option;
|
||||
stop: string option;
|
||||
autorun: autorun
|
||||
@@ -149,7 +149,7 @@ type periodic = {
|
||||
|
||||
let parse_periodic = fun xml ->
|
||||
let get = fun x -> ExtXml.attrib_opt xml x in
|
||||
let geti = fun x -> ExtXml.attrib_opt_int xml x in
|
||||
let getf = fun x -> ExtXml.attrib_opt_float xml x in
|
||||
let call = snd (List.find (fun (a, _) -> Compat.lowercase_ascii a = "fun")
|
||||
(Xml.attribs xml)) in
|
||||
let call_regexp = Str.regexp "\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\(.*\\)" in
|
||||
@@ -176,7 +176,7 @@ let parse_periodic = fun xml ->
|
||||
with _ -> Period p
|
||||
end
|
||||
in
|
||||
{ call; fname; period_freq; delay = geti "delay";
|
||||
{ call; fname; period_freq; delay = getf "delay";
|
||||
start = get "start"; stop = get "stop";
|
||||
autorun = match get "autorun" with
|
||||
| None -> Lock
|
||||
|
||||
@@ -111,7 +111,12 @@ let get_functions_modulos = fun modules ->
|
||||
let p, _ = get_period_and_freq x in
|
||||
let d = begin try
|
||||
let _d = float_of_string (Xml.attrib x "delay") in
|
||||
if _d > 0.95 then _d /. 65536. else _d (* try to keep some backward compatibility *)
|
||||
if _d > 0.99 then
|
||||
begin
|
||||
fprintf stderr "Warning: 'delay' attribute should be a float value between 0. and 1.\n";
|
||||
_d /. 65536.
|
||||
end
|
||||
else _d (* try to keep some backward compatibility *)
|
||||
with _ ->
|
||||
delay := !delay +. 0.1;
|
||||
if !delay > 0.9 then delay := 0.;
|
||||
|
||||
Reference in New Issue
Block a user