paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [4252] add functions to pprz transport lib


From: Pascal Brisset
Subject: [paparazzi-commits] [4252] add functions to pprz transport lib
Date: Thu, 15 Oct 2009 07:04:49 +0000

Revision: 4252
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=4252
Author:   hecto
Date:     2009-10-15 07:04:49 +0000 (Thu, 15 Oct 2009)
Log Message:
-----------
 add functions to pprz transport lib

Modified Paths:
--------------
    paparazzi3/trunk/sw/lib/ocaml/pprz.ml
    paparazzi3/trunk/sw/lib/ocaml/pprz.mli

Modified: paparazzi3/trunk/sw/lib/ocaml/pprz.ml
===================================================================
--- paparazzi3/trunk/sw/lib/ocaml/pprz.ml       2009-10-15 06:50:05 UTC (rev 
4251)
+++ paparazzi3/trunk/sw/lib/ocaml/pprz.ml       2009-10-15 07:04:49 UTC (rev 
4252)
@@ -296,8 +296,26 @@
       String.blit s 0 buf (i+1) n;
       1 + n
   | (Scalar x|ArrayType x), _ -> failwith (sprintf "Pprz.sprint_value (%s)" x)
+
+
+
+let hex_of_int_array = function
+    Array array ->
+      let n = Array.length array in
+      (* One integer -> 2 chars *)
+      let s = String.create (2*n) in
+      Array.iteri
+       (fun i dec ->
+         let x = int_of_value array.(i) in
+         assert (0 <= x && x <= 0xff);
+         let hex = sprintf "%02x" x in
+         String.blit hex 0 s (2*i) 2)
+       array;
+      s        
+  | value ->
+      failwith (sprintf "Error: expecting array in Pprz.hex_of_int_array, 
found %s" (string_of_value value))
+
   
-  
 
 exception Unknown_msg_name of string * string
 

Modified: paparazzi3/trunk/sw/lib/ocaml/pprz.mli
===================================================================
--- paparazzi3/trunk/sw/lib/ocaml/pprz.mli      2009-10-15 06:50:05 UTC (rev 
4251)
+++ paparazzi3/trunk/sw/lib/ocaml/pprz.mli      2009-10-15 07:04:49 UTC (rev 
4252)
@@ -72,7 +72,7 @@
 type values  = (string * value) list
 
 val assoc : string -> values -> value
-(** Safe assoc taking into accound characters case *)
+(** Safe assoc taking into accound characters case. May raise Failure ... *)
 
 val string_assoc : string -> values -> string
 (** May raise Not_found *)
@@ -82,6 +82,9 @@
 val int32_assoc : string -> values -> Int32.t
 (** May raise Not_found or Invalid_argument *)
 
+val hex_of_int_array : value -> string
+(** Returns the hexadecimal string of an array of integers *)
+
 exception Unknown_msg_name of string * string
 (** [Unknown_msg_name (name, class_name)] Raised if message [name] is not
 found in class [class_name]. *)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]