[248975]: PC_Mainboard / Apps / cards / dbus-drivers / card_interface.ml  Maximize  Restore  History

Download this file

39 lines (31 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(*
* card_interface.ml
* -----------------
* Copyright : (c) 2009, Jeremie Dimino <jeremie@dimino.org>
* Licence : BSD3
*
* This file is a part of [kro]bot.
*)
(* Driver for the interface Kard *)
open OBus_type.Perv
open Lwt
type card = {
card : Card.t;
obus : OBus_object.t;
}
module M = OBus_object.Make(struct
type obj = card
let get card = card.obus
end)
include M.MakeInterface(struct let name = "fr.krobot.Device.Compass" end)
OL_method GetCompas : int = fun card ->
let data = Card.make_buffer () in
lwt data = Card.send_request card.card Protocol.get_cmp03_data data in
return (RW.get_int16 data 2)
let () = Lwt_main.run begin
lwt card = Card.open_card ~product_id:Protocol.usb_vid ~vendor_id:Protocol.usb_pid_robot_interface and bus = Lazy.force OBus_bus.system in
let card = { card = card; obus = OBus_object.make [ "fr"; "krobot"; "Devices"; "Compass" ] } in
M.export bus card;
lwt _ = OBus_bus.request_name bus "fr.krobot.Device.Compass" in
fst (Lwt.wait ())
end

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks