mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-30 11:37:06 +08:00
wavecard support removed
This commit is contained in:
@@ -112,3 +112,4 @@ settings.cmo : INCLUDES += -I ../cockpit
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include .depend
|
||||
endif
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
(*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2004 CENA/ENAC, Pascal Brisset, Antoine Drouin
|
||||
* Copyright (C) 2004-2007 ENAC, Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
open Latlong
|
||||
open Printf
|
||||
module W = Wavecard
|
||||
module Tm_Pprz = Pprz.Messages(struct let name = "telemetry" end)
|
||||
module Ground_Pprz = Pprz.Messages(struct let name = "ground" end)
|
||||
module Dl_Pprz = Pprz.Messages(struct let name = "datalink" end)
|
||||
@@ -33,7 +32,6 @@ module PprzTransport = Serial.Transport(Pprz.Transport)
|
||||
type transport =
|
||||
Modem
|
||||
| Pprz
|
||||
| Wavecard
|
||||
| XBee
|
||||
|
||||
type ground_device = {
|
||||
@@ -41,8 +39,7 @@ type ground_device = {
|
||||
}
|
||||
|
||||
type airborne_device =
|
||||
WavecardDevice of W.addr
|
||||
| XBeeDevice
|
||||
XBeeDevice
|
||||
| Uart (** For HITL for example *)
|
||||
|
||||
let my_id = 0
|
||||
@@ -53,8 +50,7 @@ let conf = Env.paparazzi_home // "conf"
|
||||
|
||||
let airborne_device = fun device addr ->
|
||||
match device with
|
||||
"WAVECARD" -> WavecardDevice (W.addr_of_string addr)
|
||||
| "XBEE" -> XBeeDevice
|
||||
"XBEE" -> XBeeDevice
|
||||
| "PPRZ" | "AEROCOMM" -> Uart
|
||||
| _ -> failwith (sprintf "Link: unknown datalink: %s" device)
|
||||
|
||||
@@ -149,8 +145,7 @@ let airborne_device = fun ac_id airframes device ->
|
||||
let ac_device = try Some (List.assoc ac_id airframes) with Not_found -> None in
|
||||
match ac_device, device with
|
||||
(None, Pprz) | (Some Uart, Pprz) -> Uart
|
||||
| (Some (WavecardDevice _ as ac_device), Wavecard) |
|
||||
(Some (XBeeDevice as ac_device), XBee) ->
|
||||
| (Some (XBeeDevice as ac_device), XBee) ->
|
||||
ac_device
|
||||
| _ -> raise NotSendingToThis
|
||||
|
||||
@@ -172,125 +167,6 @@ let use_tele_message = fun ?raw_data_size payload ->
|
||||
|
||||
type priority = Null | Low | Normal | High
|
||||
|
||||
(******** Wavecard ******************************************************)
|
||||
module Wc = struct
|
||||
type status = Ready | Busy
|
||||
|
||||
let buffer_size = 5
|
||||
let null_buffer_entry = (Null, Unix.stdout, (W.ACK, ""))
|
||||
let priority_of = fun (p, _, _) -> p
|
||||
let buffer = (ref Ready, Array.create buffer_size null_buffer_entry)
|
||||
let timer = ref None
|
||||
let remove_timer = fun () ->
|
||||
match !timer with
|
||||
None -> ()
|
||||
| Some t -> GMain.Timeout.remove t
|
||||
|
||||
let shift_buffer = fun b ->
|
||||
for i = 0 to buffer_size - 2 do (** A circular buf would be better *)
|
||||
b.(i) <- b.(i+1)
|
||||
done;
|
||||
b.(buffer_size-1) <- null_buffer_entry
|
||||
|
||||
let rec repeat_send = fun fd cmd n ->
|
||||
W.send fd cmd;
|
||||
timer := Some (GMain.Timeout.add 300 (fun _ -> Debug.trace 'b' (sprintf "Retry %d" n); repeat_send fd cmd (n+1); false))
|
||||
|
||||
let rec flush = fun () ->
|
||||
let status, b = buffer in
|
||||
if !status = Ready then
|
||||
let (priority, fd, cmd) = b.(0) in
|
||||
if priority <> Null then begin
|
||||
shift_buffer b;
|
||||
status := Busy;
|
||||
repeat_send fd cmd 0
|
||||
end
|
||||
|
||||
let buffer_ready = fun () ->
|
||||
remove_timer ();
|
||||
let (status, b) = buffer in
|
||||
shift_buffer b;
|
||||
status := Ready;
|
||||
flush ()
|
||||
|
||||
|
||||
let send_buffered = fun fd cmd priority ->
|
||||
let _status, b = buffer in
|
||||
(** Set the message in the right place in the buffer *)
|
||||
let rec loop = fun i ->
|
||||
if i < buffer_size then
|
||||
if priority_of b.(i) >= priority
|
||||
then loop (i+1)
|
||||
else begin
|
||||
for j = i + 1 to buffer_size - 1 do (** Shift *)
|
||||
b.(j) <- b.(j-1)
|
||||
done;
|
||||
Debug.trace 'b' (sprintf "Set in %d" i);
|
||||
b.(i) <- (priority, fd, cmd)
|
||||
end
|
||||
else
|
||||
Debug.trace 'b' "Buffer full" in
|
||||
loop 0;
|
||||
flush ()
|
||||
|
||||
let send = fun fd addr payload priority ->
|
||||
let data = W.addressed addr (Serial.string_of_payload payload) in
|
||||
send_buffered fd (W.REQ_SEND_MESSAGE, data) priority
|
||||
|
||||
let ack_delay = 10 (* ms *)
|
||||
let send_ack = fun fd () ->
|
||||
Debug.trace 'w' (sprintf "%.2f send ACK" (Unix.gettimeofday ()));
|
||||
ignore (GMain.Timeout.add ack_delay (fun _ -> W.send fd (W.ACK, ""); false))
|
||||
let use_message = fun (com, data) ->
|
||||
match com with
|
||||
W.RECEIVED_FRAME ->
|
||||
use_tele_message (Serial.payload_of_string data)
|
||||
| W.RES_SEND_FRAME ->
|
||||
Debug.trace 'b' "RES_SEND_FRAME";
|
||||
ignore (GMain.Timeout.add 100 (fun _ -> buffer_ready (); false))
|
||||
|
||||
| W.RES_READ_REMOTE_RSSI ->
|
||||
Tm_Pprz.message_send "link" "WC_RSSI" ["raw_level", Pprz.Int (Char.code data.[0])];
|
||||
Debug.call 'w' (fun f -> fprintf f "%.2f wv remote RSSI %d\n" (Unix.gettimeofday ()) (Char.code data.[0]));
|
||||
ignore (GMain.Timeout.add 100 (fun _ -> buffer_ready (); false))
|
||||
| W.RES_READ_RADIO_PARAM ->
|
||||
Ivy.send (sprintf "WC_ADDR %s" data);
|
||||
Debug.call 'w' (fun f -> fprintf f "wv local addr : %s\n" (Debug.xprint data));
|
||||
| W.ACK ->
|
||||
Debug.trace 'w' (sprintf "%.2f wv ACK" (Unix.gettimeofday ()))
|
||||
| _ ->
|
||||
Debug.call 'w' (fun f -> fprintf f "wv receiving: %02x %s\n" (W.code_of_cmd com) (Debug.xprint data));
|
||||
()
|
||||
|
||||
let rssi_period = 5000 (** ms *)
|
||||
let req_rssi = fun device addr ->
|
||||
let data = W.addressed addr "" in
|
||||
send_buffered device.fd (W.REQ_READ_REMOTE_RSSI, data) Low
|
||||
|
||||
let init = fun device rssi_id ->
|
||||
(** Set the wavecard in short wakeup mode *)
|
||||
let data = String.create 2 in
|
||||
data.[0] <- Char.chr (W.code_of_config_param W.WAKEUP_TYPE);
|
||||
data.[1] <- Char.chr (W.code_of_wakeup_type W.SHORT_WAKEUP);
|
||||
(*** data.[0] <- Char.chr (W.code_of_config_param W.AWAKENING_PERIOD);
|
||||
data.[1] <- Char.chr 10; ***)
|
||||
W.send device.fd (W.REQ_WRITE_RADIO_PARAM,data);
|
||||
|
||||
(* request own address *)
|
||||
let s = String.make 1 (char_of_int 5) in
|
||||
ignore (GMain.Timeout.add 1500 (fun _ -> W.send device.fd (W.REQ_READ_RADIO_PARAM, s); false));
|
||||
|
||||
(** Ask for rssi if required *)
|
||||
if rssi_id >= 0 then begin
|
||||
match airborne_device rssi_id airframes device.transport with
|
||||
WavecardDevice addr ->
|
||||
ignore (GMain.Timeout.add rssi_period (fun _ -> req_rssi device addr; true))
|
||||
| _ -> failwith (sprintf "Rssi not supported by A/C '%d'" rssi_id)
|
||||
end
|
||||
|
||||
end (** Wc module *)
|
||||
|
||||
|
||||
module Aerocomm = struct
|
||||
let set_command_mode = fun fd ->
|
||||
Serial.set_dtr fd true
|
||||
@@ -405,9 +281,6 @@ let send = fun ac_id device ac_device payload priority ->
|
||||
let buf = Pprz.Transport.packet payload in
|
||||
Printf.fprintf o "%s" buf; flush o;
|
||||
Debug.call 'l' (fun f -> fprintf f "mm sending: %s\n" (Debug.xprint buf));
|
||||
| WavecardDevice addr ->
|
||||
Wc.send device.fd addr payload priority
|
||||
|
||||
| XBeeDevice ->
|
||||
XB.send ac_id device payload
|
||||
|
||||
@@ -565,8 +438,6 @@ let parse_of_transport device = function
|
||||
| Modem ->
|
||||
let module ModemTransport = Serial.Transport(Modem.Protocol) in
|
||||
ModemTransport.parse PprzModem.use_message
|
||||
| Wavecard ->
|
||||
fun buf -> Wavecard.parse buf ~ack:(Wc.send_ack device.fd) (Wc.use_message)
|
||||
| XBee ->
|
||||
let module XbeeTransport = Serial.Transport (Xbee.Protocol) in
|
||||
XbeeTransport.parse (XB.use_message device)
|
||||
@@ -585,10 +456,10 @@ let _ =
|
||||
let options =
|
||||
[ "-b", Arg.Set_string ivy_bus, (sprintf "<ivy bus> Default is %s" !ivy_bus);
|
||||
"-d", Arg.Set_string port, (sprintf "<port> Default is %s" !port);
|
||||
"-rssi", Arg.Set_int rssi_id, (sprintf "<ac_id> Periodically requests rssi level from the distant wavecard");
|
||||
"-rssi", Arg.Set_int rssi_id, (sprintf "<ac_id> Periodically requests rssi level from the distant modem");
|
||||
"-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);
|
||||
"-transport", Arg.Set_string transport, (sprintf "<transport> Available protocols are modem,pprz,wavecard and xbee. Default is %s" !transport);
|
||||
"-transport", Arg.Set_string transport, (sprintf "<transport> Available protocols are modem,pprz and xbee. Default is %s" !transport);
|
||||
"-uplink", Arg.Set uplink, (sprintf "Deprecated (now default)");
|
||||
"-nouplink", Arg.Clear uplink, (sprintf "Disables the uplink (from the ground to the aircraft).");
|
||||
"-dtr", Arg.Set aerocomm, "Set serial DTR to false (deprecated)";
|
||||
@@ -608,7 +479,6 @@ let _ =
|
||||
match !transport with
|
||||
"modem" -> Modem
|
||||
| "pprz" -> Pprz
|
||||
| "wavecard" -> Wavecard
|
||||
| "xbee" -> XBee
|
||||
| x -> invalid_arg (sprintf "transport_of_string: %s" x)
|
||||
in
|
||||
@@ -666,8 +536,6 @@ let _ =
|
||||
Modem ->
|
||||
(** Sending periodically modem and downlink status messages *)
|
||||
ignore (Glib.Timeout.add PprzModem.msg_period (fun () -> PprzModem.send_msg (); true))
|
||||
| Wavecard ->
|
||||
Wc.init device !rssi_id
|
||||
| XBee ->
|
||||
XB.init device
|
||||
| _ -> ()
|
||||
|
||||
@@ -28,7 +28,7 @@ OCAMLC=ocamlc
|
||||
OCAMLOPT=ocamlopt
|
||||
|
||||
|
||||
SRC = debug.ml env.ml serial.ml ocaml_tools.ml extXml.ml xml2h.ml latlong.ml srtm.ml http.ml gm.ml iGN.ml wavecard.ml geometry_2d.ml geometry_3d.ml cserial.o convert.o ubx.ml pprz.ml xbee.ml
|
||||
SRC = debug.ml env.ml serial.ml ocaml_tools.ml extXml.ml xml2h.ml latlong.ml srtm.ml http.ml gm.ml iGN.ml geometry_2d.ml geometry_3d.ml cserial.o convert.o ubx.ml pprz.ml xbee.ml
|
||||
CMO = $(SRC:.ml=.cmo)
|
||||
CMX = $(SRC:.ml=.cmx)
|
||||
|
||||
|
||||
@@ -1,228 +0,0 @@
|
||||
(*
|
||||
* $Id$
|
||||
*
|
||||
* Coronis wavecard handling
|
||||
*
|
||||
* Copyright (C) 2004 CENA/ENAC, Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*)
|
||||
|
||||
open Printf
|
||||
|
||||
type cmd_name =
|
||||
ACK
|
||||
| NAK
|
||||
| ERROR
|
||||
| REQ_WRITE_RADIO_PARAM
|
||||
| RES_WRITE_RADIO_PARAM
|
||||
| REQ_READ_RADIO_PARAM
|
||||
| RES_READ_RADIO_PARAM
|
||||
| REQ_SELECT_CHANNEL
|
||||
| RES_SELECT_CHANNEL
|
||||
| REQ_READ_CHANNEL
|
||||
| RES_READ_CHANNEL
|
||||
| REQ_SELECT_PHYCONFIG
|
||||
| RES_SELECT_PHYCONFIG
|
||||
| REQ_READ_PHYCONFIG
|
||||
| RES_READ_PHYCONFIG
|
||||
| REQ_READ_REMOTE_RSSI
|
||||
| RES_READ_REMOTE_RSSI
|
||||
| REQ_READ_LOCAL_RSSI
|
||||
| RES_READ_LOCAL_RSSI
|
||||
| REQ_FIRMWARE_VERSION
|
||||
| RES_FIRMWARE_VERSION
|
||||
| MODE_TEST
|
||||
| REQ_SEND_FRAME
|
||||
| RES_SEND_FRAME
|
||||
| REQ_SEND_MESSAGE
|
||||
| REQ_SEND_POLLING
|
||||
| REQ_SEND_BROADCAST
|
||||
| RECEIVED_FRAME
|
||||
| RECEPTION_ERROR
|
||||
| RECEIVED_FRAME_POLLING
|
||||
| RECEIVED_FRAME_BROADCAST
|
||||
| RECEIVED_MULTIFRAME
|
||||
| REQ_SEND_SERVICE
|
||||
| RES_SEND_SERVICE
|
||||
| SERVICE_RESPONSE
|
||||
|
||||
|
||||
type data = string
|
||||
|
||||
type cmd = cmd_name * string
|
||||
|
||||
let cmd_names = [
|
||||
0x06, ACK;
|
||||
0x15, NAK;
|
||||
0x00, ERROR;
|
||||
0x40, REQ_WRITE_RADIO_PARAM;
|
||||
0x41, RES_WRITE_RADIO_PARAM;
|
||||
0x50, REQ_READ_RADIO_PARAM;
|
||||
0x51, RES_READ_RADIO_PARAM;
|
||||
0x60, REQ_SELECT_CHANNEL;
|
||||
0x61, RES_SELECT_CHANNEL;
|
||||
0x62, REQ_READ_CHANNEL;
|
||||
0x63, RES_READ_CHANNEL;
|
||||
0x64, REQ_SELECT_PHYCONFIG;
|
||||
0x65, RES_SELECT_PHYCONFIG;
|
||||
0x66, REQ_READ_PHYCONFIG;
|
||||
0x67, RES_READ_PHYCONFIG;
|
||||
0x68, REQ_READ_REMOTE_RSSI;
|
||||
0x69, RES_READ_REMOTE_RSSI;
|
||||
0x6A, REQ_READ_LOCAL_RSSI;
|
||||
0x6B, RES_READ_LOCAL_RSSI;
|
||||
0xA0, REQ_FIRMWARE_VERSION;
|
||||
0xA1, RES_FIRMWARE_VERSION;
|
||||
0xB0, MODE_TEST;
|
||||
0x20, REQ_SEND_FRAME;
|
||||
0x21, RES_SEND_FRAME;
|
||||
0x22, REQ_SEND_MESSAGE;
|
||||
0x26, REQ_SEND_POLLING;
|
||||
0x28, REQ_SEND_BROADCAST;
|
||||
0x30, RECEIVED_FRAME;
|
||||
0x31, RECEPTION_ERROR;
|
||||
0x32, RECEIVED_FRAME_POLLING;
|
||||
0x34, RECEIVED_FRAME_BROADCAST;
|
||||
0x36, RECEIVED_MULTIFRAME;
|
||||
0x80, REQ_SEND_SERVICE;
|
||||
0x81, RES_SEND_SERVICE;
|
||||
0x82, SERVICE_RESPONSE]
|
||||
|
||||
let rec cossa = fun x l ->
|
||||
match l with
|
||||
[] -> raise Not_found
|
||||
| (v, k)::xs -> if k = x then v else cossa x xs
|
||||
|
||||
let cmd_of_code = fun x -> try List.assoc x cmd_names with Not_found -> failwith (sprintf "Unknown command: %2x" x)
|
||||
let code_of_cmd = fun x -> cossa x cmd_names
|
||||
|
||||
|
||||
type config_param =
|
||||
AWAKENING_PERIOD
|
||||
| WAKEUP_TYPE
|
||||
| WAKEUP_LENGTH
|
||||
|
||||
let code_of_config_param = fun x -> Obj.magic x
|
||||
|
||||
type wakeup_type =
|
||||
LONG_WAKEUP
|
||||
| SHORT_WAKEUP
|
||||
|
||||
let code_of_wakeup_type = fun x -> Obj.magic x
|
||||
|
||||
let sync = Char.chr 0xff
|
||||
let stx = Char.chr 0x02
|
||||
let etx = Char.chr 0x03
|
||||
|
||||
let length = fun buf -> Char.code buf.[2]
|
||||
let total_length = fun buf -> length buf + 3
|
||||
|
||||
let payload = fun buf ->
|
||||
let l = length buf in
|
||||
let data = String.sub buf 4 (l-4) in
|
||||
(cmd_of_code (Char.code buf.[3]), data)
|
||||
|
||||
let (^=) r x = r := !r lxor x
|
||||
|
||||
let compute_checksum =
|
||||
let poly = 0x8408 in
|
||||
fun buf ->
|
||||
let lg = length buf - 2
|
||||
and crc = ref 0 in
|
||||
for j = 0 to lg - 1 do
|
||||
crc ^= Char.code buf.[j+2];
|
||||
for i = 0 to 7 do
|
||||
let carry = !crc land 0x01 = 1 in
|
||||
crc := !crc lsr 1;
|
||||
if carry then
|
||||
crc ^= poly
|
||||
done
|
||||
done;
|
||||
!crc
|
||||
|
||||
let checksum = fun buf ->
|
||||
let crc = compute_checksum buf
|
||||
and l = length buf in
|
||||
true || (crc land 0xff = Char.code buf.[l] && crc lsr 8 = Char.code buf.[l+1])
|
||||
|
||||
|
||||
|
||||
|
||||
let parse = fun buf ?ack f ->
|
||||
let n = String.length buf in
|
||||
Debug.call 'w' (fun f -> fprintf f "wv input: "; for i = 0 to String.length buf - 1 do fprintf f "%x " (Char.code buf.[i]) done; fprintf f "\n");
|
||||
if n < 3 || n < total_length buf then begin
|
||||
0 (* Not enough chars to read *)
|
||||
end else if buf.[0] <> sync then
|
||||
1
|
||||
else if buf.[1] <> stx || not (checksum buf) then begin
|
||||
2
|
||||
end else begin
|
||||
f (payload buf);
|
||||
begin
|
||||
match ack with
|
||||
Some ack when cmd_of_code (Char.code buf.[3]) <> ACK -> ack ()
|
||||
| _ -> ()
|
||||
end;
|
||||
total_length buf
|
||||
end
|
||||
|
||||
|
||||
let receive = fun ?ack f ->
|
||||
match Serial.input (fun b -> parse b ?ack f) with
|
||||
Serial.Closure f -> f
|
||||
|
||||
let send = fun fd (cmd, data) ->
|
||||
let l = String.length data + 4 in
|
||||
if l >= 256 then
|
||||
invalid_arg "Wavecard.send";
|
||||
let buf = String.create (l+3) in
|
||||
buf.[0] <- sync;
|
||||
buf.[1] <- stx;
|
||||
buf.[2] <- Char.chr l;
|
||||
buf.[3] <- Char.chr (code_of_cmd cmd);
|
||||
for i = 4 to l - 1 do
|
||||
buf.[i] <- data.[i-4]
|
||||
done;
|
||||
let crc = compute_checksum buf in
|
||||
buf.[l] <- Char.chr (crc land 0xff);
|
||||
buf.[l+1] <- Char.chr (crc lsr 8);
|
||||
buf.[l+2] <- etx;
|
||||
let o = Unix.out_channel_of_descr fd in
|
||||
Printf.fprintf o "%s" buf;
|
||||
Debug.call 'w' (fun f -> fprintf f "wv sending: "; for i = 0 to String.length buf - 1 do fprintf f "%x " (Char.code buf.[i]) done; fprintf f "\n");
|
||||
flush o
|
||||
|
||||
type addr = Int64.t
|
||||
|
||||
let addr_length = 6
|
||||
|
||||
let addr_of_string = Int64.of_string
|
||||
let string_of_addr = Int64.to_string
|
||||
|
||||
let addressed = fun addr data ->
|
||||
let s = String.create addr_length in
|
||||
for i = 0 to addr_length - 1 do
|
||||
s.[addr_length-i-1] <- Char.chr (Int64.to_int (Int64.shift_right addr (8*i)) land 0xff)
|
||||
done;
|
||||
s^data
|
||||
|
||||
let send_addressed = fun fd (cmd, addr, data) ->
|
||||
send fd (cmd, addressed addr data)
|
||||
@@ -1,109 +0,0 @@
|
||||
(*
|
||||
* $Id$
|
||||
*
|
||||
* Coronis wavecard handling
|
||||
*
|
||||
* Copyright (C) 2004 CENA/ENAC, Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
type cmd_name =
|
||||
ACK
|
||||
| NAK
|
||||
| ERROR
|
||||
| REQ_WRITE_RADIO_PARAM
|
||||
| RES_WRITE_RADIO_PARAM
|
||||
| REQ_READ_RADIO_PARAM
|
||||
| RES_READ_RADIO_PARAM
|
||||
| REQ_SELECT_CHANNEL
|
||||
| RES_SELECT_CHANNEL
|
||||
| REQ_READ_CHANNEL
|
||||
| RES_READ_CHANNEL
|
||||
| REQ_SELECT_PHYCONFIG
|
||||
| RES_SELECT_PHYCONFIG
|
||||
| REQ_READ_PHYCONFIG
|
||||
| RES_READ_PHYCONFIG
|
||||
| REQ_READ_REMOTE_RSSI
|
||||
| RES_READ_REMOTE_RSSI
|
||||
| REQ_READ_LOCAL_RSSI
|
||||
| RES_READ_LOCAL_RSSI
|
||||
| REQ_FIRMWARE_VERSION
|
||||
| RES_FIRMWARE_VERSION
|
||||
| MODE_TEST
|
||||
| REQ_SEND_FRAME
|
||||
| RES_SEND_FRAME
|
||||
| REQ_SEND_MESSAGE
|
||||
| REQ_SEND_POLLING
|
||||
| REQ_SEND_BROADCAST
|
||||
| RECEIVED_FRAME
|
||||
| RECEPTION_ERROR
|
||||
| RECEIVED_FRAME_POLLING
|
||||
| RECEIVED_FRAME_BROADCAST
|
||||
| RECEIVED_MULTIFRAME
|
||||
| REQ_SEND_SERVICE
|
||||
| RES_SEND_SERVICE
|
||||
| SERVICE_RESPONSE
|
||||
(** available commands *)
|
||||
|
||||
val code_of_cmd : cmd_name -> int
|
||||
(** Code of command *)
|
||||
|
||||
type config_param =
|
||||
AWAKENING_PERIOD
|
||||
| WAKEUP_TYPE
|
||||
| WAKEUP_LENGTH
|
||||
|
||||
val code_of_config_param : config_param -> int
|
||||
|
||||
type wakeup_type =
|
||||
LONG_WAKEUP
|
||||
| SHORT_WAKEUP
|
||||
|
||||
val code_of_wakeup_type : wakeup_type -> int
|
||||
|
||||
type data = string
|
||||
type cmd = cmd_name * data
|
||||
(** A command is composed of a command name and some untyped data *)
|
||||
|
||||
type addr
|
||||
val string_of_addr : addr -> string
|
||||
val addr_of_string : string -> addr
|
||||
(** [addr_of_string address] where [address] is a 64 bits number, for example
|
||||
[0x011804c0012d] *)
|
||||
|
||||
val send : Unix.file_descr -> cmd -> unit
|
||||
(** Send a command on the channel connected to the serial port of the wavecard *)
|
||||
|
||||
val addressed : addr -> data -> data
|
||||
val send_addressed : Unix.file_descr -> (cmd_name*addr*data) -> unit
|
||||
(** [send_addressed fd (cmd, a, data)] Sends [cmd] with data obtained by
|
||||
concatenation of codinf of [a] and [data] *)
|
||||
|
||||
val parse : string -> ?ack:(unit -> unit) -> (cmd_name * string -> 'a) -> int
|
||||
(** [parse buffer ?acknowdledger callback] *)
|
||||
|
||||
val receive : ?ack:(unit -> unit) -> (cmd -> 'a) -> (Unix.file_descr -> unit)
|
||||
(** [receive ?acknowledger callbkack] Returns a listener for wavecard messages *)
|
||||
|
||||
|
||||
val compute_checksum : string -> int
|
||||
(** [compute_checksum buf] Computes the checksum of a complete message buffer,
|
||||
including the header of the message *)
|
||||
Reference in New Issue
Block a user