diff --git a/conf/messages.xml b/conf/messages.xml
index 8c109fbb85..57aaa6c34b 100644
--- a/conf/messages.xml
+++ b/conf/messages.xml
@@ -257,17 +257,18 @@
-
+
-
+
+
@@ -279,6 +280,7 @@
+
@@ -288,6 +290,7 @@
+
@@ -298,6 +301,7 @@
+
diff --git a/sw/ground_segment/cockpit/Makefile b/sw/ground_segment/cockpit/Makefile
index 98607889bf..b562385c95 100644
--- a/sw/ground_segment/cockpit/Makefile
+++ b/sw/ground_segment/cockpit/Makefile
@@ -1,4 +1,4 @@
-OCAMLC=ocamlc -g
+OCAMLC=ocamlc
OCAMLOPT=ocamlopt
INCLUDES=-I +lablgtk2 -I +camlimages -I ../../lib/ocaml
LIBS=glibivy-ocaml.cma lablgtk.cma ci_core.cma ci_png.cma ci_gif.cma ci_jpeg.cma ci_tiff.cma ci_bmp.cma ci_ppm.cma ci_ps.cma lib-pprz.cma lablgnomecanvas.cma xlib-pprz.cma
@@ -9,7 +9,7 @@ all : map2d
map2d : map2d.ml
- $(OCAMLC) -custom $(INCLUDES) $(LIBS) gtkInit.cmo $(CMO) -o /dev/null #to Check
+ $(OCAMLC) -custom $(INCLUDES) $(LIBS) gtkInit.cmo $< -o /dev/null #to Check
cat ../../../pprz_src_test.sh > $@
echo 'lablgtk2 str.cma unix.cma xml-light.cma -I +camlimages glibivy-ocaml.cma ci_core.cma ci_png.cma ci_gif.cma ci_jpeg.cma ci_tiff.cma ci_bmp.cma ci_ppm.cma ci_ps.cma -I $$PAPARAZZI_SRC/sw/lib/ocaml lib-pprz.cma xlib-pprz.cma $$PAPARAZZI_SRC/sw/ground_segment/cockpit/$< $$*' >> $@
chmod a+x $@
diff --git a/sw/ground_segment/cockpit/map2d.ml b/sw/ground_segment/cockpit/map2d.ml
index 3ff248eafd..840c144457 100644
--- a/sw/ground_segment/cockpit/map2d.ml
+++ b/sw/ground_segment/cockpit/map2d.ml
@@ -1,5 +1,32 @@
+(*
+ * $Id$
+ *
+ * Multi aircrafts map display
+ *
+ * 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
open Latlong
+module Ground_Pprz = Pprz.Protocol(struct let name = "ground" end)
type color = string
@@ -72,8 +99,11 @@ let file_of_url = fun url ->
String.sub url 7 (String.length url - 7)
else
let tmp_file = Filename.temp_file "fp" ".xml" in
- Sys.command (sprintf "wget -O %s %s" tmp_file url);
- tmp_file
+ let c = sprintf "wget -O %s %s" tmp_file url in
+ if Sys.command c = 0 then
+ tmp_file
+ else
+ failwith c
let load_mission = fun color geomap url ->
let file = file_of_url url in
@@ -132,24 +162,12 @@ let new_color =
| [] -> failwith "new_color"
-let ivy_request = fun s f ->
- let b = ref (Obj.magic ()) in
- let cb = fun response ->
- Ivy.unbind !b;
- f response in
- let id = sprintf "%s_%d" (Filename.basename Sys.argv.(1)) (Unix.getpid ()) in
- b := Ivy.bind (fun _ args -> cb args.(0)) (sprintf "response %s (.*)" id);
- Ivy.send (sprintf "request %s %s" id s)
-
-
let ask_fp = fun geomap ac ->
- let b = ref (Obj.magic ()) in
- let load_fp = fun file ->
- Ivy.unbind !b;
+ let get_config = fun _sender values ->
+ let file = Pprz.string_assoc "flight_plan" values in
let ac = Hashtbl.find live_aircrafts ac in
ac.fp_group <- Some (load_mission ac.color geomap file) in
- b := Ivy.bind (fun _ args -> load_fp args.(0)) (sprintf "ground FLIGHT_PLAN %s (.*)" ac);
- Ivy.send (sprintf "ask FLIGHT_PLAN %s" ac)
+ Ground_Pprz.message_req "map2d" "CONFIG" ["ac_id", Pprz.String ac] get_config
let show_mission = fun geomap ac on_off ->
@@ -171,6 +189,8 @@ let resize_track = fun ac track ->
let live_aircrafts_msg = fun (geomap:MapCanvas.widget) acs ->
+ let acs = Pprz.string_assoc "ac_list" acs in
+ let acs = Str.split list_separator acs in
List.iter
(fun ac ->
if not (Hashtbl.mem live_aircrafts ac) then begin
@@ -180,21 +200,33 @@ let live_aircrafts_msg = fun (geomap:MapCanvas.widget) acs ->
ignore (fp#connect#toggled (fun () -> show_mission geomap ac fp#active));
let color = new_color () in
let track = new MapTrack.track ~name:ac ~color:color geomap in
- ignore (ac_menu_fact#add_item "Clear Track" ~callback:(fun () -> track#clear)) ;
- ignore (ac_menu_fact#add_item "Resize Track" ~callback:(fun () -> resize_track ac track)) ;
- let b =
- Ivy.bind
- (fun _ args -> aircraft_pos_msg track (fos args.(0)) (fos args.(1))(fos args.(2)))
- (sprintf "%s +FLIGHT_PARAM +[^ ]* +[^ ]* +([0-9\\.]*) +([0-9\\.]*) +[0-9\\.]* +([0-9\\.]*)" ac) in
- let b =
- Ivy.bind
- (fun _ args -> carrot_pos_msg track (fos args.(0)) (fos args.(1)))
- (sprintf "%s +NAV_STATUS +[^ ]* +[^ ]* +[^ ]* +[^ ]* +[^ ]* +([\\-0-9\\.]*) +([\\-0-9\\.]*)" ac) in
+ ignore (ac_menu_fact#add_item "Clear Track" ~callback:(fun () -> track#clear));
+ ignore (ac_menu_fact#add_item "Resize Track" ~callback:(fun () -> resize_track ac track));
Hashtbl.add live_aircrafts ac { track = track; color = color; fp_group = None }
- end
- )
+ end)
acs
-
+
+
+let listen_flight_params = fun () ->
+ let get_fp = fun _sender vs ->
+ let ac_id = Pprz.string_assoc "ac_id" vs in
+ try
+ let ac = Hashtbl.find live_aircrafts ac_id in
+ let a = fun s -> Pprz.float_assoc s vs in
+ aircraft_pos_msg ac.track (a "east") (a "north") (a "heading")
+ with Not_found -> ()
+ in
+ ignore (Ground_Pprz.message_bind "FLIGHT_PARAM" get_fp);
+
+ let get_ns = fun _sender vs ->
+ let ac_id = Pprz.string_assoc "ac_id" vs in
+ try
+ let ac = Hashtbl.find live_aircrafts ac_id in
+ let a = fun s -> Pprz.float_assoc s vs in
+ carrot_pos_msg ac.track (a "target_east") (a "target_north")
+ with Not_found -> ()
+ in
+ ignore (Ground_Pprz.message_bind "NAV_STATUS" get_ns)
let _ =
let ivy_bus = ref "127.255.255.255:2010"
@@ -229,7 +261,9 @@ let _ =
load_map geomap xml_map_file
end;
- Ivy.bind (fun _ args -> live_aircrafts_msg geomap (Str.split list_separator args.(0))) "ground +AIRCRAFTS +(.*)";
+ ignore (Ground_Pprz.message_bind "AIRCRAFTS" (fun _sender vs -> live_aircrafts_msg geomap vs));
+
+ listen_flight_params ();
window#add_accel_group accel_group;
window#show ();
diff --git a/sw/ground_segment/tmtc/receive.ml b/sw/ground_segment/tmtc/receive.ml
index c714f39893..243a7526ec 100644
--- a/sw/ground_segment/tmtc/receive.ml
+++ b/sw/ground_segment/tmtc/receive.ml
@@ -24,15 +24,15 @@
*
*)
+let my_id = "ground"
+
open Printf
module U = Unix
module Tele_Class = struct let name = "telemetry_ap" end
-module Tc_Class = struct let name = "non" end
-module AcInfo = struct let name = "aircraft_info" end
+module Ground = struct let name = "ground" end
module Tele_Pprz = Pprz.Protocol(Tele_Class)
-module Tc_Pprz = Pprz.Protocol(Tc_Class)
-module AcInfo_Pprz = Pprz.Protocol(AcInfo)
+module Ground_Pprz = Pprz.Protocol(Ground)
let (//) = Filename.concat
let logs_path = Env.paparazzi_home // "var" // "logs"
@@ -76,11 +76,10 @@ let aircrafts = Hashtbl.create 3
let aircrafts_msg_period = 5000 (* ms *)
let aircraft_msg_period = 1000 (* ms *)
let traffic_info_period = 2000 (* ms *)
-let send_aircrafts_msg = fun () ->
- let t = U.gettimeofday () in
- let names = String.concat "," (Hashtbl.fold (fun k v r -> k::r) aircrafts []) in
- Ivy.send (sprintf "ground AIRCRAFTS %s" names)
-(* Ivy.send (sprintf "YOUOPIIIII") *)
+let send_aircrafts_msg = fun _asker _values ->
+ assert(_values = []);
+ let names = String.concat "," (Hashtbl.fold (fun k v r -> k::r) aircrafts []) ^ "," in
+ ["ac_list", Pprz.String names]
(* Opens the log file *)
(* FIXME : shoud open also an associated config file *)
@@ -164,7 +163,8 @@ let send_aircraft_msg = fun ac ->
let sof = fun f -> sprintf "%.1f" f in
let a = Hashtbl.find aircrafts ac in
let f = fun x -> Pprz.Float x in
- let values = ["roll", f (Geometry_2d.rad2deg a.roll);
+ let values = ["ac_id", Pprz.String ac;
+ "roll", f (Geometry_2d.rad2deg a.roll);
"pitch", f (Geometry_2d.rad2deg a.pitch);
"east", f a.east;
"north", f a.north;
@@ -172,46 +172,25 @@ let send_aircraft_msg = fun ac ->
"heading", f (Geometry_2d.rad2deg a.course);
"alt", f a.alt;
"climb", f a.climb] in
- let _, fp_msg = AcInfo_Pprz.message_of_name "FLIGHT_PARAM" in
- Ivy.send (sprintf "%s %s" ac (AcInfo_Pprz.string_of_message fp_msg values));
+ Ground_Pprz.message_send my_id "FLIGHT_PARAM" values;
- let values = ["cur_block", Pprz.Int a.cur_block;"cur_stage", Pprz.Int a.cur_stage; "target_east", f (a.nav_ref_east+.a.desired_east); "target_north", f (a.nav_ref_north+.a.desired_north)]
- and _, ns_msg = AcInfo_Pprz.message_of_name "NAV_STATUS" in
- Ivy.send (sprintf "%s %s" ac (AcInfo_Pprz.string_of_message ns_msg values));
+ let values = ["ac_id", Pprz.String ac; "cur_block", Pprz.Int a.cur_block;"cur_stage", Pprz.Int a.cur_stage; "target_east", f (a.nav_ref_east+.a.desired_east); "target_north", f (a.nav_ref_north+.a.desired_north)] in
+ Ground_Pprz.message_send my_id "NAV_STATUS" values;
- let values = ["throttle", f a.throttle;"rpm", f a.rpm;"temp", f a.temp;"bat", f a.bat;"amp", f a.amp;"energy", f a.energy]
- and _, es_msg = AcInfo_Pprz.message_of_name "ENGINE_STATUS" in
- Ivy.send (sprintf "%s %s" ac (AcInfo_Pprz.string_of_message es_msg values));
+ let values = ["ac_id", Pprz.String ac; "throttle", f a.throttle;"rpm", f a.rpm;"temp", f a.temp;"bat", f a.bat;"amp", f a.amp;"energy", f a.energy] in
+ Ground_Pprz.message_send my_id "ENGINE_STATUS" values;
- let values = ["mode", Pprz.Int a.ap_mode; "v_mode", Pprz.Int a.ap_altitude]
- and _, as_msg = AcInfo_Pprz.message_of_name "AP_STATUS" in
- Ivy.send (sprintf "%s %s" ac (AcInfo_Pprz.string_of_message as_msg values))
+ let values = ["ac_id", Pprz.String ac; "mode", Pprz.Int a.ap_mode; "v_mode", Pprz.Int a.ap_altitude] in
+ Ground_Pprz.message_send my_id "AP_STATUS" values
with
Not_found -> prerr_endline ac
-
-let send_traffic_info = fun ac ->
- (* TODO: should send up on the datalink *)
- (* Sending on the Ivy bus for the simulators *)
- let a = Hashtbl.find aircrafts ac in
- let f = fun x -> Pprz.Float x in
- let conf = ExtXml.child conf_xml "aircraft" ~select:(fun x -> ExtXml.attrib x "ac_id" = ac) in
- let values = ["ac_id", Pprz.Int (int_of_string (ExtXml.attrib conf "ac_id"));
- "east", f a.east;
- "north", f a.north;
- "speed", f a.gspeed;
- "heading", f (Geometry_2d.rad2deg a.course);
- "alt", f a.alt;
- "climb", f a.climb] in
- let _, fp_msg = Tc_Pprz.message_of_name "TRAFFIC_INFO" in
- Ivy.send (sprintf "%s %s" ac (Tc_Pprz.string_of_message fp_msg values))
let new_aircraft = fun id ->
{ port = id ; roll = 0.; pitch = 0.; east = 0.; north = 0.; nav_ref_east = 0.; nav_ref_north = 0.; desired_east = 0.; desired_north = 0.; gspeed=0.; course = 0.; alt=0.; climb=0.; cur_block=0; cur_stage=0; throttle = 0.; rpm = 0.; temp = 0.; bat = 0.; amp = 0.; energy = 0.; ap_mode=0; ap_altitude=0; if_calib_mode=0; mcu1_status=0; lls_calib=0 }
let register_aircraft = fun name a ->
Hashtbl.add aircrafts name a;
- ignore (Glib.Timeout.add aircraft_msg_period (fun () -> send_aircraft_msg name; true));
- ignore (Glib.Timeout.add traffic_info_period (fun () -> send_traffic_info name; true))
+ ignore (Glib.Timeout.add aircraft_msg_period (fun () -> send_aircraft_msg name; true))
(** Identifying message from a A/C *)
@@ -220,41 +199,37 @@ let ident_msg = fun log id name ->
let ac = new_aircraft id in
let b = Ivy.bind (fun _ args -> ac_msg log name ac args.(0)) (sprintf "^%s +(.*)" id) in
register_aircraft name ac;
- send_aircrafts_msg ()
+ Ground_Pprz.message_send my_id "NEW_AIRCRAFT" ["ac_id", Pprz.String id]
end
(* Waits for new aircrafts *)
let listen_acs = fun log ->
ignore (Ivy.bind (fun _ args -> ident_msg log args.(0) args.(1)) "^(.*) IDENT +(.*)")
-(* Server on the Ivy bus *)
-let send_flight_plan = fun id ->
- try
- let conf = ExtXml.child conf_xml "aircraft" ~select:(fun x -> ExtXml.attrib x "ac_id" = id) in
- let f = ExtXml.attrib conf "flight_plan" in
- Ivy.send (sprintf "ground FLIGHT_PLAN %s file://%s/conf/%s" id Env.paparazzi_home f)
- with
- Not_found ->
- Ivy.send (sprintf "ground UNKNOWN %s" id)
-
-let send_config = fun id_ac id_req ->
- try
- prerr_endline (sprintf "[%s] [%s]\n" id_ac id_req);
- let conf = ExtXml.child conf_xml "aircraft" ~select:(fun x -> ExtXml.attrib x "ac_id" = id_ac) in
- let fp = sprintf "%s/conf/%s" Env.paparazzi_home (ExtXml.attrib conf "flight_plan") and
- af = sprintf "%s/conf/%s" Env.paparazzi_home (ExtXml.attrib conf "airframe") and
- rc = sprintf "%s/conf/%s" Env.paparazzi_home (ExtXml.attrib conf "radio")in
- let resp = sprintf "%s CONFIG_RES %s %s %s %s" id_ac id_req fp af rc in
- Ivy.send (resp);
- prerr_endline (resp)
- with
- Not_found ->
- Ivy.send (sprintf "ground UNKNOWN %s" id_req)
+let send_config = fun _asker args ->
+ match args with
+ ["ac_id", Pprz.String ac_id] -> begin
+ try
+ let conf = ExtXml.child conf_xml "aircraft" ~select:(fun x -> ExtXml.attrib x "ac_id" = ac_id) in
+ let prefix = fun s -> sprintf "file://%s/conf/%s" Env.paparazzi_home s in
+ let fp = prefix (ExtXml.attrib conf "flight_plan")
+ and af = prefix (ExtXml.attrib conf "airframe")
+ and rc = prefix (ExtXml.attrib conf "radio") in
+ ["ac_id", Pprz.String ac_id;
+ "flight_plan", Pprz.String fp;
+ "airframe", Pprz.String af;
+ "radio", Pprz.String rc]
+ with
+ Not_found ->
+ failwith (sprintf "ground UNKNOWN %s" ac_id)
+ end
+ | _ ->
+ let s = String.concat " " (List.map (fun (a,v) -> a^"="^Pprz.string_of_value v) args) in
+ failwith (sprintf "Error, Receive.send_config: %s" s)
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 +(.*)")
+ ignore (Ground_Pprz.message_answerer my_id "AIRCRAFTS" send_aircrafts_msg);
+ ignore (Ground_Pprz.message_answerer my_id "CONFIG" send_config)
@@ -278,7 +253,12 @@ let _ =
listen_acs log;
(* Sends periodically alive aircrafts *)
- ignore (Glib.Timeout.add aircrafts_msg_period (fun () -> send_aircrafts_msg (); true));
+ let sending = fun () ->
+ let vs = send_aircrafts_msg "event" [] in
+ Ground_Pprz.message_send my_id "AIRCRAFTS" vs;
+ true
+ in
+ ignore (Glib.Timeout.add aircrafts_msg_period sending);
(* Waits for client requests on the Ivy bus *)
ivy_server ();
diff --git a/sw/lib/ocaml/Makefile b/sw/lib/ocaml/Makefile
index 60d987921e..3b5c08c1ee 100644
--- a/sw/lib/ocaml/Makefile
+++ b/sw/lib/ocaml/Makefile
@@ -39,7 +39,7 @@ all : lib-pprz.cma xlib-pprz.cma xml_get.out lib-pprz.cmxa
lib-pprz.cma : $(CMO)
- ocamlmklib -o lib-pprz str.cma xml-light.cma unix.cma $^
+ ocamlmklib -o lib-pprz str.cma unix.cma xml-light.cma ivy-ocaml.cma $^
lib-pprz.cmxa : $(CMX)
ocamlmklib -o lib-pprz $^
diff --git a/sw/lib/ocaml/pprz.ml b/sw/lib/ocaml/pprz.ml
index f431adf5b6..adfcd53d29 100644
--- a/sw/lib/ocaml/pprz.ml
+++ b/sw/lib/ocaml/pprz.ml
@@ -49,6 +49,8 @@ type type_descr = {
value : value
}
+type values = (string * value) list
+
@@ -67,7 +69,8 @@ let types = [
("int8", { format = "%d"; glib_type = "gint8"; size = 1; value= Int 42 });
("int16", { format = "%d"; glib_type = "gint16"; size = 2; value= Int 42 });
("int32", { format = "%ld" ; glib_type = "gint32"; size = 4; value=Int 42 });
- ("float", { format = "%f" ; glib_type = "gfloat"; size = 4; value=Float 4.2 })
+ ("float", { format = "%f" ; glib_type = "gfloat"; size = 4; value=Float 4.2 });
+ ("string", { format = "%s" ; glib_type = "gchar*"; size = max_int; value=String "42" })
]
let int_of_string = fun x ->
@@ -106,6 +109,14 @@ let field_of_xml = fun xml ->
let f = try Xml.attrib xml "format" with _ -> default_format t in
(ExtXml.attrib xml "name", { _type = t; fformat = f })
+let float_assoc = fun (a:string) vs ->
+ match List.assoc a vs with
+ Float x -> x
+ | _ -> invalid_arg "Pprz.float_assoc"
+
+let string_assoc = fun (a:string) (vs:values) -> string_of_value (List.assoc a vs)
+
+
(** Table of msg classes indexed by name. Each class is a table of messages
indexed by ids *)
@@ -237,6 +248,7 @@ module Protocol(Class:CLASS) = struct
(msg_id, values)
with
Not_found -> raise (Unknown_msg_name msg_name)
+ | Invalid_argument "List.map2" -> failwith (sprintf "Pprz.values_of_string: '%s'" s)
end
| [] -> invalid_arg "Pprz.values_of_string"
@@ -248,4 +260,34 @@ module Protocol(Class:CLASS) = struct
try string_of_value (List.assoc field_name values) with
Not_found -> string_of_value (default_value field._type))
msg.fields)
+
+ let message_send = fun sender msg_name values ->
+ let m = snd (message_of_name msg_name) in
+ let s = string_of_message m values in
+ Ivy.send (sprintf "%s %s" sender s)
+
+ let message_bind = fun msg_name cb ->
+ Ivy.bind (fun _ args -> cb args.(0) (snd (values_of_string args.(1)))) (sprintf "^([^ ]*) +(%s.*)" msg_name)
+
+ let message_answerer = fun sender msg_name cb ->
+ let ivy_cb = fun _ args ->
+ let asker = args.(0)
+ and asker_id = args.(1) in
+ let values = cb asker (snd (values_of_string args.(2))) in
+ let m = string_of_message (snd (message_of_name msg_name)) values in
+ Ivy.send (sprintf "%s %s %s" asker_id sender m) in
+ Ivy.bind ivy_cb (sprintf "^([^ ]*) +([^ ]*) +(%s_REQ.*)" msg_name)
+
+ let gen_id = let r = ref 0 in fun () -> incr r; !r
+ let message_req = fun sender msg_name values (f:string -> (string * value) list -> unit) ->
+ let b = ref (Obj.magic ()) in
+ let cb = fun _ args ->
+ Ivy.unbind !b;
+ f args.(0) (snd (values_of_string args.(1))) in
+ let id = sprintf "%d_%d" (Unix.getpid ()) (gen_id ()) in
+ let r = sprintf "^%s ([^ ]*) +(%s.*)" id msg_name in
+ b := Ivy.bind cb r;
+ let msg_name_req = msg_name ^ "_REQ" in
+ let m = sprintf "%s %s %s" sender id (string_of_message (snd (message_of_name msg_name_req)) values) in
+ Ivy.send m
end
diff --git a/sw/lib/ocaml/pprz.mli b/sw/lib/ocaml/pprz.mli
index 62c44896e2..cc002b259a 100644
--- a/sw/lib/ocaml/pprz.mli
+++ b/sw/lib/ocaml/pprz.mli
@@ -43,6 +43,13 @@ type type_descr = {
value : value
}
val types : (string * type_descr) list
+type values = (string * value) list
+
+val string_assoc : string -> values -> string
+(** May raise Not_found *)
+
+val float_assoc : string -> values -> float
+(** May raise Not_found or Invalid_argument *)
exception Unknown_msg_name of string
@@ -51,21 +58,31 @@ module Protocol : functor (Class : CLASS) -> sig
include Serial.PROTOCOL
val message_of_id : message_id -> message
val message_of_name : string -> message_id * message
- val values_of_payload : string -> message_id * (string * value) list
+ val values_of_payload : string -> message_id * values
(** [values_of_bin payload] Parses a raw payload, returns the
message id and the list of (field_name, value) *)
- val values_of_bin : string -> message_id * (string * value) list
+ val values_of_bin : string -> message_id * values
(** [values_of_bin raw_message] Same than previous but [raw_message]
includes header and checksum. *)
- val payload_of_values : message_id -> (string * value) list -> string
+ val payload_of_values : message_id -> values -> string
(** [payload_of_values m vs] Returns a payload *)
- val values_of_string : string -> message_id * (string * value) list
+ val values_of_string : string -> message_id * values
(** May raise [(Unknown_msg_name msg_name)] *)
- val string_of_message : message -> (string * value) list -> string
+ val string_of_message : message -> values -> string
(** [string_of_message msg values] *)
-end
-
+ val message_send : string -> string -> values -> unit
+ (** [message_send sender msg_name values] *)
+
+ val message_bind : string -> (string -> values -> unit) -> Ivy.binding
+ (** [message_bind msg_name callback] *)
+
+ val message_answerer : string -> string -> (string -> values -> values) -> Ivy.binding
+ (** [message_answerer sender msg_name callback] *)
+
+ val message_req : string -> string -> values -> (string -> values -> unit) -> unit
+ (** [message_answerer sender msg_name values receiver] Sends a request on the Ivy bus for the specified message. On reception, [receiver] will be applied on [sender_name] and expected values. *)
+end
diff --git a/sw/simulator/sim.ml b/sw/simulator/sim.ml
index d005d8dd88..7e8b5462bd 100644
--- a/sw/simulator/sim.ml
+++ b/sw/simulator/sim.ml
@@ -150,7 +150,7 @@ module Make(AircraftItl : AIRCRAFT_ITL) = struct
let horizon_distance = 1000. in
try
match !last_gps_state with
- None -> Printf.printf "gps state NONE \n%!";()
+ None -> ()
| Some gps_state ->
let delta_ir =
if !ir_srtm then