From: Jérémie D. <Ba...@us...> - 2010-02-16 19:35:51
|
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 60ddcdf6fc72e9ca1906fb6b470b5ee4d98ed6ca (commit) via 459275da1eec8e551b033c2e280904a94ef05d56 (commit) from 31a63cff42edcdc0ad0302eb62a3bd4fad21bc26 (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 60ddcdf6fc72e9ca1906fb6b470b5ee4d98ed6ca Author: Olivier BICHLER <oli...@en...> Date: Tue Feb 16 20:34:42 2010 +0100 [driver] bugfixes commit 459275da1eec8e551b033c2e280904a94ef05d56 Author: Jérémie Dimino <je...@di...> Date: Tue Feb 16 19:18:10 2010 +0100 typos ----------------------------------------------------------------------- Changes: diff --git a/PC_Mainboard/clients/controller.ml b/PC_Mainboard/clients/controller.ml index f8817b0..f694bba 100644 --- a/PC_Mainboard/clients/controller.ml +++ b/PC_Mainboard/clients/controller.ml @@ -116,7 +116,7 @@ let rec draw size Draw.textf zone x 2 "compass = %d" compass; let text_of_state name = function | `Absent -> [fg lred; textf "%s card is absent" name] - | `Present -> [fg lred; textf "%s card is present" name] + | `Present -> [textf "%s card is present" name] in Draw.textc zone x 3 (text_of_state "interface" state_interface); Draw.textc zone x 4 (text_of_state "sensor" state_sensor); diff --git a/PC_Mainboard/driver/card.ml b/PC_Mainboard/driver/card.ml index cd8c920..1a9927c 100644 --- a/PC_Mainboard/driver/card.ml +++ b/PC_Mainboard/driver/card.ml @@ -167,7 +167,7 @@ let rec dispatch card = return (`Error exn) end >>= function | `Error exn -> - Log#exn exn "stop dispatching on %s card: %s" card.wrapper.name (Printexc.to_string exn); + Log#exn exn "stop dispatching on %s card" card.wrapper.name; lwt _ = abort card.wrapper exn in return () | `OK len -> diff --git a/PC_Mainboard/driver/driver.ml b/PC_Mainboard/driver/driver.ml index 06e11a1..bd69ec1 100644 --- a/PC_Mainboard/driver/driver.ml +++ b/PC_Mainboard/driver/driver.ml @@ -193,9 +193,6 @@ struct mutable acceleration : int; (* The current acceleration *) - mutable state : unit React.signal; - (* Reinit [acceleraation] to None when the card state changes *) - mutable inhibit_forward_until : float; mutable inhibit_backward_until : float; (* Date after which motor's inhition should be stopped *) @@ -370,7 +367,6 @@ struct obus = OBus_object.make path; card = card; acceleration = 0; - state = React.S.const (); inhibit_forward_until = 0.0; inhibit_backward_until = 0.0; move_state = Ms_static; @@ -491,40 +487,45 @@ end (* Continously try to open the card with given parameters *) let rec monitor_card ~name ~vendor_id ~product_id ~set on_up on_down = - try_bind - (fun () -> - return (USB.open_device_with ~vendor_id ~product_id)) - (fun handle -> - Log#info "%s card opened" name; - lwt () = - try_lwt - lwt card = Card.make name handle in - set (Some card); - Log#info "%s card is up and running" name; - lwt () = on_up card in - lwt result = Card.watch card in - set None; - lwt () = on_down () in - match result with - | `Closed -> - return () - | `Error exn -> - Log#exn exn "%s card crashed with" name; - return () - with exn -> - Log#exn exn "failed to initialise %s card" name; - return () - in - if !quit then - return () - else - monitor_card ~name ~vendor_id ~product_id ~set on_up on_down) - (fun exn -> - Log#exn exn "failed to open %s card" name; - if !quit then - return () - else - 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 -> + Log#exn exn "failed to open %s card" name; + restart_card ~name ~vendor_id ~product_id ~set on_up on_down + | `Handle handle -> + Log#info "%s card opened" name; + begin + try_lwt + lwt card = Card.make name handle in + return (`Card card) + with exn -> + return (`Error exn) + end >>= function + | `Card card -> + Log#info "%s card is up and running" name; + set (Some card); + lwt () = on_up card in + lwt result = Card.watch card in + set None; + lwt () = on_down () in + begin + match result with + | `Closed -> + () + | `Error exn -> + Log#exn exn "%s card crashed with" name + end; + restart_card ~name ~vendor_id ~product_id ~set on_up on_down + | `Error exn -> + Log#exn exn "failed to make %s card" name; + 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 = + if !quit then + return () + else begin + lwt () = Lwt_unix.sleep Config.reopen_delay in + monitor_card ~name ~vendor_id ~product_id ~set on_up on_down + end (* +-----------------------------------------------------------------+ | Entry point | @@ -583,7 +584,6 @@ lwt () = and () = AX12.OBus.export bus =|< AX12.make card ["fr"; "krobot"; "Devices"; "AX12"] in return ()) (fun () -> - OBus_object.remove_by_path bus ["fr"; "krobot"; "Cards"; "Interface"]; OBus_object.remove_by_path bus ["fr"; "krobot"; "Devices"; "Compass"]; OBus_object.remove_by_path bus ["fr"; "krobot"; "Devices"; "AX12"]; return ()) @@ -596,7 +596,6 @@ lwt () = and () = Range_finders.OBus.export bus =|< Range_finders.make card ["fr"; "krobot"; "Devices"; "RangeFinders"] in return ()) (fun () -> - OBus_object.remove_by_path bus ["fr"; "krobot"; "Cards"; "Sensor"]; OBus_object.remove_by_path bus ["fr"; "krobot"; "Devices"; "LogicSensors"]; OBus_object.remove_by_path bus ["fr"; "krobot"; "Devices"; "RangeFinders"]; return ()) @@ -609,7 +608,6 @@ lwt () = lwt () = Motors.OBus.export bus =|< Motors.make card ["fr"; "krobot"; "Devices"; "Motors"] in return ()) (fun () -> - OBus_object.remove_by_path bus ["fr"; "krobot"; "Cards"; "Motor"]; OBus_object.remove_by_path bus ["fr"; "krobot"; "Devices"; "Motors"]; return ()) end; @@ -620,6 +618,6 @@ lwt () = Manager.OBus.export bus (); - Log#info "ready, waiting for requests"; + Log#notice "ready, waiting for requests"; done_waiter end hooks/post-receive -- krobot |