From: Jérémie D. <Ba...@us...> - 2011-03-30 21:05:34
|
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 32438eb8c7678e35dfb26bde88d77c0a73c63596 (commit) from e7c92edc9c0d24e0ad519fc88ab61c355109b9cc (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 32438eb8c7678e35dfb26bde88d77c0a73c63596 Author: Jérémie Dimino <je...@di...> Date: Wed Mar 30 23:05:02 2011 +0200 [info] better errors on invalid frame ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/lib/krobot_message.ml b/info/control2011/src/lib/krobot_message.ml index 08e4402..fe1dc3c 100644 --- a/info/control2011/src/lib/krobot_message.ml +++ b/info/control2011/src/lib/krobot_message.ml @@ -193,7 +193,18 @@ let encode = function | Decoding | +-----------------------------------------------------------------+ *) +exception Invalid_frame of Krobot_can.frame + +let () = + Printexc.register_printer + (function + | Invalid_frame frame -> + Some(Printf.sprintf "Invalid_frame%s" (Krobot_can.string_of_frame frame)) + | _ -> + None) + let decode frame = + try if frame.remote then match frame.identifier with | 103 -> @@ -242,6 +253,8 @@ let decode frame = Motor_stop | _ -> Unknown frame + with Invalid_argument _ -> + raise (Invalid_frame frame) (* +-----------------------------------------------------------------+ | Sending/receiving messages | diff --git a/info/control2011/src/lib/krobot_message.mli b/info/control2011/src/lib/krobot_message.mli index 298572d..5c80ce7 100644 --- a/info/control2011/src/lib/krobot_message.mli +++ b/info/control2011/src/lib/krobot_message.mli @@ -54,6 +54,9 @@ type t = val to_string : t -> string (** Returns the string representation of the given message. *) +exception Invalid_frame of Krobot_can.frame + (** Exception raised when an invalid frame is encountered. *) + val encode : t -> Krobot_can.frame (** Encode the given message into a CAN frame. *) hooks/post-receive -- krobot |