From: Jérémie D. <Ba...@us...> - 2010-02-18 17:38:28
|
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 874a7ccf8dbabec69f1172c987e9213905ab7d45 (commit) from c4abed670c3fe59fe59c4043cc1224cb2b90a33e (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 874a7ccf8dbabec69f1172c987e9213905ab7d45 Author: Jérémie Dimino <je...@di...> Date: Thu Feb 18 18:37:56 2010 +0100 [controller] returns all calibrations at the same time ----------------------------------------------------------------------- Changes: diff --git a/PC_Mainboard/_tags b/PC_Mainboard/_tags index 6d352b3..818fd97 100644 --- a/PC_Mainboard/_tags +++ b/PC_Mainboard/_tags @@ -55,8 +55,6 @@ <tools/forward_dbus.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log, pkg_obus.syntax <tools/forward_dbus.*>: pkg_obus -<tools/flood.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log, pkg_obus.syntax -<tools/flood.*>: pkg_obus # +------------------------------------------------------------------+ # | Tests | diff --git a/PC_Mainboard/clients/controller.ml b/PC_Mainboard/clients/controller.ml index 32791c9..abe4a32 100644 --- a/PC_Mainboard/clients/controller.ml +++ b/PC_Mainboard/clients/controller.ml @@ -217,7 +217,7 @@ let () = (React.S.map (fun state -> state.Engine.mode) engine_state) let logs, set_logs = React.S.create [] -let log line = +let log_line line = let rec truncate n = function | [] -> [] @@ -227,7 +227,18 @@ let log line = else line :: truncate (n + 1) rest in - set_logs (line :: truncate 0 (React.S.value logs)) + set_logs (line :: truncate 1 (React.S.value logs)) +let log_lines lines = + let rec truncate n = function + | [] -> + [] + | line :: rest -> + if n = 1024 then + [] + else + line :: truncate (n + 1) rest + in + set_logs (lines @ truncate (List.length lines) (React.S.value logs)) let history_file_name = Filename.concat (try Unix.getenv "HOME" with _ -> "") ".krobot-controller-history" @@ -268,7 +279,7 @@ let rec loop krobot history = let rec copy_logs ic = lwt line = Lwt_io.read_line ic in - log line; + log_line line; copy_logs ic let redirect_stderr () = @@ -287,7 +298,7 @@ let redirect_stderr () = Lwt_log.render ~buffer ~level ~message:line ~template:"$(date): $(message)"; Buffer.contents buffer) lines in - List.iter log lines; + log_lines lines; return ()) ~close:return () diff --git a/PC_Mainboard/clients/script.ml b/PC_Mainboard/clients/script.ml index 4dc474b..1d147a3 100644 --- a/PC_Mainboard/clients/script.ml +++ b/PC_Mainboard/clients/script.ml @@ -44,7 +44,7 @@ let commands = [ { name = "reset"; args = [("card", Arg_keyword ["interface"; "sensor"; "motor"])] }; { name = "get-calibration"; - args = [("range-finder", Arg_int)] }; + args = [] }; ] let set_of_list l = List.fold_left (fun set x -> TextSet.add x set) TextSet.empty l @@ -152,8 +152,20 @@ let exec krobot line = | "sensor" -> `Sensor | _ -> failwith "Script.exec: invalid card") | "get-calibration" -> - lwt cal = Krobot.get_calibration krobot (arg_int "range-finder" 0) in - Log#notice "calibration: %s" (String.concat " " (List.map string_of_int (Array.to_list cal))); + lwt l = Lwt_list.map_p (Krobot.get_calibration krobot) [0; 1; 2; 3; 4; 5; 6; 7] in + let buffer = Buffer.create 1024 in + let _ = + List.fold_left + (fun i cal -> + Printf.bprintf buffer "calibration[%d]:" i; + for i = 0 to Array.length cal - 1 do + Printf.bprintf buffer " %d" cal.(i) + done; + Buffer.add_char buffer '\n'; + (i + 1)) + 0 l + in + Log#notice "%s" (Buffer.contents buffer); return () | _ -> Log#error "unknown command %S" action; diff --git a/PC_Mainboard/myocamlbuild.ml b/PC_Mainboard/myocamlbuild.ml index a6a42a2..b23d4cf 100644 --- a/PC_Mainboard/myocamlbuild.ml +++ b/PC_Mainboard/myocamlbuild.ml @@ -66,7 +66,6 @@ let targets = List.filter_opt (function (true, target) -> Some target | (false, (* Tools *) (have_lwt_unix && have_obus, "tools/forward_dbus.best"); - (have_lwt_unix && have_obus, "tools/flood.best"); (* Clients *) (have_lwt_unix && have_obus, "clients/info.best"); hooks/post-receive -- krobot |