Skip to content

Commit

Permalink
[datalink] Set Xbee channel (paparazzi#2288)
Browse files Browse the repository at this point in the history
* [datalink] Adds Xbee channel configuration.
* Update pprzlink ref to include Xbee channel configuration.
  • Loading branch information
Fabien-B authored and gautierhattenberger committed Jul 3, 2018
1 parent 6317591 commit fa2f603
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sw/ext/pprzlink
9 changes: 7 additions & 2 deletions sw/ground_segment/tmtc/link.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let transport_of_string = function


type ground_device = {
fd : Unix.file_descr; transport : transport ; baud_rate : int
fd : Unix.file_descr; transport : transport ; baud_rate : int ; channel : int option
}

(* We assume here a single modem is used *)
Expand Down Expand Up @@ -223,6 +223,9 @@ module XB = struct (** XBee module *)
let o = Unix.out_channel_of_descr device.fd in
Debug.trace 'x' "config xbee";
fprintf o "%s%!" (Xbee_transport.at_set_my !my_addr);
match device.channel with
None -> ()
| Some ch -> fprintf o "%s%!" (Xbee_transport.at_set_channel ch);
fprintf o "%s%!" Xbee_transport.at_api_enable;
fprintf o "%s%!" Xbee_transport.at_exit;
Debug.trace 'x' "end init xbee"
Expand Down Expand Up @@ -427,6 +430,7 @@ let () =
let ivy_bus = ref Defivybus.default_ivy_bus
and port = ref "/dev/ttyUSB0"
and baudrate = ref "9600"
and channel = ref None
and hw_flow_control = ref false
and transport = ref "pprz"
and uplink = ref true
Expand All @@ -440,6 +444,7 @@ let () =
"-noac_info", Arg.Clear ac_info, (sprintf "Disables AC traffic info (uplink).");
"-nouplink", Arg.Clear uplink, (sprintf "Disables the uplink (from the ground to the aircraft).");
"-s", Arg.Set_string baudrate, (sprintf "<baudrate> Default is %s" !baudrate);
"-ch", Arg.String (fun channel_string -> channel := Some (int_of_string channel_string)), "<channel> Default does not change configuration.";
"-hfc", Arg.Set hw_flow_control, "Enable UART hardware flow control (CTS/RTS)";
"-local_timestamp", Arg.Unit (fun () -> add_timestamp := Some (Unix.gettimeofday ())), "Add local timestamp to messages sent over ivy";
"-transport", Arg.Set_string transport, (sprintf "<transport> Available protocols are modem,pprz,pprz2 and xbee. Default is %s" !transport);
Expand Down Expand Up @@ -491,7 +496,7 @@ let () =

(* Create the device object *)
let baudrate = int_of_string !baudrate in
let device = { fd=fd; transport=transport; baud_rate=baudrate } in
let device = { fd=fd; transport=transport; baud_rate=baudrate; channel= !channel } in

(* The function to be called when data is available *)
let read_fd =
Expand Down

0 comments on commit fa2f603

Please sign in to comment.