mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-07 00:53:41 +08:00
add functions to pprz transport lib
This commit is contained in:
+19
-1
@@ -296,7 +296,25 @@ let rec sprint_value = fun buf i _type v ->
|
||||
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
|
||||
|
||||
@@ -72,7 +72,7 @@ val types : (string * type_descr) list
|
||||
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 int_assoc : string -> values -> int
|
||||
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]. *)
|
||||
|
||||
Reference in New Issue
Block a user