Module Hidapi
type device_info={}type t
val init : unit -> unitinit ()initializes the HIDAPI library. Calling it is not strictly necessary, however this function should be called at the beginning of execution however, if there is a chance of HIDAPI handles being opened by different threads simultaneously.
val deinit : unit -> unitdeinit ()frees all of the static data associated with HIDAPI. It should be called at the end of execution to avoid memory leaks.
val enumerate : ?vendor_id:int -> ?product_id:int -> unit -> device_info listenumerate ?vendor_id ?product_id ()is the list of HID devices attached to the system. The optional arguments are a way to filter the results returned.
val open_id : vendor_id:int -> product_id:int -> t optionopen_id ~vendor_id ~product_idis the device handle of HID device (vendor_id, product_id), or None if no such device exist or in case of error.
val open_path : string -> t optionopen_path pathis the device handle of HID device of pathpath, or None if no such device exist or in case of error.pathcan be discovered withenumerateor a platform-specific path name can be used (eg: /dev/hidraw0 on Linux).
val open_id_exn : vendor_id:int -> product_id:int -> tval open_path_exn : string -> tval write : t -> ?len:int -> Bigstring.t -> (int, string) Pervasives.resultwrite t bufisOk nb_bytes_writtenon success, orError descriptionin case of error.
val read : ?timeout:int -> t -> Bigstring.t -> int -> (int, string) Pervasives.resultread ?timeout t buf lenisOk nb_bytes_readon success, orError descriptionin case of error.
val set_nonblocking : t -> bool -> (unit, string) Pervasives.resultset_nonblocking t vsets nonblocking mode ifvistrue, or sets blocking mode otherwise.