From: Jérémie D. <Ba...@us...> - 2010-02-19 10:37:43
|
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 63fb5ee679acec91c2b3916b2a465e93bbbb4a2b (commit) from f8de486ed428692bf71920a2343a51fe066bce60 (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 63fb5ee679acec91c2b3916b2a465e93bbbb4a2b Author: Jérémie Dimino <je...@di...> Date: Fri Feb 19 11:36:50 2010 +0100 update logging instructions ----------------------------------------------------------------------- Changes: diff --git a/PC_Mainboard/clients/controller.ml b/PC_Mainboard/clients/controller.ml index 25728ec..5b940f3 100644 --- a/PC_Mainboard/clients/controller.ml +++ b/PC_Mainboard/clients/controller.ml @@ -9,6 +9,8 @@ (* Prints status continuously *) +module Log = Lwt_log.Make(struct let section = "controller" end) + open Lwt open Lwt_term open Lwt_read_line @@ -259,7 +261,7 @@ let rec loop krobot history = else begin let history = Lwt_read_line.add_entry line history in set_engine_state (Engine.init history); - lwt () = Log#notice "%s" line in + lwt () = Log.notice line in ignore (Script.exec krobot line); loop krobot history end @@ -304,7 +306,7 @@ let redirect_stderr () = () lwt () = - lwt () = Log#notice "connecting to the krobot bus..." in + lwt () = Log.notice "connecting to the krobot bus..." in lwt krobot = Krobot.create () in lwt () = save_state () in lwt () = hide_cursor () in diff --git a/PC_Mainboard/clients/init_position.ml b/PC_Mainboard/clients/init_position.ml index 4683c51..94073a3 100644 --- a/PC_Mainboard/clients/init_position.ml +++ b/PC_Mainboard/clients/init_position.ml @@ -9,34 +9,35 @@ (* Put the robot into its initial state *) +module Log = Lwt_log.Make(struct let section = "" end) + open Lwt let move_backward_slowly krobot = - lwt () = Log#notice "moving backward" in + lwt () = Log.notice "moving backward" in Krobot.move krobot ~dist:(-1000) ~speed:100 ~acc:100 >>= function | `OK -> - lwt () = Log#error "where am i ???" in + lwt () = Log.error "where am i ???" in exit 1 | `Stopped -> - lwt () = Log#notice "backward colisiton dectected" in - return () + Log.notice "backward colisiton dectected" lwt () = lwt krobot = Krobot.create () in lwt () = move_backward_slowly krobot in - lwt () = Log#notice "going to initial position on first axis" in + lwt () = Log.notice "going to initial position on first axis" in lwt _ = Krobot.move krobot ~dist:Config.initial_position ~speed:400 ~acc:800 in - lwt () = Log#notice "turning" in + lwt () = Log.notice "turning" in lwt _ = Krobot.turn krobot ~angle:(-90) ~speed:400 ~acc:800 in lwt () = move_backward_slowly krobot in - lwt () = Log#notice "going to initial position on second axis" in + lwt () = Log.notice "going to initial position on second axis" in lwt _ = Krobot.move krobot ~dist:Config.initial_position ~speed:400 ~acc:800 in - lwt () = Log#notice "turning" in + lwt () = Log.notice "turning" in lwt _ = Krobot.turn krobot ~angle:45 ~speed:400 ~acc:800 in return () diff --git a/PC_Mainboard/clients/joy_control.ml b/PC_Mainboard/clients/joy_control.ml index 4510e0f..3d7d355 100644 --- a/PC_Mainboard/clients/joy_control.ml +++ b/PC_Mainboard/clients/joy_control.ml @@ -9,6 +9,8 @@ (* Control the robot with a joystick *) +module Log = Lwt_log.Make(struct let section = "" end) + open Lwt open Sdljoystick open Sdlevent @@ -121,7 +123,7 @@ let try_call action f = try_lwt f () with Failure msg -> - lwt () = Log#error "action %s failed with: %s" action msg in + lwt () = Log.error_f "action %s failed with: %s" action msg in return () let rec set_speed action krobot motor speed abort_waiter = @@ -210,6 +212,6 @@ let () = Unix.close fd_w; Lwt_main.run begin lwt krobot = Krobot.create () in - lwt() = Log#notice "ready to process event" in + lwt() = Log.notice "ready to process event" in parent_loop krobot (Lwt_io.of_unix_fd ~mode:Lwt_io.input fd_r) end diff --git a/PC_Mainboard/clients/script.ml b/PC_Mainboard/clients/script.ml index 11d89d3..9c3f558 100644 --- a/PC_Mainboard/clients/script.ml +++ b/PC_Mainboard/clients/script.ml @@ -7,6 +7,8 @@ * This file is a part of [kro]bot. *) +module Log = Lwt_log.Make(struct let section = "script" end) + open Lwt module TextSet = Set.Make(Text) @@ -110,9 +112,9 @@ let motor_of_string = function let move thread = thread >>= function | `OK -> - Log#notice "done" + Log.notice "done" | `Stopped -> - Log#notice "stopped" + Log.notice "stopped" let exec krobot line = try_lwt @@ -169,7 +171,7 @@ let exec krobot line = (i + 1)) 0 l in - Log#notice "%s" (Buffer.contents buffer) + Log.notice (Buffer.contents buffer) | "calibration-start" -> Krobot.calibration_start krobot (arg_int "range-finder" 0) (match arg_string "skip-meas" "false" with @@ -181,11 +183,11 @@ let exec krobot line = | "calibration-stop" -> Krobot.calibration_stop krobot | _ -> - Log#error "unknown command %S" action + Log.error_f "unknown command %S" action with | Script_lexer.Parse_failure msg -> - Log#error "parse failure: %s" msg + Log.error_f "parse failure: %s" msg | Failure msg -> - Log#error "command failed: %s" msg + Log.error_f "command failed: %s" msg | exn -> - Log#exn exn "command failed with" + Log.exn exn "command failed with" diff --git a/PC_Mainboard/driver/card.ml b/PC_Mainboard/driver/card.ml index b93e429..7ffe0b7 100644 --- a/PC_Mainboard/driver/card.ml +++ b/PC_Mainboard/driver/card.ml @@ -7,6 +7,8 @@ * This file is a part of [kro]bot. *) +module Log = Lwt_log.Make(struct let section = "card" end) + open Lwt (* +-----------------------------------------------------------------+ @@ -167,13 +169,13 @@ let rec dispatch card = return (`Error exn) end >>= function | `Error exn -> - lwt () = Log#exn exn "stop dispatching on %s card" card.wrapper.name in + lwt () = Log.exn_f exn "stop dispatching on %s card" card.wrapper.name in lwt _ = abort card.wrapper exn in return () | `OK len -> if len <> 64 then begin let msg = Printf.sprintf "read on %s card returned %d instead of 64" card.wrapper.name len in - lwt () = Log#error "%s" msg in + lwt () = Log.error msg in lwt _ = abort card.wrapper (Card_crashed msg) in return () end else begin @@ -185,7 +187,7 @@ let rec dispatch card = card.serial_pool <- card.serial_pool @ [msg.host_serial]; Lwt.wakeup wakener msg.data | None -> - LogI#warning "response dropped" + ignore (Log.warning "response dropped") end else begin match try Some(Int_map.find msg.command card.events) with Not_found -> None with | Some seq -> @@ -194,10 +196,10 @@ let rec dispatch card = try push msg.data with exn -> - LogI#exn exn "pushing event %d from %s card failed with" msg.command card.wrapper.name) + ignore (Log.exn_f exn "pushing event %d from %s card failed with" msg.command card.wrapper.name)) seq | None -> - LogI#warning "command dropped" + ignore (Log.warning "command dropped") end; dispatch card end @@ -258,7 +260,7 @@ let send card buffer = lwt len = select [card.abort_waiter; USB.interrupt_send ~handle:card.handle ~endpoint:1 buffer 0 64] in if len <> 64 then begin let msg = Printf.sprintf "write on %s card returned %d instead of 64" card.wrapper.name len in - lwt () = Log#error "%s" msg in + lwt () = Log.error msg in fail =<< abort card.wrapper (Card_crashed msg) end else return () @@ -292,7 +294,7 @@ let rec send_request wrapper command data = | Canceled -> fail Canceled | exn -> - lwt () = Log#exn exn "write to %s card failed with" wrapper.name in + lwt () = Log.exn_f exn "write to %s card failed with" wrapper.name in fail =<< abort wrapper exn (* Send a command without waiting for the reply: *) @@ -309,7 +311,7 @@ let rec send_command wrapper command data = | Canceled -> fail Canceled | exn -> - lwt () = Log#exn exn "write to %s card failed with" wrapper.name in + lwt () = Log.exn_f exn "write to %s card failed with" wrapper.name in fail =<< abort wrapper exn let connect wrapper command = match wrapper.state with diff --git a/PC_Mainboard/driver/driver.ml b/PC_Mainboard/driver/driver.ml index 37379f1..0a6a4c0 100644 --- a/PC_Mainboard/driver/driver.ml +++ b/PC_Mainboard/driver/driver.ml @@ -9,6 +9,8 @@ (* Driver for USB cards *) +module Log = Lwt_log.Make(struct let section = "driver" end) + open OBus_pervasives open Lwt @@ -250,7 +252,7 @@ struct dev.speed_right <- 0 let move dev dist speed acc = - lwt () = Log#info "motor: move(dist=%d, speed=%d, acc=%d)" dist speed acc in + lwt () = Log.info_f "motor: move(dist=%d, speed=%d, acc=%d)" dist speed acc in match dev.move_state with | Ms_moving _ | Ms_stopping -> fail (Failure "already moving") @@ -273,7 +275,7 @@ struct end let turn dev angle speed acc = - lwt () = Log#info "motor: turn(angle=%d, speed=%d, acc=%d)" angle speed acc in + lwt () = Log.info_f "motor: turn(angle=%d, speed=%d, acc=%d)" angle speed acc in match dev.move_state with | Ms_moving _ | Ms_stopping -> fail (Failure "already moving") @@ -308,12 +310,12 @@ struct | `Smooth -> "smooth" let stop_motors dev motor mode = - lwt () = Log#info "motor: stopping(motor=%s, mode=%s)" (string_of_motor motor) (string_of_stop_mode mode) in + lwt () = Log.info_f "motor: stopping(motor=%s, mode=%s)" (string_of_motor motor) (string_of_stop_mode mode) in stop_move dev; Commands.Motor.stop dev.card motor mode let set_speed dev motor speed acc = - lwt () = Log#info "motor: set_speed(motor=%s, speed=%d, acc=%d)" (string_of_motor motor) speed acc in + lwt () = Log.info_f "motor: set_speed(motor=%s, speed=%d, acc=%d)" (string_of_motor motor) speed acc in stop_move dev; let dir, abs_speed = if speed < 0 then (`Backward, -speed) else (`Forward, speed) in let date = Unix.gettimeofday () in @@ -446,7 +448,7 @@ struct state card_motor) OL_method Shutdown : OBus_connection.t -> unit = fun () connection -> - lwt () = Log#info "exiting" in + lwt () = Log.info "exiting" in quit := true; lwt _ = OBus_bus.release_name connection "fr.krobot" and () = close card_interface @@ -529,10 +531,10 @@ end let rec monitor_card ~name ~vendor_id ~product_id ~set on_up on_down = match try `Handle(USB.open_device_with ~vendor_id ~product_id) with exn -> `Error exn with | `Error exn -> - lwt () = Log#exn exn "failed to open %s card" name in + lwt () = Log.exn_f exn "failed to open %s card" name in restart_card ~name ~vendor_id ~product_id ~set on_up on_down | `Handle handle -> - lwt () = Log#info "%s card opened" name in + lwt () = Log.info_f "%s card opened" name in begin try_lwt lwt card = Card.make name handle in @@ -541,7 +543,7 @@ let rec monitor_card ~name ~vendor_id ~product_id ~set on_up on_down = return (`Error exn) end >>= function | `Card card -> - lwt () = Log#info "%s card is up and running" name in + lwt () = Log.info_f "%s card is up and running" name in set (Some card); lwt () = on_up card in lwt result = Card.watch card in @@ -552,11 +554,11 @@ let rec monitor_card ~name ~vendor_id ~product_id ~set on_up on_down = | `Closed -> return () | `Error exn -> - Log#exn exn "%s card crashed with" name + Log.exn_f exn "%s card crashed with" name in restart_card ~name ~vendor_id ~product_id ~set on_up on_down | `Error exn -> - lwt () = Log#exn exn "failed to make %s card" name in + lwt () = Log.exn_f exn "failed to make %s card" name in restart_card ~name ~vendor_id ~product_id ~set on_up on_down and restart_card ~name ~vendor_id ~product_id ~set on_up on_down = @@ -585,7 +587,7 @@ lwt () = lwt () = try_lwt - lwt () = Log#info "Killing any running driver" in + lwt () = Log.info "Killing any running driver" in OBus_connection.method_call bus ~path:["fr"; "krobot"; "Manager"] ~interface:"fr.krobot.Manager" @@ -611,9 +613,9 @@ lwt () = lwt () = if !foreground then (* Running foreground, prints message on stderr: *) - Log#notice "starting krobot driver in foreground mode" + Log.notice "starting krobot driver in foreground mode" else begin - lwt () = Log#notice "starting krobot driver in daemon mode" in + lwt () = Log.notice "starting krobot driver in daemon mode" in Lwt_daemon.daemonize (); return () end @@ -661,6 +663,6 @@ lwt () = Manager.OBus.export bus (); - LogI#notice "ready, waiting for requests"; + lwt () = Log.notice "ready, waiting for requests" in done_waiter end diff --git a/PC_Mainboard/lib_krobot/krobot.ml b/PC_Mainboard/lib_krobot/krobot.ml index fd4a1a1..e3bf7f6 100644 --- a/PC_Mainboard/lib_krobot/krobot.ml +++ b/PC_Mainboard/lib_krobot/krobot.ml @@ -7,6 +7,8 @@ * This file is a part of [kro]bot. *) +module Log = Lwt_log.Make(struct let section = "krobot" end) + open OBus_pervasives open Lwt @@ -88,7 +90,7 @@ let get_bus () = match try Some(Sys.getenv "KROBOT") with Not_found -> None with | Some command -> begin try_lwt - lwt () = Log#info "connecting to the krobot with command %S" command in + lwt () = Log.info_f "connecting to the krobot with command %S" command in let process = Lwt_process.open_process (Lwt_process.shell command) in let transport = OBus_transport.make @@ -101,15 +103,15 @@ let get_bus () = lwt () = OBus_bus.register_connection connection in return connection with exn -> - lwt () = Log#exn exn "failed to create remote transport" in + lwt () = Log.exn exn "failed to create remote transport" in fail exn end | None -> try_lwt - lwt () = Log#info "connecting to the krobot with the local krobot bus" in + lwt () = Log.info "connecting to the krobot with the local krobot bus" in Lazy.force bus with exn -> - lwt () = Log#exn exn "failed to connect to the local krobot bus" in + lwt () = Log.exn exn "failed to connect to the local krobot bus" in fail exn let create ?peer () = diff --git a/PC_Mainboard/services/hard_stop.ml b/PC_Mainboard/services/hard_stop.ml index f2352a7..a07d177 100644 --- a/PC_Mainboard/services/hard_stop.ml +++ b/PC_Mainboard/services/hard_stop.ml @@ -9,6 +9,8 @@ (* Stop the robot on collisions *) +module Log = Lwt_log.Make(struct let section = "" end) + open Lwt (* Duration of an inhibition: *) @@ -25,12 +27,12 @@ type state = OK | Stopped let handle_collide krobot sensors = join [ (if Util.front_collide sensors then begin - lwt () = Log#notice "front collision detected, inhibit motors" in + lwt () = Log.notice "front collision detected, inhibit motors" in Krobot.inhibit_forward krobot duration end else return ()); (if Util.back_collide sensors then begin - lwt () = Log#notice "back collision detected, inhibit motors" in + lwt () = Log.notice "back collision detected, inhibit motors" in Krobot.inhibit_backward krobot duration end else return ()); @@ -40,9 +42,9 @@ lwt () = Arg.parse args ignore usage; if !foreground then - LogI#info "starting hard_stop in foreground mode" + ignore (Log.info "starting hard_stop in foreground mode") else begin - LogI#info "starting hard_stop in daemon mode"; + ignore (Log.info "starting hard_stop in daemon mode"); Lwt_log.default := Lwt_log.syslog ~level:(min Lwt_log.Info Lwt_log.default_level) ~facility:`Daemon hooks/post-receive -- krobot |