Skip to content

Commit

Permalink
[ocaml] separate string_of_chars function for printing strings in con…
Browse files Browse the repository at this point in the history
…sole
  • Loading branch information
flixr committed Nov 6, 2014
1 parent 3bfe7db commit e848f7c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sw/ground_segment/cockpit/live.ml
Expand Up @@ -1386,7 +1386,7 @@ let listen_info_msg = fun a ->
let get_msg = fun a _sender vs ->
let ac = find_ac _sender in
let msg_array = Pprz.assoc "msg" vs in
log_and_say a ac.ac_name (Pprz.string_of_value msg_array) in
log_and_say a ac.ac_name (Pprz.string_of_chars msg_array) in
tele_bind "INFO_MSG" (get_msg a)

let listen_tcas = fun a ->
Expand Down
11 changes: 10 additions & 1 deletion sw/lib/ocaml/pprz.ml
Expand Up @@ -162,7 +162,16 @@ let rec string_of_value = function
| Int64 x -> Int64.to_string x
| Char c -> String.make 1 c
| String s -> s
| Array a -> let vl = Array.to_list (Array.map string_of_value a) in
| Array a -> "|"^(String.concat separator (Array.to_list (Array.map string_of_value a)))^"|"

let rec string_of_chars = function
Int x -> string_of_int x
| Float x -> string_of_float x
| Int32 x -> Int32.to_string x
| Int64 x -> Int64.to_string x
| Char c -> String.make 1 c
| String s -> s
| Array a -> let vl = Array.to_list (Array.map string_of_chars a) in
match a.(0) with
Char x -> String.concat "" vl
| _ -> "|"^(String.concat separator vl)^"|"
Expand Down
1 change: 1 addition & 0 deletions sw/lib/ocaml/pprz.mli
Expand Up @@ -63,6 +63,7 @@ val is_fixed_array_type : string -> bool

val size_of_field : field -> int
val string_of_value : value -> string
val string_of_chars : value -> string
val formatted_string_of_value : 'a -> value -> string
val int_of_value : value -> int (* May raise Invalid_argument *)
type type_descr = {
Expand Down

0 comments on commit e848f7c

Please sign in to comment.