Open Lighting Architecture  0.9.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
ola::plugin::usbdmx::AsyncronousLibUsbAdaptor Class Reference

Detailed Description

A LibUsbAdaptor for use with Asyncronous widgets.

Asyncronous mode requires notifying the LibUsbThread when handles are opened and closed.

Inheritance diagram for ola::plugin::usbdmx::AsyncronousLibUsbAdaptor:
Inheritance graph
[legend]
Collaboration diagram for ola::plugin::usbdmx::AsyncronousLibUsbAdaptor:
Collaboration graph
[legend]

Public Member Functions

 AsyncronousLibUsbAdaptor (class LibUsbThread *thread)
bool OpenDevice (libusb_device *usb_device, libusb_device_handle **usb_handle)
 Open a libusb device.
bool OpenDeviceAndClaimInterface (libusb_device *usb_device, int interface, libusb_device_handle **usb_handle)
 Open a libusb device and claim an interface.
void Close (libusb_device_handle *usb_handle)
 Close a libusb handle.
int ControlTransfer (libusb_device_handle *dev_handle, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, unsigned int timeout)
 Wraps libusb_control_transfer().
int BulkTransfer (struct libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *transferred, unsigned int timeout)
 Wraps libusb_bulk_transfer.
int InterruptTransfer (libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout)
 Wraps libusb_interrupt_transfer.
- Public Member Functions inherited from ola::plugin::usbdmx::BaseLibUsbAdaptor
libusb_device * RefDevice (libusb_device *dev)
 Wraps libusb_ref_device.
void UnrefDevice (libusb_device *dev)
 Wraps libusb_unref_device.
int SetConfiguration (libusb_device_handle *dev, int configuration)
 Wraps libusb_set_configuration.
int ClaimInterface (libusb_device_handle *dev, int interface_number)
 Wraps libusb_claim_interface.
int DetachKernelDriver (libusb_device_handle *dev, int interface_number)
 Detatch a kernel driver.
int GetActiveConfigDescriptor (libusb_device *dev, struct libusb_config_descriptor **config)
 Wraps libusb_get_active_config_descriptor.
int GetConfigDescriptor (libusb_device *dev, uint8_t config_index, struct libusb_config_descriptor **config)
 Wraps libusb_get_config_descriptor.
void FreeConfigDescriptor (struct libusb_config_descriptor *config)
 Wraps busb_free_config_descriptor.
struct libusb_transfer * AllocTransfer (int iso_packets)
 Wraps libusb_alloc_transfer.
void FreeTransfer (struct libusb_transfer *transfer)
 Wraps libusb_free_transfer.
int SubmitTransfer (struct libusb_transfer *transfer)
 Wraps libusb_submit_transfer.
int CancelTransfer (struct libusb_transfer *transfer)
 Wraps libusb_cancel_transfer.
void FillControlSetup (unsigned char *buffer, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength)
 Wraps libusb_fill_control_setup.
void FillControlTransfer (struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
 Wraps libusb_fill_control_transfer.
void FillBulkTransfer (struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *buffer, int length, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
 Wraps libusb_fill_bulk_transfer.
void FillInterruptTransfer (struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *buffer, int length, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
 Wraps libusb_fill_interrupt_transfer.

Additional Inherited Members

- Static Public Member Functions inherited from ola::plugin::usbdmx::LibUsbAdaptor
static bool GetDeviceInfo (struct libusb_device *usb_device, const struct libusb_device_descriptor &device_descriptor, DeviceInformation *device_info)
 Fetch the manufacturer, product and serial strings from a device.
static bool CheckManufacturer (const std::string &expected, const DeviceInformation &device_info)
 Check if the manufacturer string matches the expected value.
static bool CheckProduct (const std::string &expected, const DeviceInformation &device_info)
 Check if the product string matches the expected value.
static std::string ErrorCodeToString (const int error_code)
 Try and convert an error code to a string.

Member Function Documentation

int ola::plugin::usbdmx::AsyncronousLibUsbAdaptor::BulkTransfer ( struct libusb_device_handle *  dev_handle,
unsigned char  endpoint,
unsigned char *  data,
int  length,
int *  transferred,
unsigned int  timeout 
)
virtual

Wraps libusb_bulk_transfer.

Returns
0 on success and populates transferred
LIBUSB_ERROR_TIMEOUT if the transfer timed out (and populates transferred)
LIBUSB_ERROR_PIPE if the endpoint halted
LIBUSB_ERROR_OVERFLOW if the device offered more data, see
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
another LIBUSB_ERROR code on other failures

Reimplemented from ola::plugin::usbdmx::BaseLibUsbAdaptor.

void ola::plugin::usbdmx::AsyncronousLibUsbAdaptor::Close ( libusb_device_handle *  usb_handle)
virtual

Close a libusb handle.

Parameters
usb_handlethe handle to close.

Implements ola::plugin::usbdmx::LibUsbAdaptor.

int ola::plugin::usbdmx::AsyncronousLibUsbAdaptor::ControlTransfer ( libusb_device_handle *  dev_handle,
uint8_t  bmRequestType,
uint8_t  bRequest,
uint16_t  wValue,
uint16_t  wIndex,
unsigned char *  data,
uint16_t  wLength,
unsigned int  timeout 
)
virtual

Wraps libusb_control_transfer().

Parameters
dev_handlea handle for the device to communicate with
bmRequestTypethe request type field for the setup packet
bRequestthe request field for the setup packet
wValuethe value field for the setup packet
wIndexthe index field for the setup packet
[in,out]dataa suitably-sized data buffer for either input or output (depending on direction bits within bmRequestType)
wLengththe length field for the setup packet. The data buffer should be at least this size.
timeouttimeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use value 0.
Returns
on success, the number of bytes actually transferred

Reimplemented from ola::plugin::usbdmx::BaseLibUsbAdaptor.

int ola::plugin::usbdmx::AsyncronousLibUsbAdaptor::InterruptTransfer ( libusb_device_handle *  dev_handle,
unsigned char  endpoint,
unsigned char *  data,
int  length,
int *  actual_length,
unsigned int  timeout 
)
virtual

Wraps libusb_interrupt_transfer.

Returns
0 on success and populates transferred
LIBUSB_ERROR_TIMEOUT if the transfer timed out
LIBUSB_ERROR_PIPE if the endpoint halted
LIBUSB_ERROR_OVERFLOW if the device offered more data, see
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
another LIBUSB_ERROR code on other error

Reimplemented from ola::plugin::usbdmx::BaseLibUsbAdaptor.

bool ola::plugin::usbdmx::AsyncronousLibUsbAdaptor::OpenDevice ( libusb_device *  usb_device,
libusb_device_handle **  usb_handle 
)
virtual

Open a libusb device.

Parameters
usb_deviceThe usb device to open.
[out]usb_handlethe new device handle.
Returns
true if the device was opened, false otherwise.

Implements ola::plugin::usbdmx::LibUsbAdaptor.

bool ola::plugin::usbdmx::AsyncronousLibUsbAdaptor::OpenDeviceAndClaimInterface ( libusb_device *  usb_device,
int  interface,
libusb_device_handle **  usb_handle 
)
virtual

Open a libusb device and claim an interface.

Parameters
usb_deviceThe usb device to open.
interfacethe interface index to claim.
[out]usb_handlethe new device handle.
Returns
true if the device was opened and the interface claimed, false otherwise.

Implements ola::plugin::usbdmx::LibUsbAdaptor.


The documentation for this class was generated from the following files: