mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-28 09:58:23 +08:00
[link] parameters for period of PING and LINK_REPORT messages
closes #1037
This commit is contained in:
@@ -69,6 +69,10 @@ let gen_stat_trafic = ref false
|
|||||||
|
|
||||||
let add_timestamp = ref None
|
let add_timestamp = ref None
|
||||||
|
|
||||||
|
let status_msg_period = ref 1000 (** ms *)
|
||||||
|
let ping_msg_period = ref 5000 (** ms *)
|
||||||
|
|
||||||
|
|
||||||
let send_message_over_ivy = fun sender name vs ->
|
let send_message_over_ivy = fun sender name vs ->
|
||||||
let timestamp =
|
let timestamp =
|
||||||
match !add_timestamp with
|
match !add_timestamp with
|
||||||
@@ -128,8 +132,6 @@ let update_status = fun ?udp_peername ac_id buf_size is_pong ->
|
|||||||
if is_pong then
|
if is_pong then
|
||||||
status.last_pong <- Unix.gettimeofday ();;
|
status.last_pong <- Unix.gettimeofday ();;
|
||||||
|
|
||||||
let status_msg_period = 1000 (** ms *)
|
|
||||||
let ping_msg_period = 5000 (** ms *)
|
|
||||||
let status_ping_diff = 500 (* ms *)
|
let status_ping_diff = 500 (* ms *)
|
||||||
|
|
||||||
let live_aircraft = fun ac_id ->
|
let live_aircraft = fun ac_id ->
|
||||||
@@ -155,7 +157,7 @@ let send_status_msg =
|
|||||||
let start = Unix.gettimeofday () in
|
let start = Unix.gettimeofday () in
|
||||||
fun () ->
|
fun () ->
|
||||||
Hashtbl.iter (fun ac_id status ->
|
Hashtbl.iter (fun ac_id status ->
|
||||||
let dt = float status_msg_period /. 1000. in
|
let dt = float !status_msg_period /. 1000. in
|
||||||
let t = int_of_float (Unix.gettimeofday () -. start) in
|
let t = int_of_float (Unix.gettimeofday () -. start) in
|
||||||
let byte_rate = float (status.rx_byte - status.last_rx_byte) /. dt
|
let byte_rate = float (status.rx_byte - status.last_rx_byte) /. dt
|
||||||
and msg_rate = float (status.rx_msg - status.last_rx_msg) /. dt in
|
and msg_rate = float (status.rx_msg - status.last_rx_msg) /. dt in
|
||||||
@@ -179,7 +181,7 @@ let send_status_msg =
|
|||||||
let update_ms_since_last_msg =
|
let update_ms_since_last_msg =
|
||||||
fun () ->
|
fun () ->
|
||||||
Hashtbl.iter (fun ac_id status ->
|
Hashtbl.iter (fun ac_id status ->
|
||||||
status.ms_since_last_msg <- status.ms_since_last_msg + status_msg_period / 3)
|
status.ms_since_last_msg <- status.ms_since_last_msg + !status_msg_period / 3)
|
||||||
statuss
|
statuss
|
||||||
|
|
||||||
let use_tele_message = fun ?udp_peername ?raw_data_size payload ->
|
let use_tele_message = fun ?udp_peername ?raw_data_size payload ->
|
||||||
@@ -483,7 +485,9 @@ let () =
|
|||||||
"-xbee_retries", Arg.Set_int XB.my_addr, (sprintf "<nb retries> (%d)" !XB.nb_retries);
|
"-xbee_retries", Arg.Set_int XB.my_addr, (sprintf "<nb retries> (%d)" !XB.nb_retries);
|
||||||
"-xbee_868", Arg.Set Xbee.mode868, (sprintf "Enables the 868 protocol");
|
"-xbee_868", Arg.Set Xbee.mode868, (sprintf "Enables the 868 protocol");
|
||||||
"-redlink", Arg.Set red_link, (sprintf "Sets whether the link is a redundant link. Set this flag and the id flag to use multiple links");
|
"-redlink", Arg.Set red_link, (sprintf "Sets whether the link is a redundant link. Set this flag and the id flag to use multiple links");
|
||||||
"-id", Arg.Set_int link_id, (sprintf "Sets the link id. If multiple links are used, each must have a unique id. Default is %i" !link_id)
|
"-id", Arg.Set_int link_id, (sprintf "<id> Sets the link id. If multiple links are used, each must have a unique id. Default is %i" !link_id);
|
||||||
|
"-status_period", Arg.Set_int status_msg_period, (sprintf "<period> Sets the period (in ms) of the LINK_REPORT status message. Default is %i" !status_msg_period);
|
||||||
|
"-ping_period", Arg.Set_int ping_msg_period, (sprintf "<period> Sets the period (in ms) of the PING message sent to aircrafs. Default is %i" !ping_msg_period)
|
||||||
] in
|
] in
|
||||||
Arg.parse options (fun _x -> ()) "Usage: ";
|
Arg.parse options (fun _x -> ()) "Usage: ";
|
||||||
|
|
||||||
@@ -548,10 +552,10 @@ let () =
|
|||||||
|
|
||||||
(** Init and Periodic tasks *)
|
(** Init and Periodic tasks *)
|
||||||
begin
|
begin
|
||||||
ignore (Glib.Timeout.add status_msg_period (fun () -> send_status_msg (); true));
|
ignore (Glib.Timeout.add !status_msg_period (fun () -> send_status_msg (); true));
|
||||||
ignore (Glib.Timeout.add (status_msg_period / 3) (fun () -> update_ms_since_last_msg (); true));
|
ignore (Glib.Timeout.add (!status_msg_period / 3) (fun () -> update_ms_since_last_msg (); true));
|
||||||
let start_ping = fun () ->
|
let start_ping = fun () ->
|
||||||
ignore (Glib.Timeout.add ping_msg_period (fun () -> send_ping_msg device; true));
|
ignore (Glib.Timeout.add !ping_msg_period (fun () -> send_ping_msg device; true));
|
||||||
false in
|
false in
|
||||||
ignore (Glib.Timeout.add status_ping_diff start_ping);
|
ignore (Glib.Timeout.add status_ping_diff start_ping);
|
||||||
if !aerocomm then
|
if !aerocomm then
|
||||||
|
|||||||
Reference in New Issue
Block a user