mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-31 12:23:23 +08:00
Start of work on Redundant Link. This first step modifies the exisitng link agent to allow it to be given an id (through the -link_id flag) and to send ivy messages of a different format (when -redlink is set). The messages are sent within the TELEMETRY_MESSAGE message as a ;sv (colon-seperated-value) which are listed to by the link_combiner.py agent.
This commit is contained in:
@@ -151,6 +151,7 @@
|
|||||||
</message>
|
</message>
|
||||||
|
|
||||||
<message name="DOWNLINK_STATUS" id="23">
|
<message name="DOWNLINK_STATUS" id="23">
|
||||||
|
<field name="link_id" type="int8"/>
|
||||||
<field name="run_time" type="uint32" unit="s"/>
|
<field name="run_time" type="uint32" unit="s"/>
|
||||||
<field name="rx_bytes" type="uint32"/>
|
<field name="rx_bytes" type="uint32"/>
|
||||||
<field name="rx_msgs" type="uint32"/>
|
<field name="rx_msgs" type="uint32"/>
|
||||||
@@ -2461,6 +2462,18 @@
|
|||||||
<field name="message" type="string"/>
|
<field name="message" type="string"/>
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
<message name="TELEMETRY_MESSAGE" id="34">
|
||||||
|
<field name="ac_id" type="string"/>
|
||||||
|
<field name="link_id" type="string" />
|
||||||
|
<field name="message" type="string" format=";sv"/>
|
||||||
|
</message>
|
||||||
|
|
||||||
|
<message name="DATALINK_MESSAGE" id="35">
|
||||||
|
<field name="ac_id" type="string"/>
|
||||||
|
<field name="link_id" type="string"/>
|
||||||
|
<field name="message" type="string" format=";sv"/>
|
||||||
|
</message>
|
||||||
|
|
||||||
<message name="PLUMES" id="100">
|
<message name="PLUMES" id="100">
|
||||||
<field name="ids" type="string" format="csv"/>
|
<field name="ids" type="string" format="csv"/>
|
||||||
<field name="lats" type="string" format="csv"/>
|
<field name="lats" type="string" format="csv"/>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
*)
|
*)
|
||||||
|
|
||||||
(** Agent connecting a hardware modem, usually through USB/serial, with
|
(** Agent connecting a hardware modem, usually through USB/serial, with
|
||||||
the Ivy sowtware bus.
|
the Ivy software bus.
|
||||||
*)
|
*)
|
||||||
|
|
||||||
open Latlong
|
open Latlong
|
||||||
@@ -40,7 +40,7 @@ type transport =
|
|||||||
| Pprz2 (* Paparazzi protocol, with timestamp, A/C id, message id and CRC *)
|
| Pprz2 (* Paparazzi protocol, with timestamp, A/C id, message id and CRC *)
|
||||||
| XBee (* Maxstream protocol, API mode *)
|
| XBee (* Maxstream protocol, API mode *)
|
||||||
let transport_of_string = function
|
let transport_of_string = function
|
||||||
"pprz" -> Pprz
|
"pprz" -> Pprz
|
||||||
| "pprz2" -> Pprz2
|
| "pprz2" -> Pprz2
|
||||||
| "xbee" -> XBee
|
| "xbee" -> XBee
|
||||||
| x -> invalid_arg (sprintf "transport_of_string: %s" x)
|
| x -> invalid_arg (sprintf "transport_of_string: %s" x)
|
||||||
@@ -53,6 +53,9 @@ type ground_device = {
|
|||||||
(* We assume here a single modem is used *)
|
(* We assume here a single modem is used *)
|
||||||
let my_id = 0
|
let my_id = 0
|
||||||
|
|
||||||
|
(* Here we set the default id of the link*)
|
||||||
|
let link_id = ref 1
|
||||||
|
|
||||||
(* enable broadcast messages by default *)
|
(* enable broadcast messages by default *)
|
||||||
let ac_info = ref true
|
let ac_info = ref true
|
||||||
|
|
||||||
@@ -70,7 +73,7 @@ let send_message_over_ivy = fun sender name vs ->
|
|||||||
match !add_timestamp with
|
match !add_timestamp with
|
||||||
None -> None
|
None -> None
|
||||||
| Some start_time -> Some (Unix.gettimeofday () -. start_time) in
|
| Some start_time -> Some (Unix.gettimeofday () -. start_time) in
|
||||||
Tm_Pprz.message_send ?timestamp sender name vs
|
Tm_Pprz.message_send ?timestamp ~link_id:!link_id sender name vs
|
||||||
|
|
||||||
|
|
||||||
(*********** Monitoring *************************************************)
|
(*********** Monitoring *************************************************)
|
||||||
@@ -146,7 +149,8 @@ let send_status_msg =
|
|||||||
status.last_rx_msg <- status.rx_msg;
|
status.last_rx_msg <- status.rx_msg;
|
||||||
status.last_rx_byte <- status.rx_byte;
|
status.last_rx_byte <- status.rx_byte;
|
||||||
status.ms_since_last_msg <- status.ms_since_last_msg + status_msg_period;
|
status.ms_since_last_msg <- status.ms_since_last_msg + status_msg_period;
|
||||||
let vs = ["run_time", Pprz.Int t;
|
let vs = ["link_id", Pprz.Int !link_id;
|
||||||
|
"run_time", Pprz.Int t;
|
||||||
"rx_bytes_rate", Pprz.Float byte_rate;
|
"rx_bytes_rate", Pprz.Float byte_rate;
|
||||||
"rx_msgs_rate", Pprz.Float msg_rate;
|
"rx_msgs_rate", Pprz.Float msg_rate;
|
||||||
"rx_err", Pprz.Int status.rx_err;
|
"rx_err", Pprz.Int status.rx_err;
|
||||||
@@ -453,6 +457,7 @@ let () =
|
|||||||
"-xbee_addr", Arg.Set_int XB.my_addr, (sprintf "<my_addr> (%d)" !XB.my_addr);
|
"-xbee_addr", Arg.Set_int XB.my_addr, (sprintf "<my_addr> (%d)" !XB.my_addr);
|
||||||
"-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");
|
||||||
|
"-id", Arg.Set_int link_id, (sprintf "Sets the link id. This must be set if multiple links are to be used.")
|
||||||
] in
|
] in
|
||||||
Arg.parse options (fun _x -> ()) "Usage: ";
|
Arg.parse options (fun _x -> ()) "Usage: ";
|
||||||
|
|
||||||
|
|||||||
+19
-5
@@ -485,10 +485,10 @@ module type MESSAGES = sig
|
|||||||
val string_of_message : ?sep:string -> message -> values -> string
|
val string_of_message : ?sep:string -> message -> values -> string
|
||||||
(** [string_of_message ?sep msg values] Default [sep] is space *)
|
(** [string_of_message ?sep msg values] Default [sep] is space *)
|
||||||
|
|
||||||
val message_send : ?timestamp:float -> string -> string -> values -> unit
|
val message_send : ?timestamp:float -> ?link_id:int -> string -> string -> values -> unit
|
||||||
(** [message_send sender msg_name values] *)
|
(** [message_send sender link_id msg_name values] *)
|
||||||
|
|
||||||
val message_bind : ?sender:string ->string -> (string -> values -> unit) -> Ivy.binding
|
val message_bind : ?sender:string -> string -> (string -> values -> unit) -> Ivy.binding
|
||||||
(** [message_bind ?sender msg_name callback] *)
|
(** [message_bind ?sender msg_name callback] *)
|
||||||
|
|
||||||
val message_answerer : string -> string -> (string -> values -> values) -> Ivy.binding
|
val message_answerer : string -> string -> (string -> values -> values) -> Ivy.binding
|
||||||
@@ -609,8 +609,22 @@ module MessagesOfXml(Class:CLASS_Xml) = struct
|
|||||||
if n > 1000 then (** FIXME: to prevent Ivy bug on long message *)
|
if n > 1000 then (** FIXME: to prevent Ivy bug on long message *)
|
||||||
fprintf stderr "Discarding long ivy message (%d bytes)\n%!" n
|
fprintf stderr "Discarding long ivy message (%d bytes)\n%!" n
|
||||||
else
|
else
|
||||||
Ivy.send msg
|
match link_id with
|
||||||
|
None -> Ivy.send msg
|
||||||
|
| Some the_link_id -> begin
|
||||||
|
let index = ref 0 in
|
||||||
|
let modified_msg = String.copy msg in
|
||||||
|
let func = fun c ->
|
||||||
|
match c with
|
||||||
|
' ' -> begin
|
||||||
|
String.set modified_msg !index ';';
|
||||||
|
index := !index + 1
|
||||||
|
end
|
||||||
|
| x -> index := !index + 1; in
|
||||||
|
String.iter func modified_msg;
|
||||||
|
Ivy.send ( Printf.sprintf "redlink TELEMETRY_MESSAGE %s %i %s" sender the_link_id modified_msg);
|
||||||
|
end
|
||||||
|
|
||||||
let message_bind = fun ?sender msg_name cb ->
|
let message_bind = fun ?sender msg_name cb ->
|
||||||
match sender with
|
match sender with
|
||||||
None ->
|
None ->
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ module type MESSAGES = sig
|
|||||||
val string_of_message : ?sep:string -> message -> values -> string
|
val string_of_message : ?sep:string -> message -> values -> string
|
||||||
(** [string_of_message ?sep msg values] Default [sep] is space *)
|
(** [string_of_message ?sep msg values] Default [sep] is space *)
|
||||||
|
|
||||||
val message_send : ?timestamp:float -> string -> string -> values -> unit
|
val message_send : ?timestamp:float -> ?link_id:int -> string -> string -> values -> unit
|
||||||
(** [message_send sender msg_name values] *)
|
(** [message_send sender msg_name values] *)
|
||||||
|
|
||||||
val message_bind : ?sender:string ->string -> (string -> values -> unit) -> Ivy.binding
|
val message_bind : ?sender:string ->string -> (string -> values -> unit) -> Ivy.binding
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ module Gen_onboard = struct
|
|||||||
sprintf "({ union { uint64_t u; double f; } _f; _f.u = (uint64_t)(%s); Swap32IfBigEndian(_f.u); _f.f; })" !s
|
sprintf "({ union { uint64_t u; double f; } _f; _f.u = (uint64_t)(%s); Swap32IfBigEndian(_f.u); _f.f; })" !s
|
||||||
| 4 ->
|
| 4 ->
|
||||||
sprintf "(%s)(*((uint8_t*)_payload+%d)|*((uint8_t*)_payload+%d+1)<<8|((uint32_t)*((uint8_t*)_payload+%d+2))<<16|((uint32_t)*((uint8_t*)_payload+%d+3))<<24)" pprz_type.Pprz.inttype o o o o
|
sprintf "(%s)(*((uint8_t*)_payload+%d)|*((uint8_t*)_payload+%d+1)<<8|((uint32_t)*((uint8_t*)_payload+%d+2))<<16|((uint32_t)*((uint8_t*)_payload+%d+3))<<24)" pprz_type.Pprz.inttype o o o o
|
||||||
| _ -> failwith "unexpected size in Gen_messages.print_get_macros" in
|
| _ -> failwith "unexpected size in Gen_messages.print_get_macros. Possibly since a Telemetry message was defined with a field type of string." in
|
||||||
|
|
||||||
(** To be an array or not to be an array: *)
|
(** To be an array or not to be an array: *)
|
||||||
match _type with
|
match _type with
|
||||||
|
|||||||
Reference in New Issue
Block a user