[fix][ocaml] uint32 are actually stored in Int64

and converting md5sum to hex was really a bad idea (since server was not
aware of this change)
This commit is contained in:
Gautier Hattenberger
2015-03-20 18:15:50 +01:00
parent ed5223e588
commit 999029b5df
7 changed files with 19 additions and 18 deletions
+1 -1
View File
@@ -11,7 +11,7 @@
<message name="ALIVE" id="2">
<description>alive/heartbeat message containing the MD5sum of the aircraft configuration</description>
<field name="md5sum" type="uint8[]" format="%x"/>
<field name="md5sum" type="uint8[]"/>
</message>
<message name="PONG" id="3">
+2 -2
View File
@@ -141,7 +141,7 @@ type aircraft = {
airframe : Xml.xml;
mutable pos : Latlong.geographic;
mutable unix_time : float;
mutable itow : int32; (* ms *)
mutable itow : int64; (* ms *)
mutable roll : float;
mutable pitch : float;
mutable heading : float; (* rad, CW 0=N *)
@@ -201,7 +201,7 @@ let new_aircraft = fun id name fp airframe ->
let svsinfo_init = Array.init gps_nb_channels (fun _ -> svinfo_init ()) in
{ vehicle_type = UnknownVehicleType; id = id; name = name; flight_plan = fp; airframe = airframe;
pos = { Latlong.posn_lat = 0.; posn_long = 0. };
unix_time = 0.; itow = Int32.of_int 0;
unix_time = 0.; itow = Int64.of_int 0;
roll = 0.; pitch = 0.;
gspeed=0.; airspeed= -1.; course = 0.; heading = 0.; alt=0.; climb=0.; agl = 0.;
nav_ref = None; d_hmsl = 0.; ground_alt = 0.;
+1 -1
View File
@@ -93,7 +93,7 @@ type aircraft = {
airframe : Xml.xml;
mutable pos : Latlong.geographic;
mutable unix_time : float;
mutable itow : int32;
mutable itow : int64;
mutable roll : float;
mutable pitch : float;
mutable heading : float; (* rad *)
+2 -2
View File
@@ -110,7 +110,7 @@ let log_and_parse = fun ac_name (a:Aircraft.aircraft) msg values ->
utm_zone = ivalue "utm_zone" } in
a.pos <- LL.of_utm WGS84 p;
a.unix_time <- LL.unix_time_of_tow (truncate (fvalue "itow" /. 1000.));
a.itow <- Int32.of_float (fvalue "itow");
a.itow <- Int64.of_float (fvalue "itow");
a.gspeed <- fvalue "speed" /. 100.;
a.course <- norm_course ((Deg>>Rad)(fvalue "course" /. 10.));
if !heading_from_course then
@@ -125,7 +125,7 @@ let log_and_parse = fun ac_name (a:Aircraft.aircraft) msg values ->
let geo = make_geo_deg (float lat /. 1e7) (float lon /. 1e7) in
a.pos <- geo;
a.unix_time <- LL.unix_time_of_tow (truncate (fvalue "itow" /. 1000.));
a.itow <- Int32.of_float (fvalue "itow");
a.itow <- Int64.of_float (fvalue "itow");
a.gspeed <- fvalue "speed" /. 100.;
a.course <- norm_course ((Deg>>Rad)(fvalue "course" /. 10.));
if !heading_from_course then
+1 -1
View File
@@ -179,7 +179,7 @@ let log_and_parse = fun ac_name (a:Aircraft.aircraft) msg values ->
Wind.update ac_name a.gspeed a.course*)
| "GPS_INT" ->
a.unix_time <- LL.unix_time_of_tow (truncate (fvalue "tow" /. 1000.));
a.itow <- Int32.of_float (fvalue "tow");
a.itow <- Int64.of_float (fvalue "tow");
a.gps_Pacc <- ivalue "pacc"
| "ROTORCRAFT_STATUS" ->
a.vehicle_type <- Rotorcraft;
+9 -9
View File
@@ -311,11 +311,11 @@ let send_telemetry_status = fun a ->
[ "ac_id", Pprz.String id;
"link_id", Pprz.String link_id;
"time_since_last_msg", Pprz.Float (U.gettimeofday () -. a.last_msg_date); (* don't use rx_lost_time from LINK_REPORT so it also works in simulation *)
"rx_bytes", Pprz.Int32 (Int32.of_int link_status.rx_bytes);
"rx_msgs", Pprz.Int32 (Int32.of_int link_status.rx_msgs);
"rx_bytes", Pprz.Int64 (Int64.of_int link_status.rx_bytes);
"rx_msgs", Pprz.Int64 (Int64.of_int link_status.rx_msgs);
"rx_bytes_rate", Pprz.Float link_status.rx_bytes_rate;
"tx_msgs", Pprz.Int32 (Int32.of_int link_status.tx_msgs);
"uplink_lost_time", Pprz.Int32 (Int32.of_int datalink_status.uplink_lost_time);
"tx_msgs", Pprz.Int64 (Int64.of_int link_status.tx_msgs);
"uplink_lost_time", Pprz.Int64 (Int64.of_int datalink_status.uplink_lost_time);
"uplink_msgs", Pprz.Int datalink_status.uplink_msgs;
"downlink_msgs", Pprz.Int datalink_status.downlink_msgs;
"downlink_rate", Pprz.Int datalink_status.downlink_rate;
@@ -367,7 +367,7 @@ let send_aircraft_msg = fun ac ->
"lat", f ((Rad>>Deg)wgs84.posn_lat);
"long", f ((Rad>>Deg) wgs84.posn_long);
"unix_time", f a.unix_time;
"itow", Pprz.Int32 a.itow;
"itow", Pprz.Int64 a.itow;
"speed", f a.gspeed;
"airspeed", f a.airspeed; (* negative value is sent if no airspeed available *)
"course", f (Geometry_2d.rad2deg a.course);
@@ -388,7 +388,7 @@ let send_aircraft_msg = fun ac ->
"alt", cm_of_m a.alt;
"speed", cm_of_m a.gspeed;
"climb", cm_of_m a.climb;
"itow", Pprz.Int32 a.itow] in
"itow", Pprz.Int64 a.itow] in
Dl_Pprz.message_send my_id "ACINFO" ac_info;
end;
@@ -401,8 +401,8 @@ let send_aircraft_msg = fun ac ->
let values = ["ac_id", Pprz.String ac;
"cur_block", Pprz.Int a.cur_block;
"cur_stage", Pprz.Int a.cur_stage;
"stage_time", Pprz.Int32 (Int32.of_int a.stage_time);
"block_time", Pprz.Int32 (Int32.of_int a.block_time);
"stage_time", Pprz.Int64 (Int64.of_int a.stage_time);
"block_time", Pprz.Int64 (Int64.of_int a.block_time);
"target_lat", f ((Rad>>Deg)a.desired_pos.posn_lat);
"target_long", f ((Rad>>Deg)a.desired_pos.posn_long);
"target_alt", Pprz.Float a.desired_altitude;
@@ -432,7 +432,7 @@ let send_aircraft_msg = fun ac ->
let state_filter_mode = get_indexed_value state_filter_modes a.state_filter_mode
and kill_mode = if a.kill_mode then "ON" else "OFF" in
let values = ["ac_id", Pprz.String ac;
"flight_time", Pprz.Int32 (Int32.of_int a.flight_time);
"flight_time", Pprz.Int64 (Int64.of_int a.flight_time);
"ap_mode", Pprz.String ap_mode;
"gaz_mode", Pprz.String gaz_mode;
"lat_mode", Pprz.String lat_mode;
+3 -2
View File
@@ -91,7 +91,7 @@ external sprint_int8 : string -> int -> int -> unit = "c_sprint_int8"
let types = [
("uint8", { format = "%u"; glib_type = "guint8"; inttype = "uint8_t"; size = 1; value=Int 42 });
("uint16", { format = "%u"; glib_type = "guint16"; inttype = "uint16_t"; size = 2; value=Int 42 });
("uint32", { format = "%lu" ; glib_type = "guint32"; inttype = "uint32_t"; size = 4; value=Int 42 });
("uint32", { format = "%Lu" ; glib_type = "guint32"; inttype = "uint32_t"; size = 4; value=Int 42 }); (* uint32 should be lu, but doesn't fit into Int32 so Int64 (Lu) is used *)
("uint64", { format = "%Lu" ; glib_type = "guint64"; inttype = "uint64_t"; size = 8; value=Int 42 });
("int8", { format = "%d"; glib_type = "gint8"; inttype = "int8_t"; size = 1; value= Int 42 });
("int16", { format = "%d"; glib_type = "gint16"; inttype = "int16_t"; size = 2; value= Int 42 });
@@ -137,7 +137,8 @@ let length_of_fixed_array_type = fun s ->
let int_of_string = fun x ->
try int_of_string x with
_ -> failwith (sprintf "Pprz.int_of_string: %s" x)
_ -> try int_of_string ("0x"^x) with (* try hex format in case *)
_ -> failwith (sprintf "Pprz.int_of_string: %s" x)
let rec value = fun t v ->
match t with