Module Usb
module Usb: sig end
Ocaml binding to libusb
type
size_t = int
type
usb_device_descriptor = {
|
bLength : int ; |
|
bDescriptorType : int ; |
|
bcdUSB : int ; |
|
bDeviceClass : int ; |
|
bDeviceSubClass : int ; |
|
bDeviceProtocol : int ; |
|
bMaxPacketSize0 : int ; |
|
idVendor : int ; |
|
idProduct : int ; |
|
bcdDevice : int ; |
|
iManufacturer : int ; |
|
iProduct : int ; |
|
iSerialNumber : int ; |
|
bNumConfigurations : int ; |
}
type
usb_endpoint_descriptor = {
|
bLength : int ; |
|
bDescriptorType : int ; |
|
bEndpointAddress : int ; |
|
bmAttributes : int ; |
|
wMaxPacketSize : int ; |
|
bInterval : int ; |
|
bRefresh : int ; |
|
bSynchAddress : int ; |
|
extra : char array ; |
}
type
usb_interface_descriptor = {
|
bLength : int ; |
|
bDescriptorType : int ; |
|
bInterfaceNumber : int ; |
|
bAlternateSetting : int ; |
|
bInterfaceClass : int ; |
|
bInterfaceSubClass : int ; |
|
bInterfaceProtocol : int ; |
|
iInterface : int ; |
|
endpoint : usb_endpoint_descriptor array ; |
|
extra : char array ; |
}
type
usb_interface = {
}
type
usb_config_descriptor = {
|
bLength : int ; |
|
bDescriptorType : int ; |
|
wTotalLength : int ; |
|
bNumInterfaces : int ; |
|
bConfigurationValue : int ; |
|
iConfiguration : int ; |
|
bmAttributes : int ; |
|
maxPower : int ; |
|
interf : usb_interface ; |
|
extra : char array ; |
}
type
usb_bus
type
usb_dev_handle
type
usb_device
val is_null : 'a Com.opaque -> bool
Test if a value, opaque in Ocaml, is NULL in C
These are just utility accessor functions, not present in libusb, needed to generate camlusb without having to define structs in the IDL
usb_bus related accessor functions
val usb_bus_prev : usb_bus Com.opaque -> usb_bus Com.opaque
Returns the previous bus in the usb_bus struct
val usb_bus_next : usb_bus Com.opaque -> usb_bus Com.opaque
Returns the next bus in the usb_bus struct
val usb_bus_dirname : usb_bus Com.opaque -> string
Returns the dirname of bus in the usb_bus struct
val usb_bus_devices : usb_bus Com.opaque -> usb_device Com.opaque
Returns the struct usb_device of bus in the usb_bus struct
usb_device related accessor functions
val usb_device_prev : usb_device Com.opaque -> usb_device Com.opaque
Returns the previous device in the usb_device struct
val usb_device_next : usb_device Com.opaque -> usb_device Com.opaque
Returns the next device in the usb_device struct
val usb_device_filename : usb_device Com.opaque -> string
Returns the filename of the device in the usb_device struct
val usb_device_bus : usb_device Com.opaque -> usb_bus Com.opaque
Returns the bus of the device in the usb_device struct
val usb_device_descriptor : usb_device Com.opaque -> usb_device_descriptor
Returns the descriptor of the device in the usb_device struct
val usb_device_config : usb_device Com.opaque -> usb_config_descriptor
Returns the config of the device in the usb_device struct
tested functions
val usb_init : unit -> unit
val usb_find_busses : unit -> int
val usb_find_devices : unit -> int
val usb_get_busses : unit -> usb_bus Com.opaque
Returns the abstract type usb_bus. This function is meant to be used with the access functions:
FIXME: Differently from libusb, these functions return a pair made by the return value of the C function and the opaque input parameter, since I think that this input parameter is modified as a side effect.
tested functions
val usb_open : usb_device Com.opaque ->
usb_dev_handle Com.opaque * usb_device Com.opaque
In the C version this function can return NULL, in Ocaml, since it is opaque, you can testif it is null using the function
Usb.is_null
val usb_close : usb_dev_handle Com.opaque -> int * usb_dev_handle Com.opaque
val usb_claim_interface : usb_dev_handle Com.opaque -> int -> int * usb_dev_handle Com.opaque
untested functions
val usb_reset : usb_dev_handle Com.opaque -> int * usb_dev_handle Com.opaque
val usb_set_configuration : usb_dev_handle Com.opaque -> int -> int * usb_dev_handle Com.opaque
val usb_set_altinterface : usb_dev_handle Com.opaque -> int -> int * usb_dev_handle Com.opaque
val usb_resetep : usb_dev_handle Com.opaque -> int -> int * usb_dev_handle Com.opaque
val usb_clear_halt : usb_dev_handle Com.opaque -> int -> int * usb_dev_handle Com.opaque
val usb_release_interface : usb_dev_handle Com.opaque -> int -> int * usb_dev_handle Com.opaque
tested functions
val usb_control_msg : usb_dev_handle Com.opaque ->
int -> int -> int -> int -> int -> int -> int * int array
usb_control_msg handle requesttype request value index size timeout
,
differently from libusb, this function doesn't take the buffer as an input parameter but as an output parameter.
Returns the pair of the return value of the C function and the buffer (the bytes
parameter in the libusb documentation) of size size
untested funcrtions
val usb_get_string : usb_dev_handle Com.opaque -> int -> int -> size_t -> int * string
val usb_get_string_simple : usb_dev_handle Com.opaque -> int -> size_t -> int * string
FIXME: I'm not sure that the correct returned type value is string or int array
tested functions
val usb_bulk_write : usb_dev_handle Com.opaque -> int -> int array -> int -> int
val usb_bulk_read : usb_dev_handle Com.opaque -> int -> int -> int -> int * int array
usb_bulk_read handle ep size timeout
,
differently from libusb, this function doesn't take the buffer as an input parameter but as an output parameter.
Returns the pair of the return value of the C function and the buffer (the bytes
parameter in the libusb documentation) of size size