From: Jérémie D. <Ba...@us...> - 2011-03-17 17:50:37
|
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 76c6568221d3133754d2737441d8abeade097416 (commit) from a2b57864d1452b99d01b96efdc7aea7765f3a566 (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 76c6568221d3133754d2737441d8abeade097416 Author: Jérémie Dimino <je...@di...> Date: Thu Mar 17 18:49:59 2011 +0100 [info] make the driver to never fail ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/driver/krobot_driver.ml b/info/control2011/src/driver/krobot_driver.ml index fe7af7f..dab0a02 100644 --- a/info/control2011/src/driver/krobot_driver.ml +++ b/info/control2011/src/driver/krobot_driver.ml @@ -19,13 +19,29 @@ let () = Krobot_init.arg "-device" (Arg.Set_string device) "<device> The device lwt () = lwt bus = Krobot_init.init_service "Driver" in - (* Open the CAN bus. *) - lwt can = Krobot_can_bus.open_can !device in - - (* D-Bus --> CAN *) - E.keep (E.map_s (Krobot_can_bus.send can) (Krobot_can.recv bus)); - - (* CAN --> D-Bus *) while_lwt true do - Krobot_can_bus.recv can >>= Krobot_can.send bus + try_lwt + (* Open the CAN bus. *) + lwt can = Krobot_can_bus.open_can !device in + + let active, set_active = S.create true in + + (* D-Bus --> CAN *) + let ev = E.map_s (Krobot_can_bus.send can) (E.when_ active (Krobot_can.recv bus)) in + + try_lwt + (* CAN --> D-Bus *) + while_lwt true do + Krobot_can_bus.recv can >>= Krobot_can.send bus + done + with exn -> + (* Make sure no more messages are sent on the CAN bus. *) + set_active false; + (* This is just here to keep a reference to [ev]. *) + E.stop ev; + raise_lwt exn + with exn -> + lwt () = Lwt_log.error ~exn "failure" in + (* Wait a bit before retrying. *) + Lwt_unix.sleep 0.5 done hooks/post-receive -- krobot |