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 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 (** {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 -> error