From e003f52d72936675995f74752f1b32719fe57edb Mon Sep 17 00:00:00 2001 From: Pascal Brisset Date: Wed, 25 May 2005 21:56:15 +0000 Subject: [PATCH] *** empty log message *** --- conf/control_panel.xml | 13 +----------- sw/ground_segment/tmtc/receive.ml | 35 +++++++++++++++++++++++++++---- sw/lib/ocaml/wavecard.ml | 26 +++++++++++++++++++++++ sw/lib/ocaml/wavecard.mli | 26 +++++++++++++++++++++++ 4 files changed, 84 insertions(+), 16 deletions(-) diff --git a/conf/control_panel.xml b/conf/control_panel.xml index e96a630015..fa728334c7 100644 --- a/conf/control_panel.xml +++ b/conf/control_panel.xml @@ -82,23 +82,12 @@ - - - - - - - - - - - - + diff --git a/sw/ground_segment/tmtc/receive.ml b/sw/ground_segment/tmtc/receive.ml index 28b646173b..455daf50f7 100644 --- a/sw/ground_segment/tmtc/receive.ml +++ b/sw/ground_segment/tmtc/receive.ml @@ -253,7 +253,6 @@ let register_aircraft = fun name a -> (** Callback of an identifying message from a soft simulator *) let ident_msg = fun log id name -> if not (Hashtbl.mem aircrafts name) then begin - prerr_endline "ident_msg"; let ac = new_aircraft (Ivy id) in let b = Ivy.bind (fun _ args -> sim_msg log name ac args.(0)) (sprintf "^%s +(.*)" id) in register_aircraft name ac; @@ -288,7 +287,7 @@ let send_config = fun id_ac id_req -> Not_found -> Ivy.send (sprintf "ground UNKNOWN %s" id_req) -let server = fun () -> +let ivy_server = fun () -> ignore (Ivy.bind (fun _ args -> send_aircrafts_msg ()) "^ask AIRCRAFTS"); ignore (Ivy.bind (fun _ args -> send_flight_plan args.(0)) "^ask FLIGHT_PLAN +(.*)"); ignore (Ivy.bind (fun _ args -> send_config args.(0) args.(1)) "^(.*) CONFIG_REQ +(.*)") @@ -307,6 +306,29 @@ let handle_pprz_message = fun log a -> | Some ac_name -> log_and_parse log ac_name a msg values +module Coronis = struct + let send_ack = fun delay fd -> + ignore (GMain.Timeout.add delay (fun _ -> Wavecard.send fd ("ACK", ""); false)) + + let broadcast_msg = fun (msg, data) -> + Ivy.send (sprintf "FROM_WAVECARD %s %s" msg data) + + let connect = fun port -> + try + let fd = Serial.opendev port Serial.B9600 in + (* Listening *) + let cb = fun _ -> + Wavecard.receive ~ack:(fun () -> send_ack 100 fd) broadcast_msg fd; + true in + ignore (GMain.Io.add_watch [`IN] cb (GMain.Io.channel_of_descr fd)); + + (* Sending request from Ivy *) + let send = fun _ a -> Wavecard.send fd (a.(0), a.(1)) in + ignore (Ivy.bind send "TO_WAVECARD +([^ ]+) +([^ ]+)") + with + _ -> failwith "Coronis.connect" +end + let listen_link = fun log xml_link -> match ExtXml.attrib xml_link "protocol" with "pprz/modem" -> @@ -314,6 +336,11 @@ let listen_link = fun log xml_link -> let port = ExtXml.attrib xml_link "port" in let ac = new_aircraft (Modem port) in listen_pprz_modem (handle_pprz_message log ac) port +(*** + | "pprz/coronis" -> + let port = ExtXml.attrib xml_link "port" in + Coronis.connect port +***) | _ -> fprintf stderr "Warning: Ignoring link '%s'\n" (ExtXml.attrib xml_link "name") @@ -331,7 +358,6 @@ let _ = Ivy.init "Paparazzi receive" "READY" (fun _ _ -> ()); Ivy.start !ivy_bus; - (* Opens the log file *) let log = logger () in @@ -344,7 +370,8 @@ let _ = (* Sends periodically alive aircrafts *) ignore (Glib.Timeout.add aircrafts_msg_period (fun () -> send_aircrafts_msg (); true)); - server (); + (* Waits for client requests on the Ivy bus *) + ivy_server (); let loop = Glib.Main.create true in while Glib.Main.is_running loop do ignore (Glib.Main.iteration true) done diff --git a/sw/lib/ocaml/wavecard.ml b/sw/lib/ocaml/wavecard.ml index 2ea9e77a5a..f1b88fd9e0 100644 --- a/sw/lib/ocaml/wavecard.ml +++ b/sw/lib/ocaml/wavecard.ml @@ -1,3 +1,29 @@ +(* + * $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 = string diff --git a/sw/lib/ocaml/wavecard.mli b/sw/lib/ocaml/wavecard.mli index c2f344112a..b84bc92a74 100644 --- a/sw/lib/ocaml/wavecard.mli +++ b/sw/lib/ocaml/wavecard.mli @@ -1,3 +1,29 @@ +(* + * $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 = string type data = string type cmd = cmd_name * data