ocaml-libusb/lib/libusb.mli
Matthieu Dubuget 1792a640a1 2018-06-15
* Ajout de claim_interface et release_interface
* Ajout de num_configurations dans descriptor
* Ajout de unref_devices
* Ajout de bulk_transfer
2018-06-15 08:30:45 +02:00

99 lines
3.2 KiB
OCaml

open Ctypes
include module type of T
(** {1 Errors} *)
val string_of_error: error -> string
val description_of_error: error -> string
(** {1 Flags} *)
val request_type_standard: int
val request_type_class: int
val request_type_vendor: int
val request_type_reserved: int
val endpoint_direction_in: int
val endpoint_direction_out: int
val recipient_device: int
val recipient_interface: int
val recipient_endpoint: int
val recipient_other: int
(** {1 Initialisation} *)
val init_libusb: unit -> (unit, error) result
(** This function must be called before calling any other libusb function. *)
val exit_libusb: unit -> unit
(** Should be called after closing all open devices and before your application terminates. *)
val get_version: unit -> version
(** @return the version of the running libusb library *)
(** {1 Devices enumeration} *)
type device
(** A C pointer to a device *)
val get_device_list: unit -> (device list, error) result
(** @return a list of C pointers to libusb devices.
Each device returned in the list has it's reference counter set to 1. Do not
forget to {!Libusb.unref_device} each of them after use. *)
val unref_device: device -> unit
(** Decrement the reference count of a device.
If the decrement operation causes the reference count to reach zero, the
device shall be destroyed. *)
val unref_devices: device list -> unit
(** [unref_device == List.iter unref_device] *)
val is_vendor: int -> device -> bool
(** [is_vendor vend d] checks if device [d] vendor id is [vend] *)
val is_product: int -> device -> bool
(** [is_product prod d] checks if device [d] product id is [prod] *)
val filter_devices: (device -> bool) -> device list -> device list
(** [filter_devices f dl] filters [dl] devices list using [f].
The devices of [dl] which are not part of the returned list are
unreferenced with {!Libusb.unref_device}. *)
(** {1 Device opening} *)
type device_handle
(** A opaque type to manipulate opened devices *)
val open_device: ?unref:bool -> device -> (device_handle, error) result
(** Opens the device.
The C libusb library device opening increments the device reference count.
If the operation is successfull, and if [unref] is true (which is it's
default value) {!Libusb.open_device} decrements the device reference counter
of the device: this allows the device to be destroyed automatically when
{!Libusb.close_device} will be called. *)
val close_device: device_handle -> unit
(** Closes the device. This operation decrements the reference counter. *)
val get_device_descriptor: device -> (device_descriptor, error) result
val get_string_descriptor: device_handle -> int -> (string, error) result
val claim_interface: device_handle -> int -> (unit, error) result
val release_interface: device_handle -> int -> (unit, error) result
(** {1 Transfers} *)
val control_transfer: device_handle:device_handle -> request_type:int -> request:int -> value:int -> index:int -> buffer:(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> timeout:int -> unit -> error
val bulk_transfer: device_handle:device_handle -> endpoint:int -> buffer:(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> timeout:int -> unit -> (int, error) result