From fa2f603945bd2853abf9d930fe1b175795a8da17 Mon Sep 17 00:00:00 2001 From: Fabien-B Date: Tue, 3 Jul 2018 10:07:07 +0200 Subject: [PATCH] [datalink] Set Xbee channel (#2288) * [datalink] Adds Xbee channel configuration. * Update pprzlink ref to include Xbee channel configuration. --- sw/ext/pprzlink | 2 +- sw/ground_segment/tmtc/link.ml | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sw/ext/pprzlink b/sw/ext/pprzlink index 0f5869983fc..cbcb37060c0 160000 --- a/sw/ext/pprzlink +++ b/sw/ext/pprzlink @@ -1 +1 @@ -Subproject commit 0f5869983fc13f1485dd048239954207c53109fe +Subproject commit cbcb37060c0c0438a5956b578a728f846a1b3a0d diff --git a/sw/ground_segment/tmtc/link.ml b/sw/ground_segment/tmtc/link.ml index 6f1d9ec90f4..fe1529395be 100644 --- a/sw/ground_segment/tmtc/link.ml +++ b/sw/ground_segment/tmtc/link.ml @@ -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 *) @@ -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" @@ -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 @@ -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 " Default is %s" !baudrate); + "-ch", Arg.String (fun channel_string -> channel := Some (int_of_string channel_string)), " 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 " Available protocols are modem,pprz,pprz2 and xbee. Default is %s" !transport); @@ -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 =