From: Jérémie D. <Ba...@us...> - 2011-04-18 19:33:00
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 1063889e6c9547426e6f4a8322fef1f4bd8f85f7 (commit) from 89e804e0141a8c908fb78fa549e50f1dc08864dd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1063889e6c9547426e6f4a8322fef1f4bd8f85f7 Author: Jérémie Dimino <je...@di...> Date: Mon Apr 18 20:06:16 2011 +0200 [krobot_message] use C stubs for serializing/deserializing strange structures ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/_oasis b/info/control2011/_oasis index 85e61ae..c14f942 100644 --- a/info/control2011/_oasis +++ b/info/control2011/_oasis @@ -31,9 +31,9 @@ Flag gtk Library krobot FindlibName: krobot - BuildDepends: lwt.unix, lwt.syntax, obus, krobot.interfaces, bitstring, bitstring.syntax + BuildDepends: lwt.unix, lwt.syntax, obus, krobot.interfaces XMETADescription: The [Kro]bot library - XMETARequires: lwt.unix, obus, krobot.interfaces, bitstring + XMETARequires: lwt.unix, obus, krobot.interfaces Path: src/lib Install: true Modules: @@ -43,6 +43,8 @@ Library krobot Krobot_service, Krobot_geom, Krobot_planner + CSources: + krobot_message_stubs.c Library "krobot-can" FindlibName: can diff --git a/info/control2011/_tags b/info/control2011/_tags index f8002fe..650cedb 100644 --- a/info/control2011/_tags +++ b/info/control2011/_tags @@ -2,7 +2,7 @@ <src/interfaces/*.ml>: -syntax_camlp4o # OASIS_START -# DO NOT EDIT (digest: bc62a620a945818c8391362124b031c3) +# DO NOT EDIT (digest: 28c051595fc8936deb8eca602b892268) # Library krobot-interfaces "src/interfaces": include "src/interfaces/krobot-interfaces.cmxs": use_krobot-interfaces @@ -10,12 +10,15 @@ # Library krobot "src/lib": include "src/lib/krobot.cmxs": use_krobot +<src/lib/krobot.{cma,cmxa}>: use_libkrobot <src/lib/*.ml{,i}>: use_krobot-interfaces <src/lib/*.ml{,i}>: pkg_obus <src/lib/*.ml{,i}>: pkg_lwt.unix <src/lib/*.ml{,i}>: pkg_lwt.syntax -<src/lib/*.ml{,i}>: pkg_bitstring.syntax -<src/lib/*.ml{,i}>: pkg_bitstring +"src/lib/krobot_message_stubs.c": use_krobot-interfaces +"src/lib/krobot_message_stubs.c": pkg_obus +"src/lib/krobot_message_stubs.c": pkg_lwt.unix +"src/lib/krobot_message_stubs.c": pkg_lwt.syntax # Library krobot-can "src/can": include "src/can/krobot-can.cmxs": use_krobot-can @@ -25,31 +28,23 @@ <src/can/*.ml{,i}>: pkg_obus <src/can/*.ml{,i}>: pkg_lwt.unix <src/can/*.ml{,i}>: pkg_lwt.syntax -<src/can/*.ml{,i}>: pkg_bitstring.syntax -<src/can/*.ml{,i}>: pkg_bitstring "src/can/can_stubs.c": use_krobot "src/can/can_stubs.c": use_krobot-interfaces "src/can/can_stubs.c": pkg_obus "src/can/can_stubs.c": pkg_lwt.unix "src/can/can_stubs.c": pkg_lwt.syntax -"src/can/can_stubs.c": pkg_bitstring.syntax -"src/can/can_stubs.c": pkg_bitstring # Executable krobot-dump <src/tools/krobot_dump.{native,byte}>: use_krobot <src/tools/krobot_dump.{native,byte}>: use_krobot-interfaces <src/tools/krobot_dump.{native,byte}>: pkg_obus <src/tools/krobot_dump.{native,byte}>: pkg_lwt.unix <src/tools/krobot_dump.{native,byte}>: pkg_lwt.syntax -<src/tools/krobot_dump.{native,byte}>: pkg_bitstring.syntax -<src/tools/krobot_dump.{native,byte}>: pkg_bitstring # Executable krobot-dump-encoders <src/tools/krobot_dump_encoders.{native,byte}>: use_krobot <src/tools/krobot_dump_encoders.{native,byte}>: use_krobot-interfaces <src/tools/krobot_dump_encoders.{native,byte}>: pkg_obus <src/tools/krobot_dump_encoders.{native,byte}>: pkg_lwt.unix <src/tools/krobot_dump_encoders.{native,byte}>: pkg_lwt.syntax -<src/tools/krobot_dump_encoders.{native,byte}>: pkg_bitstring.syntax -<src/tools/krobot_dump_encoders.{native,byte}>: pkg_bitstring # Executable krobot-driver <src/driver/krobot_driver.{native,byte}>: use_krobot-can <src/driver/krobot_driver.{native,byte}>: use_krobot @@ -57,16 +52,12 @@ <src/driver/krobot_driver.{native,byte}>: pkg_obus <src/driver/krobot_driver.{native,byte}>: pkg_lwt.unix <src/driver/krobot_driver.{native,byte}>: pkg_lwt.syntax -<src/driver/krobot_driver.{native,byte}>: pkg_bitstring.syntax -<src/driver/krobot_driver.{native,byte}>: pkg_bitstring <src/driver/*.ml{,i}>: use_krobot-can <src/driver/*.ml{,i}>: use_krobot <src/driver/*.ml{,i}>: use_krobot-interfaces <src/driver/*.ml{,i}>: pkg_obus <src/driver/*.ml{,i}>: pkg_lwt.unix <src/driver/*.ml{,i}>: pkg_lwt.syntax -<src/driver/*.ml{,i}>: pkg_bitstring.syntax -<src/driver/*.ml{,i}>: pkg_bitstring # Executable krobot-viewer <src/tools/krobot_viewer.{native,byte}>: use_krobot <src/tools/krobot_viewer.{native,byte}>: use_krobot-interfaces @@ -76,8 +67,6 @@ <src/tools/krobot_viewer.{native,byte}>: pkg_lwt.glib <src/tools/krobot_viewer.{native,byte}>: pkg_lablgtk2.glade <src/tools/krobot_viewer.{native,byte}>: pkg_cairo.lablgtk2 -<src/tools/krobot_viewer.{native,byte}>: pkg_bitstring.syntax -<src/tools/krobot_viewer.{native,byte}>: pkg_bitstring <src/tools/*.ml{,i}>: pkg_lablgtk2.glade # Executable krobot-hil-simulator <src/tools/krobot_hil_simulator.{native,byte}>: use_krobot @@ -85,8 +74,6 @@ <src/tools/krobot_hil_simulator.{native,byte}>: pkg_obus <src/tools/krobot_hil_simulator.{native,byte}>: pkg_lwt.unix <src/tools/krobot_hil_simulator.{native,byte}>: pkg_lwt.syntax -<src/tools/krobot_hil_simulator.{native,byte}>: pkg_bitstring.syntax -<src/tools/krobot_hil_simulator.{native,byte}>: pkg_bitstring # Executable send-can <examples/send_can.{native,byte}>: use_krobot-can <examples/send_can.{native,byte}>: use_krobot @@ -94,8 +81,6 @@ <examples/send_can.{native,byte}>: pkg_obus <examples/send_can.{native,byte}>: pkg_lwt.unix <examples/send_can.{native,byte}>: pkg_lwt.syntax -<examples/send_can.{native,byte}>: pkg_bitstring.syntax -<examples/send_can.{native,byte}>: pkg_bitstring # Executable krobot-plot-battery <src/tools/krobot_plot_battery.{native,byte}>: use_krobot <src/tools/krobot_plot_battery.{native,byte}>: use_krobot-interfaces @@ -104,39 +89,29 @@ <src/tools/krobot_plot_battery.{native,byte}>: pkg_lwt.syntax <src/tools/krobot_plot_battery.{native,byte}>: pkg_lwt.glib <src/tools/krobot_plot_battery.{native,byte}>: pkg_cairo.lablgtk2 -<src/tools/krobot_plot_battery.{native,byte}>: pkg_bitstring.syntax -<src/tools/krobot_plot_battery.{native,byte}>: pkg_bitstring # Executable krobot-service-planner <src/services/krobot_service_planner.{native,byte}>: use_krobot <src/services/krobot_service_planner.{native,byte}>: use_krobot-interfaces <src/services/krobot_service_planner.{native,byte}>: pkg_obus <src/services/krobot_service_planner.{native,byte}>: pkg_lwt.unix <src/services/krobot_service_planner.{native,byte}>: pkg_lwt.syntax -<src/services/krobot_service_planner.{native,byte}>: pkg_bitstring.syntax -<src/services/krobot_service_planner.{native,byte}>: pkg_bitstring <src/services/*.ml{,i}>: use_krobot <src/services/*.ml{,i}>: use_krobot-interfaces <src/services/*.ml{,i}>: pkg_obus <src/services/*.ml{,i}>: pkg_lwt.unix <src/services/*.ml{,i}>: pkg_lwt.syntax -<src/services/*.ml{,i}>: pkg_bitstring.syntax -<src/services/*.ml{,i}>: pkg_bitstring # Executable krobot-remote <src/tools/krobot_remote.{native,byte}>: use_krobot <src/tools/krobot_remote.{native,byte}>: use_krobot-interfaces <src/tools/krobot_remote.{native,byte}>: pkg_obus <src/tools/krobot_remote.{native,byte}>: pkg_lwt.unix <src/tools/krobot_remote.{native,byte}>: pkg_lwt.syntax -<src/tools/krobot_remote.{native,byte}>: pkg_bitstring.syntax -<src/tools/krobot_remote.{native,byte}>: pkg_bitstring # Executable krobot-replay <src/tools/krobot_replay.{native,byte}>: use_krobot <src/tools/krobot_replay.{native,byte}>: use_krobot-interfaces <src/tools/krobot_replay.{native,byte}>: pkg_obus <src/tools/krobot_replay.{native,byte}>: pkg_lwt.unix <src/tools/krobot_replay.{native,byte}>: pkg_lwt.syntax -<src/tools/krobot_replay.{native,byte}>: pkg_bitstring.syntax -<src/tools/krobot_replay.{native,byte}>: pkg_bitstring # Executable dump-can <examples/dump_can.{native,byte}>: use_krobot-can <examples/dump_can.{native,byte}>: use_krobot @@ -144,32 +119,24 @@ <examples/dump_can.{native,byte}>: pkg_obus <examples/dump_can.{native,byte}>: pkg_lwt.unix <examples/dump_can.{native,byte}>: pkg_lwt.syntax -<examples/dump_can.{native,byte}>: pkg_bitstring.syntax -<examples/dump_can.{native,byte}>: pkg_bitstring <examples/*.ml{,i}>: use_krobot-can <examples/*.ml{,i}>: use_krobot <examples/*.ml{,i}>: use_krobot-interfaces <examples/*.ml{,i}>: pkg_obus <examples/*.ml{,i}>: pkg_lwt.unix <examples/*.ml{,i}>: pkg_lwt.syntax -<examples/*.ml{,i}>: pkg_bitstring.syntax -<examples/*.ml{,i}>: pkg_bitstring # Executable krobot-local <src/tools/krobot_local.{native,byte}>: use_krobot <src/tools/krobot_local.{native,byte}>: use_krobot-interfaces <src/tools/krobot_local.{native,byte}>: pkg_obus <src/tools/krobot_local.{native,byte}>: pkg_lwt.unix <src/tools/krobot_local.{native,byte}>: pkg_lwt.syntax -<src/tools/krobot_local.{native,byte}>: pkg_bitstring.syntax -<src/tools/krobot_local.{native,byte}>: pkg_bitstring # Executable krobot-record <src/tools/krobot_record.{native,byte}>: use_krobot <src/tools/krobot_record.{native,byte}>: use_krobot-interfaces <src/tools/krobot_record.{native,byte}>: pkg_obus <src/tools/krobot_record.{native,byte}>: pkg_lwt.unix <src/tools/krobot_record.{native,byte}>: pkg_lwt.syntax -<src/tools/krobot_record.{native,byte}>: pkg_bitstring.syntax -<src/tools/krobot_record.{native,byte}>: pkg_bitstring # Executable krobot-plot <src/tools/krobot_plot.{native,byte}>: use_krobot <src/tools/krobot_plot.{native,byte}>: use_krobot-interfaces @@ -178,8 +145,6 @@ <src/tools/krobot_plot.{native,byte}>: pkg_lwt.syntax <src/tools/krobot_plot.{native,byte}>: pkg_lwt.glib <src/tools/krobot_plot.{native,byte}>: pkg_cairo.lablgtk2 -<src/tools/krobot_plot.{native,byte}>: pkg_bitstring.syntax -<src/tools/krobot_plot.{native,byte}>: pkg_bitstring <src/tools/*.ml{,i}>: pkg_lwt.glib <src/tools/*.ml{,i}>: pkg_cairo.lablgtk2 # Executable krobot-simulator @@ -188,13 +153,9 @@ <src/tools/krobot_simulator.{native,byte}>: pkg_obus <src/tools/krobot_simulator.{native,byte}>: pkg_lwt.unix <src/tools/krobot_simulator.{native,byte}>: pkg_lwt.syntax -<src/tools/krobot_simulator.{native,byte}>: pkg_bitstring.syntax -<src/tools/krobot_simulator.{native,byte}>: pkg_bitstring <src/tools/*.ml{,i}>: use_krobot <src/tools/*.ml{,i}>: use_krobot-interfaces <src/tools/*.ml{,i}>: pkg_obus <src/tools/*.ml{,i}>: pkg_lwt.unix <src/tools/*.ml{,i}>: pkg_lwt.syntax -<src/tools/*.ml{,i}>: pkg_bitstring.syntax -<src/tools/*.ml{,i}>: pkg_bitstring # OASIS_STOP diff --git a/info/control2011/myocamlbuild.ml b/info/control2011/myocamlbuild.ml index 08cc900..20d8e84 100644 --- a/info/control2011/myocamlbuild.ml +++ b/info/control2011/myocamlbuild.ml @@ -1,5 +1,5 @@ (* OASIS_START *) -(* DO NOT EDIT (digest: 570b31c8f48685aca9662d28e560f425) *) +(* DO NOT EDIT (digest: 1ca7268f789f49955feedef89f6b4ca9) *) module OASISGettext = struct # 21 "/home/dim/sources/oasis/src/oasis/OASISGettext.ml" @@ -457,7 +457,7 @@ let package_default = ("src/lib/krobot", ["src/lib"]); ("src/can/krobot-can", ["src/can"]) ]; - lib_c = [("krobot-can", "src/can", [])]; + lib_c = [("krobot", "src/lib", []); ("krobot-can", "src/can", [])]; flags = []; } ;; diff --git a/info/control2011/setup.ml b/info/control2011/setup.ml index 8d91fa9..5b8befa 100644 --- a/info/control2011/setup.ml +++ b/info/control2011/setup.ml @@ -1,7 +1,7 @@ (* setup.ml generated for the first time by OASIS v0.2.0~alpha1 *) (* OASIS_START *) -(* DO NOT EDIT (digest: 0d24f30592bfc03631b0c362d4d27577) *) +(* DO NOT EDIT (digest: b04695e11f7527ee760b637f6ae5beb4) *) (* Regenerated by OASIS v0.2.0 Visit http://oasis.forge.ocamlcore.org for more information and @@ -5106,12 +5106,10 @@ let setup_t = FindlibPackage ("lwt.unix", None); FindlibPackage ("lwt.syntax", None); FindlibPackage ("obus", None); - InternalLibrary "krobot-interfaces"; - FindlibPackage ("bitstring", None); - FindlibPackage ("bitstring.syntax", None) + InternalLibrary "krobot-interfaces" ]; bs_build_tools = [ExternalTool "ocamlbuild"]; - bs_c_sources = []; + bs_c_sources = ["krobot_message_stubs.c"]; bs_data_files = []; bs_ccopt = [(OASISExpr.EBool true, [])]; bs_cclib = [(OASISExpr.EBool true, [])]; diff --git a/info/control2011/src/lib/META b/info/control2011/src/lib/META index 47df438..8cab18d 100644 --- a/info/control2011/src/lib/META +++ b/info/control2011/src/lib/META @@ -1,8 +1,8 @@ # OASIS_START -# DO NOT EDIT (digest: 060bacace64817181263e75a71185b59) +# DO NOT EDIT (digest: 6d4fe02a501933ad8464e70af7fcf3b1) version = "1.0" description = "The [Kro]bot library" -requires = "lwt.unix obus krobot.interfaces bitstring" +requires = "lwt.unix obus krobot.interfaces" archive(byte) = "krobot.cma" archive(native) = "krobot.cmxa" exists_if = "krobot.cma" diff --git a/info/control2011/src/lib/krobot_message.ml b/info/control2011/src/lib/krobot_message.ml index 7640a41..c9da849 100644 --- a/info/control2011/src/lib/krobot_message.ml +++ b/info/control2011/src/lib/krobot_message.ml @@ -126,6 +126,8 @@ let to_string = function let pi = 4. *. atan 1. +external encode_bezier : int * int * int * int * int * int -> string = "krobot_message_encode_bezier" + let encode = function | Encoder_position_direction_3_4(pos3, dir3, pos4, dir4) -> let data = String.create 6 in @@ -213,22 +215,12 @@ let encode = function and d2 = int_of_float (d2 *. 100.) and theta = int_of_float (theta *. 1000.) land 0b1111111111111; and v = int_of_float (v *. 1000.) in - let data = Bitstring.string_of_bitstring - (BITSTRING{ - x : 12 : littleendian, unsigned; - y : 12 : littleendian, unsigned; - d1 : 8 : littleendian, unsigned; - d2 : 8 : littleendian, unsigned; - theta : 13 : littleendian, unsigned; - v : 11 : littleendian, unsigned - }) - in frame ~identifier:206 ~kind:Data ~remote:false ~format:F29bits - ~data + ~data:(encode_bezier (x, y, d1, d2, theta, v)) | Set_odometry(x, y, theta) -> let data = String.create 6 in put_sint16 data 0 (truncate (x *. 1000.)); @@ -324,102 +316,98 @@ let () = | _ -> None) +external decode_bezier : string -> int * int * int * int * int * int = "krobot_message_decode_bezier" + let decode frame = try - if frame.remote then - match frame.identifier with - | 103 -> - Req_motor_status - | _ -> - Unknown frame - else - match frame.identifier with - | 100 -> - Encoder_position_direction_3_4 - (get_uint16 frame.data 0, - (if get_uint8 frame.data 4 = 0 then Forward else Backward), - get_uint16 frame.data 2, - (if get_uint8 frame.data 5 = 0 then Forward else Backward)) - | 101 -> - Encoder_position_speed_3 - (get_float32 frame.data 0, - get_float32 frame.data 4) - | 102 -> - Encoder_position_speed_4 - (get_float32 frame.data 0, - get_float32 frame.data 4) - | 103 -> - let x = get_uint8 frame.data 0 in - Motor_status(x land 1 <> 0, - x land 2 <> 0, - x land 4 <> 0, - x land 8 <> 0) - | 104 -> - Odometry - (float (get_sint16 frame.data 0) /. 1000., - float (get_sint16 frame.data 2) /. 1000., - float (get_sint16 frame.data 4) /. 10000.) - | 201 -> - Motor_move - (float (get_sint32 frame.data 0) /. 1000., - float (get_uint16 frame.data 4) /. 1000., - float (get_uint16 frame.data 6) /. 1000.) - | 202 -> - Motor_turn - (float (get_sint32 frame.data 0) /. 10000., - float (get_uint16 frame.data 4) /. 1000., - float (get_uint16 frame.data 6) /. 1000.) - | 203 -> - Set_odometry - (float (get_sint16 frame.data 0) /. 1000., - float (get_sint16 frame.data 2) /. 1000., - float (get_sint16 frame.data 4) /. 10000.) - | 204 -> - Motor_stop - | 205 -> - Set_controller_mode - (get_uint8 frame.data 0 <> 0) - | 206 -> - (bitmatch Bitstring.bitstring_of_string frame.data with - | { x : 12 : littleendian; - y : 12 : littleendian; - d1 : 8 : littleendian; - d2 : 8 : littleendian; - theta : 13 : littleendian; - v : 11 : littleendian } -> - Motor_bezier(float x /. 1000., - float y /. 1000., - float d1 /. 100., - float d2 /. 100., - (if theta >= 4096 then - float (theta - 8192) /. 1000. - else - float theta /. 1000.), - float v /. 1000.)) - | 301 -> - Beacon_position - (float (get_uint16 frame.data 0) /. 10000., - float (get_uint16 frame.data 2) /. 1000., - float (get_uint16 frame.data 4) /. 10000.) - | 302 -> - Beacon_lowlevel_position - (float (get_uint16 frame.data 0) /. 10000., - float (get_uint16 frame.data 2) /. 100000., - get_uint32 frame.data 4) - | 401 -> - Battery1_voltages - (float (get_uint16 frame.data 0) /. 10000., - float (get_uint16 frame.data 2) /. 10000., - float (get_uint16 frame.data 4) /. 10000., - float (get_uint16 frame.data 6) /. 10000.) - | 402 -> - Battery2_voltages - (float (get_uint16 frame.data 0) /. 10000., - float (get_uint16 frame.data 2) /. 10000., - float (get_uint16 frame.data 4) /. 10000., - float (get_uint16 frame.data 6) /. 10000.) - | _ -> - Unknown frame + if frame.remote then + match frame.identifier with + | 103 -> + Req_motor_status + | _ -> + Unknown frame + else + match frame.identifier with + | 100 -> + Encoder_position_direction_3_4 + (get_uint16 frame.data 0, + (if get_uint8 frame.data 4 = 0 then Forward else Backward), + get_uint16 frame.data 2, + (if get_uint8 frame.data 5 = 0 then Forward else Backward)) + | 101 -> + Encoder_position_speed_3 + (get_float32 frame.data 0, + get_float32 frame.data 4) + | 102 -> + Encoder_position_speed_4 + (get_float32 frame.data 0, + get_float32 frame.data 4) + | 103 -> + let x = get_uint8 frame.data 0 in + Motor_status(x land 1 <> 0, + x land 2 <> 0, + x land 4 <> 0, + x land 8 <> 0) + | 104 -> + Odometry + (float (get_sint16 frame.data 0) /. 1000., + float (get_sint16 frame.data 2) /. 1000., + float (get_sint16 frame.data 4) /. 10000.) + | 201 -> + Motor_move + (float (get_sint32 frame.data 0) /. 1000., + float (get_uint16 frame.data 4) /. 1000., + float (get_uint16 frame.data 6) /. 1000.) + | 202 -> + Motor_turn + (float (get_sint32 frame.data 0) /. 10000., + float (get_uint16 frame.data 4) /. 1000., + float (get_uint16 frame.data 6) /. 1000.) + | 203 -> + Set_odometry + (float (get_sint16 frame.data 0) /. 1000., + float (get_sint16 frame.data 2) /. 1000., + float (get_sint16 frame.data 4) /. 10000.) + | 204 -> + Motor_stop + | 205 -> + Set_controller_mode + (get_uint8 frame.data 0 <> 0) + | 206 -> + let x, y, d1, d2, theta, v = decode_bezier frame.data in + Motor_bezier(float x /. 1000., + float y /. 1000., + float d1 /. 100., + float d2 /. 100., + (if theta >= 4096 then + float (theta - 8192) /. 1000. + else + float theta /. 1000.), + float v /. 1000.) + | 301 -> + Beacon_position + (float (get_uint16 frame.data 0) /. 10000., + float (get_uint16 frame.data 2) /. 1000., + float (get_uint16 frame.data 4) /. 10000.) + | 302 -> + Beacon_lowlevel_position + (float (get_uint16 frame.data 0) /. 10000., + float (get_uint16 frame.data 2) /. 100000., + get_uint32 frame.data 4) + | 401 -> + Battery1_voltages + (float (get_uint16 frame.data 0) /. 10000., + float (get_uint16 frame.data 2) /. 10000., + float (get_uint16 frame.data 4) /. 10000., + float (get_uint16 frame.data 6) /. 10000.) + | 402 -> + Battery2_voltages + (float (get_uint16 frame.data 0) /. 10000., + float (get_uint16 frame.data 2) /. 10000., + float (get_uint16 frame.data 4) /. 10000., + float (get_uint16 frame.data 6) /. 10000.) + | _ -> + Unknown frame with Invalid_argument _ -> raise (Invalid_frame frame) diff --git a/info/control2011/src/lib/krobot_message_stubs.c b/info/control2011/src/lib/krobot_message_stubs.c new file mode 100644 index 0000000..0550aa1 --- /dev/null +++ b/info/control2011/src/lib/krobot_message_stubs.c @@ -0,0 +1,51 @@ +/* + * krobot_message_stubs.c + * ---------------------- + * Copyright : (c) 2011, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + */ + +#include <caml/mlvalues.h> +#include <caml/memory.h> +#include <caml/alloc.h> + +static struct bezier_message { + unsigned int x : 12; + unsigned int y : 12; + unsigned int d1 : 8; + unsigned int d2 : 8; + int theta : 13; + unsigned int v : 11; +}; + +CAMLprim value krobot_message_encode_bezier(value params) +{ + CAMLparam1(params); + CAMLlocal1(str); + str = caml_alloc_string(8); + struct bezier_message *msg = (struct bezier_message*)String_val(str); + msg->x = Int_val(Field(params, 0)); + msg->y = Int_val(Field(params, 1)); + msg->d1 = Int_val(Field(params, 2)); + msg->d2 = Int_val(Field(params, 3)); + msg->theta = Int_val(Field(params, 4)); + msg->v = Int_val(Field(params, 5)); + CAMLreturn(str); +} + +CAMLprim value krobot_message_decode_bezier(value str) +{ + CAMLparam1(str); + CAMLlocal1(res); + struct bezier_message *msg = (struct bezier_message*)String_val(str); + res = caml_alloc_tuple(6); + Field(res, 0) = Val_int(msg->x); + Field(res, 1) = Val_int(msg->y); + Field(res, 2) = Val_int(msg->d1); + Field(res, 3) = Val_int(msg->d2); + Field(res, 4) = Val_int(msg->theta); + Field(res, 5) = Val_int(msg->v); + CAMLreturn(res); +} hooks/post-receive -- krobot |