From: Jérémie D. <Ba...@us...> - 2010-03-24 21:56:11
|
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 76537af4b98b2564c9d1371b574a493c3056f4e4 (commit) from f39fcb227d0c9db8e22c34a31f4f791c9f52080c (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 76537af4b98b2564c9d1371b574a493c3056f4e4 Author: Kro[bot] <krobot@wally.(none)> Date: Wed Mar 24 21:54:30 2010 +0000 new logs ----------------------------------------------------------------------- Changes: diff --git a/PC_Mainboard/clients/controller.ml b/PC_Mainboard/clients/controller.ml index 8c58876..bd8bba0 100644 --- a/PC_Mainboard/clients/controller.ml +++ b/PC_Mainboard/clients/controller.ml @@ -9,8 +9,6 @@ (* Prints status continuously *) -module Log = Lwt_log.Make(struct let section = "" end) - open Lwt open Lwt_term open Lwt_read_line @@ -32,7 +30,7 @@ let logs, set_logs = React.S.create [] let add_date line = let buffer = Buffer.create 42 in - Lwt_log.render ~buffer ~level:Lwt_log.Info ~message:"" ~template:"$(date): "; + Lwt_log.render ~buffer ~level:Lwt_log.Info ~message:"" ~template:"$(date): " ~section:Lwt_log.Section.main; text (Buffer.contents buffer) :: line (* Add a list of lines to logs *) @@ -67,7 +65,7 @@ let redirect_stderr () = let init_logger () = Lwt_log.default := Lwt_log.make - ~output:(fun level lines -> + ~output:(fun section level lines -> log_add_lines (List.map (fun line -> @@ -79,7 +77,6 @@ let init_logger () = lines); return ()) ~close:return - () (* +-----------------------------------------------------------------+ | Read-line | @@ -119,7 +116,7 @@ let rec loop krobot history = else if line <> "" then begin let history = Lwt_read_line.add_entry line history in set_engine_state (Engine.init history); - lwt () = Log.notice line in + lwt () = Lwt_log.notice line in ignore (Script.exec ~krobot ~logger:(fun line -> log_add_line line; return ()) ~command:line); loop krobot history end else @@ -377,7 +374,7 @@ let refresh krobot = +-----------------------------------------------------------------+ *) lwt () = - lwt () = Log.notice "connecting to the krobot bus..." in + lwt () = Lwt_log.notice "connecting to the krobot bus..." in lwt bus = Lazy.force Krobot.bus in lwt krobot = Krobot.create () in diff --git a/PC_Mainboard/clients/init_position.ml b/PC_Mainboard/clients/init_position.ml index 4e74d75..85a69bd 100644 --- a/PC_Mainboard/clients/init_position.ml +++ b/PC_Mainboard/clients/init_position.ml @@ -9,35 +9,33 @@ (* 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 () = Lwt_log.notice "moving backward" in Krobot.move krobot ~distance:(-1000) ~velocity:100 ~acceleration:100 >>= function | `OK -> - lwt () = Log.error "where am i ???" in + lwt () = Lwt_log.error "where am i ???" in exit 1 | `Stopped -> - Log.notice "backward colisiton dectected" + Lwt_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 () = Lwt_log.notice "going to initial position on first axis" in lwt _ = Krobot.move krobot ~distance:Krobot_config.initial_position ~velocity:400 ~acceleration:800 in - lwt () = Log.notice "turning" in + lwt () = Lwt_log.notice "turning" in lwt _ = Krobot.turn krobot ~angle:(-90) ~velocity:400 ~acceleration:800 in lwt () = move_backward_slowly krobot in - lwt () = Log.notice "going to initial position on second axis" in + lwt () = Lwt_log.notice "going to initial position on second axis" in lwt _ = Krobot.move krobot ~distance:Krobot_config.initial_position ~velocity:400 ~acceleration:800 in - lwt () = Log.notice "turning" in + lwt () = Lwt_log.notice "turning" in lwt _ = Krobot.turn krobot ~angle:45 ~velocity:400 ~acceleration:800 in return () diff --git a/PC_Mainboard/clients/joy_control.ml b/PC_Mainboard/clients/joy_control.ml index a31a0b7..2247147 100644 --- a/PC_Mainboard/clients/joy_control.ml +++ b/PC_Mainboard/clients/joy_control.ml @@ -9,8 +9,6 @@ (* Control the robot with a joystick *) -module Log = Lwt_log.Make(struct let section = "" end) - open Lwt open Sdljoystick open Sdlevent @@ -135,11 +133,11 @@ let try_call action f = try_lwt f () with Failure msg -> - lwt () = Log.error_f "action %s failed with: %s" action msg in + lwt () = Lwt_log.error_f "action %s failed with: %s" action msg in return () let rec set_velocities krobot velocities = - lwt () = Log.info_f "set-velocities: left=%d right=%d" (fst velocities) (snd velocities) in + lwt () = Lwt_log.info_f "set-velocities: left=%d right=%d" (fst velocities) (snd velocities) in lwt () = try_call "set-velocities" (fun () -> @@ -223,6 +221,6 @@ let () = Unix.close fd_w; Lwt_main.run begin lwt krobot = Krobot.create () in - lwt () = Log.notice "ready to process event" in + lwt () = 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/driver/driver.ml b/PC_Mainboard/driver/driver.ml index 41c7c76..fcb947a 100644 --- a/PC_Mainboard/driver/driver.ml +++ b/PC_Mainboard/driver/driver.ml @@ -9,7 +9,7 @@ (* Driver for USB cards *) -module Log = Lwt_log.Make(struct let section = "driver" end) +let section = Lwt_log.Section.make "driver" open OBus_pervasives open Krobot_types @@ -363,18 +363,18 @@ struct let move dev dist velocity acc = lwt () = - Log.info_f "move: distance=%d velocity=%d acceleration=%d" + Lwt_log.info_f ~section "move: distance=%d velocity=%d acceleration=%d" dist velocity acc in match dev.state with | Trajectory _ -> - lwt () = Log.info "move: state=trajectory" in + lwt () = Lwt_log.info ~section "move: state=trajectory" in fail (Failure "already in a trajectory") | Manual _ -> - lwt () = Log.info "move: state=manual" in + lwt () = Lwt_log.info ~section "move: state=manual" in fail (Failure "currently in manual mode") | Static -> - lwt () = Log.info "move: state=static" in + lwt () = Lwt_log.info ~section "move: state=static" in let date = Unix.gettimeofday () in if (dist > 0 && date < dev.inhibit_forward_until) || (dist < 0 && date < dev.inhibit_backward_until) then fail (Failure "inhibited move") @@ -403,18 +403,18 @@ struct let turn dev angle velocity acc = lwt () = - Log.info_f "turn: angle=%d velocity=%d acceleration=%d" + Lwt_log.info_f ~section "turn: angle=%d velocity=%d acceleration=%d" angle velocity acc in match dev.state with | Trajectory _ -> - lwt () = Log.info "turn: state=trajectory" in + lwt () = Lwt_log.info ~section "turn: state=trajectory" in fail (Failure "already in a trajectory") | Manual _ -> - lwt () = Log.info "turn: state=manual" in + lwt () = Lwt_log.info ~section "turn: state=manual" in fail (Failure "currently in manual mode") | Static -> - lwt () = Log.info "turn: state=static" in + lwt () = Lwt_log.info ~section "turn: state=static" in let waiter, wakener = Lwt.wait () in let trajectory = { abort = wakener; @@ -443,18 +443,18 @@ struct let goto dev x y velocity acc mode bypass_distance = lwt () = - Log.info_f "goto: x=%d y=%d velocity=%d acceleration=%d mode=%s bypass_distance=%d" + Lwt_log.info_f ~section "goto: x=%d y=%d velocity=%d acceleration=%d mode=%s bypass_distance=%d" x y velocity acc (string_of_goto_mode mode) bypass_distance in match dev.state with | Trajectory _ -> - lwt () = Log.info "goto: state=trajectory" in + lwt () = Lwt_log.info ~section "goto: state=trajectory" in fail (Failure "already in a trajectory") | Manual _ -> - lwt () = Log.info "goto: state=manual" in + lwt () = Lwt_log.info ~section "goto: state=manual" in fail (Failure "currently in manual mode") | Static -> - lwt () = Log.info "goto: state=static" in + lwt () = Lwt_log.info ~section "goto: state=static" in let date = Unix.gettimeofday () in if date < dev.inhibit_forward_until then fail (Failure "inhibited move") @@ -497,22 +497,22 @@ struct | `Off -> "off" let stop_motors dev mode = - lwt () = Log.info_f "stop-motors: mode=%s" (string_of_stop_mode mode) in + lwt () = Lwt_log.info_f ~section "stop-motors: mode=%s" (string_of_stop_mode mode) in match dev.state with | Trajectory trajectory -> - lwt () = Log.info "stop-motors: state=trajectory" in + lwt () = Lwt_log.info ~section "stop-motors: state=trajectory" in trajectory.stopped <- true; lwt () = USB_commands.Motors.traj_stop dev.card `Both mode in wakeup trajectory.abort (); return () | Manual(stopper, left, right) -> - lwt () = Log.info "stop-motors: state=manual" in + lwt () = Lwt_log.info ~section "stop-motors: state=manual" in lwt () = USB_commands.Motors.traj_stop dev.card `Both mode in dev.state <- Static; cancel stopper; return () | Static -> - lwt () = Log.info "stop-motors: state=static" in + lwt () = Lwt_log.info ~section "stop-motors: state=static" in USB_commands.Motors.traj_stop dev.card `Both mode let _set_velocities dev stopper (settings_l, settings_r) (velocity_l, velocity_r) (acceleration_l, acceleration_r) duration = @@ -546,20 +546,20 @@ struct let set_velocities dev velocities accelerations duration = lwt () = - Log.info_f "set-velocities: velocities=(%d, %d) accelerations=(%d, %d) duration=%f" + Lwt_log.info_f ~section "set-velocities: velocities=(%d, %d) accelerations=(%d, %d) duration=%f" (fst velocities) (snd velocities) (fst accelerations) (snd accelerations) duration in match dev.state with | Trajectory _ -> - lwt () = Log.info "set-velocities: state=trajectory" in + lwt () = Lwt_log.info ~section "set-velocities: state=trajectory" in fail (Failure "currently in trajectory mode") | Manual(stopper, left, right) -> - lwt () = Log.info "set-velocities: state=manual" in + lwt () = Lwt_log.info ~section "set-velocities: state=manual" in _set_velocities dev stopper (left, right) velocities accelerations duration | Static -> - lwt () = Log.info "set-velocities: state=static" in + lwt () = Lwt_log.info ~section "set-velocities: state=static" in let static = { velocity = 0; acceleration = 0; direction = `Forward } in _set_velocities dev (return ()) (static, static) velocities accelerations duration @@ -654,7 +654,7 @@ struct state card_monitoring) OL_method Shutdown : OBus_connection.t -> unit = fun manager connection -> - lwt () = Log.info "exiting" in + lwt () = Lwt_log.info ~section "exiting" in quit := true; lwt () = close card_interface and () = close card_sensor @@ -749,10 +749,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.info_f "failed to open %s card: %s" name (Printexc.to_string exn) in + lwt () = Lwt_log.info_f ~section "failed to open %s card: %s" name (Printexc.to_string exn) in restart_card ~name ~vendor_id ~product_id ~set on_up on_down | `Handle handle -> - lwt () = Log.info_f "%s card opened" name in + lwt () = Lwt_log.info_f ~section "%s card opened" name in begin try_lwt lwt card = Krobot_card.make name handle in @@ -761,7 +761,7 @@ let rec monitor_card ~name ~vendor_id ~product_id ~set on_up on_down = return (`Error exn) end >>= function | `Krobot_card card -> - lwt () = Log.info_f "%s card is up and running" name in + lwt () = Lwt_log.info_f ~section "%s card is up and running" name in set (Some card); lwt () = on_up card in lwt result = Krobot_card.watch card in @@ -772,11 +772,11 @@ let rec monitor_card ~name ~vendor_id ~product_id ~set on_up on_down = | `Closed -> return () | `Error exn -> - Log.info_f "%s card crashed: %s" name (Printexc.to_string exn) + Lwt_log.info_f ~section "%s card crashed: %s" name (Printexc.to_string exn) in restart_card ~name ~vendor_id ~product_id ~set on_up on_down | `Error exn -> - lwt () = Log.exn_f exn "failed to make %s card" name in + lwt () = Lwt_log.exn_f ~section ~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 = @@ -805,7 +805,7 @@ lwt () = lwt () = try_lwt - lwt () = Log.info "Killing any running driver" in + lwt () = Lwt_log.info ~section "Killing any running driver" in OBus_connection.method_call bus ~path:["fr"; "krobot"; "Manager"] ~interface:"fr.krobot.Manager" @@ -826,9 +826,9 @@ lwt () = lwt () = if !foreground then (* Running foreground, prints message on stderr: *) - Log.notice "starting krobot driver in foreground mode" + Lwt_log.notice ~section "starting krobot driver in foreground mode" else begin - lwt () = Log.notice "starting krobot driver in daemon mode" in + lwt () = Lwt_log.notice ~section "starting krobot driver in daemon mode" in Lwt_daemon.daemonize (); return () end @@ -889,7 +889,7 @@ lwt () = OBus_object.export bus Manager.manager; - lwt () = Log.notice "ready, waiting for requests" in + lwt () = Lwt_log.notice ~section "ready, waiting for requests" in lwt () = done_waiter in OBus_connection.close bus end diff --git a/PC_Mainboard/driver/krobot_card.ml b/PC_Mainboard/driver/krobot_card.ml index f12da8b..5b23d9d 100644 --- a/PC_Mainboard/driver/krobot_card.ml +++ b/PC_Mainboard/driver/krobot_card.ml @@ -7,7 +7,7 @@ * This file is a part of [kro]bot. *) -module Log = Lwt_log.Make(struct let section = "card" end) +let section = Lwt_log.Section.make "card" open Lwt @@ -186,14 +186,14 @@ let abort wrapper exn = +-----------------------------------------------------------------+ *) let dropped typ card msg = - lwt () = Log.warning_f "%s dropped on card %s" typ card.wrapper.name in - lwt () = Log.warning_f "===== + lwt () = Lwt_log.warning_f ~section "%s dropped on card %s" typ card.wrapper.name in + lwt () = Lwt_log.warning_f ~section "===== host_serial = %d device_serial = %d command = %d error = %s data:" msg.host_serial msg.device_serial msg.command (if msg.error <> 0 then error_message msg.error else "none") in - Lwt_stream.iter_s (fun line -> Log.warning line) (Lwt_stream.hexdump (Lwt_stream.of_string msg.data)) + Lwt_stream.iter_s (fun line -> Lwt_log.warning ~section line) (Lwt_stream.hexdump (Lwt_stream.of_string msg.data)) (* Dispatch incomming messages continously *) let rec dispatch card = @@ -209,13 +209,13 @@ let rec dispatch card = return (`Error exn) end >>= function | `Error exn -> - lwt () = Log.exn_f exn "stop dispatching on %s card" card.wrapper.name in + lwt () = Lwt_log.exn_f ~section ~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 msg in + lwt () = Lwt_log.error ~section msg in lwt _ = abort card.wrapper (Card_crashed msg) in return () end else begin @@ -239,7 +239,7 @@ let rec dispatch card = try push msg.data with exn -> - ignore (Log.exn_f exn "pushing event %d from %s card failed with" msg.command card.wrapper.name)) + ignore (Lwt_log.exn_f ~section ~exn "pushing event %d from %s card failed with" msg.command card.wrapper.name)) seq | None -> if msg.error <> 0 then @@ -309,7 +309,7 @@ let send card buffer = lwt len = pick [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 msg in + lwt () = Lwt_log.error ~section msg in fail =<< abort card.wrapper (Card_crashed msg) end else return () @@ -343,7 +343,7 @@ let rec send_request wrapper command data = | Canceled -> fail Canceled | exn -> - lwt () = Log.exn_f exn "write to %s card failed with" wrapper.name in + lwt () = Lwt_log.exn_f ~section ~exn "write to %s card failed with" wrapper.name in fail =<< abort wrapper exn (* Send a command without waiting for the reply: *) @@ -360,7 +360,7 @@ let rec send_command wrapper command data = | Canceled -> fail Canceled | exn -> - lwt () = Log.exn_f exn "write to %s card failed with" wrapper.name in + lwt () = Lwt_log.exn_f ~section ~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/lib_krobot/krobot.ml b/PC_Mainboard/lib_krobot/krobot.ml index 54647ed..ef40608 100644 --- a/PC_Mainboard/lib_krobot/krobot.ml +++ b/PC_Mainboard/lib_krobot/krobot.ml @@ -7,7 +7,7 @@ * This file is a part of [kro]bot. *) -module Log = Lwt_log.Make(struct let section = "krobot" end) +let section = Lwt_log.Section.make "krobot" open OBus_pervasives open Lwt @@ -89,7 +89,7 @@ let bus = lazy( match try Some(Sys.getenv "KROBOT") with Not_found -> None with | Some command -> begin try_lwt - lwt () = Log.info_f "connecting to the krobot with command %S" command in + lwt () = Lwt_log.info_f ~section "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 @@ -102,15 +102,15 @@ let bus = lazy( lwt () = OBus_bus.register_connection connection in return connection with exn -> - lwt () = Log.exn exn "failed to create remote transport" in + lwt () = Lwt_log.exn ~section ~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 () = Lwt_log.info ~section "connecting to the krobot with the local krobot bus" in OBus_bus.of_addresses (OBus_address.of_string Krobot_config.bus_address) with exn -> - lwt () = Log.exn exn "failed to connect to the local krobot bus" in + lwt () = Lwt_log.exn ~section ~exn "failed to connect to the local krobot bus" in fail exn ) diff --git a/PC_Mainboard/services/hard_stop.ml b/PC_Mainboard/services/hard_stop.ml index c457125..f72269a 100644 --- a/PC_Mainboard/services/hard_stop.ml +++ b/PC_Mainboard/services/hard_stop.ml @@ -9,8 +9,6 @@ (* Stop the robot on collisions *) -module Log = Lwt_log.Make(struct let section = "" end) - open Lwt (* Duration of an inhibition: *) @@ -28,18 +26,18 @@ let handle_collide krobot sensors = try_lwt join [ (if Util.front_collide sensors then begin - lwt () = Log.notice "front collision detected, inhibit motors" in + lwt () = 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 () = Lwt_log.notice "back collision detected, inhibit motors" in Krobot.inhibit_backward krobot duration end else return ()); ] with exn -> - Log.info_f "collision handling failed with: %s" (Printexc.to_string exn) + Lwt_log.info_f "collision handling failed with: %s" (Printexc.to_string exn) lwt () = Arg.parse args ignore usage; @@ -50,9 +48,9 @@ lwt () = lwt () = if !foreground then - Log.info "starting krobot hard stopper in foreground mode" + Lwt_log.info "starting krobot hard stopper in foreground mode" else begin - lwt () = Log.info "starting krobot hard stopper in daemon mode" in + lwt () = Lwt_log.info "starting krobot hard stopper in daemon mode" in Lwt_daemon.daemonize (); return () end hooks/post-receive -- krobot |