From: Jérémie D. <Ba...@us...> - 2010-02-15 18:56:46
|
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 a4b90752699e95c28994bd8db6da99995798d984 (commit) via 682f03efcf4e3f6d2ba9f83ce31b877238dfa952 (commit) from 4487bdbbf8267e3f894707a786880dbe9929a00f (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 a4b90752699e95c28994bd8db6da99995798d984 Author: Jérémie Dimino <je...@di...> Date: Mon Feb 15 19:53:58 2010 +0100 allow to reset cards in the controller commit 682f03efcf4e3f6d2ba9f83ce31b877238dfa952 Author: Jérémie Dimino <je...@di...> Date: Mon Feb 15 19:45:56 2010 +0100 Handle failures in joy_control.ml. ----------------------------------------------------------------------- Changes: diff --git a/PC_Mainboard/clients/joy_control.ml b/PC_Mainboard/clients/joy_control.ml index 1fb1edb..b36a9de 100644 --- a/PC_Mainboard/clients/joy_control.ml +++ b/PC_Mainboard/clients/joy_control.ml @@ -117,6 +117,13 @@ let child_loop pipe joy = let axis_coef = 8 let acceleration = 800 +let try_call action f = + try_lwt + f () + with Failure msg -> + Log#error "action %s failed with: %s" action msg; + return () + let parent_loop krobot pipe = let rstop = ref false and lstop = ref false in let rec loop () = @@ -125,24 +132,24 @@ let parent_loop krobot pipe = return () | JoyRAxis n -> if not !rstop then - lwt () = Krobot.set_speed krobot ~motor:`Right ~speed:((-n) * axis_coef) ~acc:acceleration in + lwt () = try_call "set-speed-right" (fun () -> Krobot.set_speed krobot ~motor:`Right ~speed:((-n) * axis_coef) ~acc:acceleration) in loop () else loop () | JoyLAxis n -> if not !lstop then - lwt () = Krobot.set_speed krobot ~motor:`Left ~speed:(n * axis_coef) ~acc:acceleration in + lwt () = try_call "set-speed-left" (fun () -> Krobot.set_speed krobot ~motor:`Left ~speed:(n * axis_coef) ~acc:acceleration) in loop () else loop () | JoyButtonPressed ButtonL2 -> lstop := true; - lwt () = Krobot.stop_motors krobot ~motor:`Left ~mode:`Abrupt in + lwt () = try_call "stop-left-motor" (fun () -> Krobot.stop_motors krobot ~motor:`Left ~mode:`Abrupt) in ignore (lwt () = Lwt_unix.sleep 1.0 in lstop := false; return ()); loop () | JoyButtonPressed ButtonR2 -> rstop := true; - lwt () = Krobot.stop_motors krobot ~motor:`Right ~mode:`Abrupt in + lwt () = try_call "stop-right-motor" (fun () -> Krobot.stop_motors krobot ~motor:`Right ~mode:`Abrupt) in ignore (lwt () = Lwt_unix.sleep 1.0 in rstop := false; return ()); loop () | JoyButtonReleased ButtonCircle -> @@ -178,5 +185,6 @@ let () = Unix.close fd_w; Lwt_main.run begin lwt krobot = Krobot.create () in + Log#notice "ready to process event"; 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 158bd3d..d9999d2 100644 --- a/PC_Mainboard/clients/script.ml +++ b/PC_Mainboard/clients/script.ml @@ -41,6 +41,8 @@ let commands = [ ("acc", Arg_int)] }; { name = "bootloader"; args = [("card", Arg_keyword ["interface"; "sensor"; "motor"])] }; + { name = "reset"; + args = [("card", Arg_keyword ["interface"; "sensor"; "motor"])] }; ] let set_of_list l = List.fold_left (fun set x -> TextSet.add x set) TextSet.empty l @@ -140,6 +142,13 @@ let exec krobot line = | "motor" -> `Motor | "sensor" -> `Sensor | _ -> failwith "Script.exec: invalid card") + | "reset" -> + Krobot.Card.reset krobot + (match arg_string "card" "" with + | "interface" -> `Interface + | "motor" -> `Motor + | "sensor" -> `Sensor + | _ -> failwith "Script.exec: invalid card") | _ -> Log#error "unknown command %S" action; return () diff --git a/PC_Mainboard/driver/card.mli b/PC_Mainboard/driver/card.mli index 55cc194..8ca9ef2 100644 --- a/PC_Mainboard/driver/card.mli +++ b/PC_Mainboard/driver/card.mli @@ -41,6 +41,9 @@ val close : t -> unit Lwt.t exception Card_closed (** Exception raised when trying to use a closed card *) +val restart : t -> unit Lwt.t + (** Closes and reopens the given card *) + (** {6 Sending/receving messages} *) val make_buffer : unit -> string diff --git a/PC_Mainboard/driver/driver.ml b/PC_Mainboard/driver/driver.ml index 801319b..d821592 100644 --- a/PC_Mainboard/driver/driver.ml +++ b/PC_Mainboard/driver/driver.ml @@ -512,6 +512,9 @@ struct OL_method Bootloader : unit = fun dev -> Commands.bootloader dev.card + OL_method Reset : unit = fun dev -> + Card.restart dev.card + OL_signal StateChanged : Types.card_state let make card path = diff --git a/PC_Mainboard/lib_krobot/krobot.ml b/PC_Mainboard/lib_krobot/krobot.ml index 1b38052..409f4ea 100644 --- a/PC_Mainboard/lib_krobot/krobot.ml +++ b/PC_Mainboard/lib_krobot/krobot.ml @@ -213,6 +213,7 @@ struct OP_method GetFirmwareBuild : string OP_method GetBoardInfo : string OP_method Bootloader : unit + OP_method Reset : unit let proxy krobot card = OBus_proxy.make krobot.peer @@ -224,4 +225,5 @@ struct let get_firmware_build krobot card = get_firmware_build (proxy krobot card) let get_board_info krobot card = get_board_info (proxy krobot card) let bootloader krobot card = bootloader (proxy krobot card) + let reset krobot card = reset (proxy krobot card) end diff --git a/PC_Mainboard/lib_krobot/krobot.mli b/PC_Mainboard/lib_krobot/krobot.mli index 3a45b1a..6561470 100644 --- a/PC_Mainboard/lib_krobot/krobot.mli +++ b/PC_Mainboard/lib_krobot/krobot.mli @@ -99,4 +99,5 @@ module Card : sig val get_firmware_build : t -> card -> string Lwt.t val get_board_info : t -> card -> string Lwt.t + val reset : t -> card -> unit Lwt.t end hooks/post-receive -- krobot |