Skip to content

Commit

Permalink
[link] fix link report
Browse files Browse the repository at this point in the history
  • Loading branch information
gautierhattenberger committed Dec 1, 2014
1 parent 7b4b1ae commit 15f63ad
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
14 changes: 7 additions & 7 deletions sw/ground_segment/tmtc/aircraft.ml
Expand Up @@ -66,12 +66,12 @@ type datalink_status = {
mutable downlink_rate : int;
}
type link_status = {
mutable rx_lost_time : float;
mutable rx_bytes : int;
mutable rx_msgs : int;
mutable rx_bytes_rate : float;
mutable tx_msgs : int;
mutable ping_time : float
rx_lost_time : int;
rx_bytes : int;
rx_msgs : int;
rx_bytes_rate : float;
tx_msgs : int;
ping_time : float
}

let datalink_status_init = fun () ->
Expand All @@ -83,7 +83,7 @@ let datalink_status_init = fun () ->
}
let link_status_init = fun () ->
{
rx_lost_time = 9999.;
rx_lost_time = 9999;
rx_bytes = 0;
rx_msgs = 0;
rx_bytes_rate = 0.;
Expand Down
12 changes: 6 additions & 6 deletions sw/ground_segment/tmtc/aircraft.mli
Expand Up @@ -56,12 +56,12 @@ type datalink_status = {
mutable downlink_rate : int;
}
type link_status = {
mutable rx_lost_time : float;
mutable rx_bytes : int;
mutable rx_msgs : int;
mutable rx_bytes_rate : float;
mutable tx_msgs : int;
mutable ping_time : float
rx_lost_time : int;
rx_bytes : int;
rx_msgs : int;
rx_bytes_rate : float;
tx_msgs : int;
ping_time : float
}
val datalink_status_init : unit -> datalink_status
val link_status_init : unit -> link_status
Expand Down
9 changes: 8 additions & 1 deletion sw/ground_segment/tmtc/link.ml
Expand Up @@ -79,6 +79,13 @@ let send_message_over_ivy = fun sender name vs ->
else
Tm_Pprz.message_send ?timestamp sender name vs

let send_ground_over_ivy = fun sender name vs ->
let timestamp =
match !add_timestamp with
None -> None
| Some start_time -> Some (Unix.gettimeofday () -. start_time) in
Ground_Pprz.message_send ?timestamp sender name vs


(*********** Monitoring *************************************************)
type status = {
Expand Down Expand Up @@ -167,7 +174,7 @@ let send_status_msg =
"tx_msgs", Pprz.Int 0;
"ping_time", Pprz.Float (1000. *. (status.last_pong -. status.last_ping))
] in
send_message_over_ivy (string_of_int ac_id) "LINK_REPORT" vs)
send_ground_over_ivy "link" "LINK_REPORT" vs)
statuss


Expand Down
23 changes: 10 additions & 13 deletions sw/ground_segment/tmtc/server.ml
Expand Up @@ -713,19 +713,16 @@ let link_report = fun logging _sender vs ->
let ac_id = Pprz.string_assoc "ac_id" vs
and link_id = Pprz.int_assoc "link_id" vs in
try
begin
let ac = Hashtbl.find aircrafts ac_id in
try
let link_status = Hashtbl.find ac.link_status link_id in
link_status.rx_lost_time <- Pprz.float_assoc "rx_lost_time" vs;
link_status.rx_bytes <- Pprz.int_assoc "rx_bytes" vs;
link_status.rx_msgs <- Pprz.int_assoc "rx_msgs" vs;
link_status.rx_bytes_rate <- Pprz.float_assoc "rx_bytes_rate" vs;
link_status.tx_msgs <- Pprz.int_assoc "tx_msgs" vs;
link_status.ping_time <- Pprz.float_assoc "ping_time" vs;
Hashtbl.replace ac.link_status link_id link_status
with Not_found -> Hashtbl.add ac.link_status link_id (Aircraft.link_status_init ())
end
let ac = Hashtbl.find aircrafts ac_id in
let link_status = {
Aircraft.rx_lost_time = Pprz.int_assoc "rx_lost_time" vs;
rx_bytes = Pprz.int_assoc "rx_bytes" vs;
rx_msgs = Pprz.int_assoc "rx_msgs" vs;
rx_bytes_rate = Pprz.float_assoc "rx_bytes_rate" vs;
tx_msgs = Pprz.int_assoc "tx_msgs" vs;
ping_time = Pprz.float_assoc "ping_time" vs;
} in
Hashtbl.replace ac.link_status link_id link_status;
with _ -> ()


Expand Down

0 comments on commit 15f63ad

Please sign in to comment.