From: Jérémie D. <Ba...@us...> - 2010-02-18 17:25:23
|
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 c4abed670c3fe59fe59c4043cc1224cb2b90a33e (commit) from 992d372526a6fc373535550469f66096caf4ee99 (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 c4abed670c3fe59fe59c4043cc1224cb2b90a33e Author: Jérémie Dimino <je...@di...> Date: Thu Feb 18 18:24:22 2010 +0100 Ajout d'une commande pour obtenir la calibration des télémètres ----------------------------------------------------------------------- Changes: diff --git a/PC_Mainboard/clients/script.ml b/PC_Mainboard/clients/script.ml index 24d90cc..4dc474b 100644 --- a/PC_Mainboard/clients/script.ml +++ b/PC_Mainboard/clients/script.ml @@ -43,6 +43,8 @@ let commands = [ args = [("card", Arg_keyword ["interface"; "sensor"; "motor"])] }; { name = "reset"; args = [("card", Arg_keyword ["interface"; "sensor"; "motor"])] }; + { name = "get-calibration"; + args = [("range-finder", Arg_int)] }; ] let set_of_list l = List.fold_left (fun set x -> TextSet.add x set) TextSet.empty l @@ -149,6 +151,10 @@ let exec krobot line = | "motor" -> `Motor | "sensor" -> `Sensor | _ -> failwith "Script.exec: invalid card") + | "get-calibration" -> + lwt cal = Krobot.get_calibration krobot (arg_int "range-finder" 0) in + Log#notice "calibration: %s" (String.concat " " (List.map string_of_int (Array.to_list cal))); + return () | _ -> Log#error "unknown command %S" action; return () diff --git a/PC_Mainboard/driver/commands.ml b/PC_Mainboard/driver/commands.ml index 8524f16..4ca774b 100644 --- a/PC_Mainboard/driver/commands.ml +++ b/PC_Mainboard/driver/commands.ml @@ -67,6 +67,14 @@ struct RW.set_uint8 data 0 Protocol.get_rangefinder_state; lwt data = Card.send_request card Protocol.cmd_get data in return (Array.init 8 (fun i -> RW.get_int32 data (i * 4))) + + let get_calibration card num = + if num < 0 || num > 7 then invalid_arg "Commands.Range_finders.get_calibration"; + let data = Card.make_buffer () in + RW.set_uint8 data Protocol.get_rangefinder_calibration; + RW.set_uint8 data num; + lwt data = Card.send_request card Protocol.cmd_get data in + return (Array.init 8 (fun i -> RW.get_uint8 data i)) end module Motor = diff --git a/PC_Mainboard/driver/commands.mli b/PC_Mainboard/driver/commands.mli index ac1fe16..1b7ff04 100644 --- a/PC_Mainboard/driver/commands.mli +++ b/PC_Mainboard/driver/commands.mli @@ -30,6 +30,7 @@ end module Range_finders : sig val get : Card.t -> int array Lwt.t + val get_calibration : Card.t -> int -> int array Lwt.t end module Motor : sig diff --git a/PC_Mainboard/driver/driver.ml b/PC_Mainboard/driver/driver.ml index 1a7f4f1..3d7bab0 100644 --- a/PC_Mainboard/driver/driver.ml +++ b/PC_Mainboard/driver/driver.ml @@ -149,6 +149,8 @@ struct OL_signal Value : int array OL_method Get : int array = fun dev -> return dev.data + OL_method GetCalibration : int -> int array = fun dev num -> + Commands.Range_finders.get_calibration dev.card num let rec loop dev = lwt data = Commands.Range_finders.get dev.card in diff --git a/PC_Mainboard/lib_krobot/krobot.ml b/PC_Mainboard/lib_krobot/krobot.ml index 5ecd375..8d2ec2e 100644 --- a/PC_Mainboard/lib_krobot/krobot.ml +++ b/PC_Mainboard/lib_krobot/krobot.ml @@ -157,6 +157,14 @@ let jack krobot = React.S.map (fun ls -> ls.(15)) krobot.logic_sensors (* +-----------------------------------------------------------------+ + | Range finders | + +-----------------------------------------------------------------+ *) + +include MakeDevice(struct let name = "RangeFinders" end) + +OP_method GetCalibration : int -> int array + +(* +-----------------------------------------------------------------+ | AX12 | +-----------------------------------------------------------------+ *) diff --git a/PC_Mainboard/lib_krobot/krobot.mli b/PC_Mainboard/lib_krobot/krobot.mli index 6561470..86e6b08 100644 --- a/PC_Mainboard/lib_krobot/krobot.mli +++ b/PC_Mainboard/lib_krobot/krobot.mli @@ -51,6 +51,10 @@ val jack : t -> bool React.signal val range_finders : t -> int array React.signal (** Signal holding the current range finders state *) +val get_calibration : t -> int -> int array Lwt.t + (** [get_calibration krobot num] returns the calibration of the + given range finder. *) + (** {6 Manipulation of AX12s} *) val ax12_goto : t -> id : int -> pos : int -> speed : int -> unit Lwt.t hooks/post-receive -- krobot |