package hidapi

  1. Overview
  2. Docs
Bindings to Signal11's hidapi library

Install

Dune Dependency

Authors

Maintainers

Sources

1.1.2.tar.gz
sha256=e3ff1966ed3204fa717f4660a6bb41371eea333e0e58cbc8ce4bfa4523d0c630
sha512=c4fb07399883c9aec562ce998d837543701f66ff049c92b5460e793e8250317221f6bd505811b0befd47e8671f8b07cf9d7cd09084d0b4b4ff9733461f96a30c

doc/hidapi/Hidapi/index.html

Module HidapiSource

Sourcetype device_info = {
  1. path : string;
  2. vendor_id : int;
  3. product_id : int;
  4. serial_number : string option;
  5. release_number : int;
  6. manufacturer_string : string option;
  7. product_string : string option;
  8. usage_page : int;
  9. usage : int;
  10. interface_number : int;
}
Sourcetype t
Sourceval init : unit -> unit

init () 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.

Sourceval deinit : unit -> unit

deinit () frees all of the static data associated with HIDAPI. It should be called at the end of execution to avoid memory leaks.

Sourceval enumerate : ?vendor_id:int -> ?product_id:int -> unit -> device_info list

enumerate ?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.

Sourceval open_id : vendor_id:int -> product_id:int -> t option

open_id ~vendor_id ~product_id is the device handle of HID device (vendor_id, product_id), or None if no such device exist or in case of error.

Sourceval open_path : string -> t option

open_path path is the device handle of HID device of path path, or None if no such device exist or in case of error. path can be discovered with enumerate or a platform-specific path name can be used (eg: /dev/hidraw0 on Linux).

Sourceval open_id_exn : vendor_id:int -> product_id:int -> t
Sourceval open_path_exn : string -> t
Sourceval write : t -> ?len:int -> Bigstring.t -> (int, string) result

write t buf is Ok nb_bytes_written on success, or Error description in case of error.

Sourceval read : ?timeout:int -> t -> Bigstring.t -> int -> (int, string) result

read ?timeout t buf len is Ok nb_bytes_read on success, or Error description in case of error.

Sourceval set_nonblocking : t -> bool -> (unit, string) result

set_nonblocking t v sets nonblocking mode if v is true, or sets blocking mode otherwise.

Sourceval set_nonblocking_exn : t -> bool -> unit
Sourceval close : t -> unit

close t closes the HID device t.

OCaml

Innovation. Community. Security.