Open Lighting Architecture
Latest Git
|
Wraps calls to libusb so we can test the code.
Classes | |
struct | DeviceInformation |
Public Member Functions | |
virtual libusb_device * | RefDevice (libusb_device *dev)=0 |
Wraps libusb_ref_device. More... | |
virtual void | UnrefDevice (libusb_device *dev)=0 |
Wraps libusb_unref_device. More... | |
virtual bool | OpenDevice (libusb_device *usb_device, libusb_device_handle **usb_handle)=0 |
Open a libusb device. More... | |
virtual bool | OpenDeviceAndClaimInterface (libusb_device *usb_device, int interface, libusb_device_handle **usb_handle)=0 |
Open a libusb device and claim an interface. More... | |
virtual void | Close (libusb_device_handle *usb_handle)=0 |
Close a libusb handle. More... | |
virtual int | SetConfiguration (libusb_device_handle *dev, int configuration)=0 |
Wraps libusb_set_configuration. More... | |
virtual int | ClaimInterface (libusb_device_handle *dev, int interface_number)=0 |
Wraps libusb_claim_interface. More... | |
virtual int | DetachKernelDriver (libusb_device_handle *dev, int interface_number)=0 |
Detach a kernel driver. More... | |
virtual int | GetDeviceDescriptor (libusb_device *dev, struct libusb_device_descriptor *descriptor)=0 |
Wraps libusb_get_device_descriptor. More... | |
virtual int | GetActiveConfigDescriptor (libusb_device *dev, struct libusb_config_descriptor **config)=0 |
Wraps libusb_get_active_config_descriptor. More... | |
virtual int | GetConfigDescriptor (libusb_device *dev, uint8_t config_index, struct libusb_config_descriptor **config)=0 |
Wraps libusb_get_config_descriptor. More... | |
virtual void | FreeConfigDescriptor (struct libusb_config_descriptor *config)=0 |
Wraps busb_free_config_descriptor. More... | |
virtual bool | GetStringDescriptor (libusb_device_handle *usb_handle, uint8_t descriptor_index, std::string *data)=0 |
Get the value of a string descriptor. More... | |
virtual struct libusb_transfer * | AllocTransfer (int iso_packets)=0 |
Wraps libusb_alloc_transfer. More... | |
virtual void | FreeTransfer (struct libusb_transfer *transfer)=0 |
Wraps libusb_free_transfer. More... | |
virtual int | SubmitTransfer (struct libusb_transfer *transfer)=0 |
Wraps libusb_submit_transfer. More... | |
virtual int | CancelTransfer (struct libusb_transfer *transfer)=0 |
Wraps libusb_cancel_transfer. More... | |
virtual void | FillControlSetup (unsigned char *buffer, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength)=0 |
Wraps libusb_fill_control_setup. More... | |
virtual 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)=0 |
Wraps libusb_fill_control_transfer. More... | |
virtual 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)=0 |
Wraps libusb_fill_bulk_transfer. More... | |
virtual 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)=0 |
Wraps libusb_fill_interrupt_transfer. More... | |
virtual 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)=0 |
Wraps libusb_control_transfer(). More... | |
virtual int | BulkTransfer (struct libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *transferred, unsigned int timeout)=0 |
Wraps libusb_bulk_transfer. More... | |
virtual int | InterruptTransfer (libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout)=0 |
Wraps libusb_interrupt_transfer. More... | |
virtual USBDeviceID | GetDeviceId (libusb_device *device) const =0 |
Get the USBDeviceID for a device. More... | |
Static Public Member Functions | |
static bool | Initialize (struct libusb_context **context) |
Initialize a new libusb context. More... | |
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. More... | |
static bool | CheckManufacturer (const std::string &expected, const DeviceInformation &device_info) |
Check if the manufacturer string matches the expected value. More... | |
static bool | CheckProduct (const std::string &expected, const DeviceInformation &device_info) |
Check if the product string matches the expected value. More... | |
static bool | HotplugSupported () |
Check if this platform supports hotplug. More... | |
static std::string | ErrorCodeToString (const int error_code) |
Try and convert an error code to a string. More... | |
|
pure virtual |
Wraps libusb_alloc_transfer.
iso_packets | number of isochronous packet descriptors to allocate |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps libusb_bulk_transfer.
transferred
transferred
) Implemented in ola::usb::AsynchronousLibUsbAdaptor, and ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps libusb_cancel_transfer.
transfer | the transfer to cancel |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
static |
Check if the manufacturer string matches the expected value.
expected | The expected manufacturer string. |
device_info | The DeviceInformation struct to check against. |
|
static |
Check if the product string matches the expected value.
expected | The expected product string. |
device_info | The DeviceInformation struct to check against. |
|
pure virtual |
Wraps libusb_claim_interface.
dev | a device handle |
interface_number | the bInterfaceNumber of the interface you wish to claim |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Close a libusb handle.
usb_handle | the handle to close. |
Implemented in ola::usb::AsynchronousLibUsbAdaptor, and ola::usb::SynchronousLibUsbAdaptor.
|
pure virtual |
Wraps libusb_control_transfer().
dev_handle | a handle for the device to communicate with | |
bmRequestType | the request type field for the setup packet | |
bRequest | the request field for the setup packet | |
wValue | the value field for the setup packet | |
wIndex | the index field for the setup packet | |
[in,out] | data | a suitably-sized data buffer for either input or output (depending on direction bits within bmRequestType) |
wLength | the length field for the setup packet. The data buffer should be at least this size. | |
timeout | timeout (in milliseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use value 0. |
Implemented in ola::usb::AsynchronousLibUsbAdaptor, and ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Detach a kernel driver.
dev | a device handle |
interface_number | the interface to detach the driver from |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
static |
Try and convert an error code to a string.
error_code | The error code. |
|
pure virtual |
Wraps libusb_fill_bulk_transfer.
[out] | transfer | the transfer to populate |
dev_handle | handle of the device that will handle the transfer | |
endpoint | address of the endpoint where this transfer will be sent | |
buffer | data buffer. If provided, this function will interpret the first 8 bytes as a setup packet and infer the transfer length from that. This pointer must be aligned to at least 2 bytes boundary. | |
length | length of data buffer | |
callback | callback function to be invoked on transfer completion | |
user_data | user data to pass to callback function | |
timeout | timeout for the transfer in milliseconds |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps libusb_fill_control_setup.
[out] | buffer | buffer to output the setup packet into This pointer must be aligned to at least 2 bytes boundary. |
bmRequestType | the request type field for the setup packet | |
bRequest | the request field for the setup packet | |
wValue | the value field for the setup packet | |
wIndex | the index field for the setup packet | |
wLength | the length field for the setup packet. The data buffer should be at least this size. |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps libusb_fill_control_transfer.
[out] | transfer | the transfer to populate |
dev_handle | handle of the device that will handle the transfer | |
buffer | data buffer. If provided, this function will interpret the first 8 bytes as a setup packet and infer the transfer length from that. This pointer must be aligned to at least 2 bytes boundary. | |
callback | callback function to be invoked on transfer completion | |
user_data | user data to pass to callback function | |
timeout | timeout for the transfer in milliseconds |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps libusb_fill_interrupt_transfer.
[out] | transfer | the transfer to populate |
dev_handle | handle of the device that will handle the transfer | |
endpoint | address of the endpoint where this transfer will be sent | |
buffer | data buffer | |
length | length of data buffer | |
callback | callback function to be invoked on transfer completion | |
user_data | user data to pass to callback function | |
timeout | timeout for the transfer in milliseconds |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps busb_free_config_descriptor.
config | the configuration descriptor to free |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps libusb_free_transfer.
transfer | the transfer to free |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps libusb_get_active_config_descriptor.
dev | a device | |
[out] | config | output location for the USB configuration descriptor. Only valid if 0 was returned. Must be freed with libusb_free_config_descriptor() after use. |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps libusb_get_config_descriptor.
dev | a device | |
config_index | the index of the configuration you wish to retrieve | |
[out] | config | output location for the USB configuration descriptor. Only valid if 0 was returned. Must be freed with libusb_free_config_descriptor() after use. |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps libusb_get_device_descriptor.
dev | a device | |
[out] | descriptor | The device descriptor. |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Get the USBDeviceID for a device.
device | The libusb device to get the ID of. |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
static |
Fetch the manufacturer, product and serial strings from a device.
usb_device | The USB device to get information for. | |
device_descriptor | The descriptor to use | |
[out] | device_info | The DeviceInformation struct to populate. |
|
pure virtual |
Get the value of a string descriptor.
usb_handle | The USB device handle | |
descriptor_index | The index of the string descriptor to fetch. | |
[out] | data | The value of the string descriptor. |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
static |
Check if this platform supports hotplug.
|
static |
Initialize a new libusb context.
context | A pointer to a libusb context. |
|
pure virtual |
Wraps libusb_interrupt_transfer.
transferred
Implemented in ola::usb::AsynchronousLibUsbAdaptor, and ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Open a libusb device.
usb_device | The usb device to open. | |
[out] | usb_handle | the new device handle. |
Implemented in ola::usb::AsynchronousLibUsbAdaptor, and ola::usb::SynchronousLibUsbAdaptor.
|
pure virtual |
Open a libusb device and claim an interface.
usb_device | The usb device to open. | |
interface | the interface index to claim. | |
[out] | usb_handle | the new device handle. |
Implemented in ola::usb::AsynchronousLibUsbAdaptor, and ola::usb::SynchronousLibUsbAdaptor.
|
pure virtual |
Wraps libusb_ref_device.
dev | the device to reference |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps libusb_set_configuration.
dev | a device handle |
configuration | the bConfigurationValue of the configuration you wish to activate, or -1 if you wish to put the device in an unconfigured state. |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps libusb_submit_transfer.
transfer | the transfer to submit |
Implemented in ola::usb::BaseLibUsbAdaptor.
|
pure virtual |
Wraps libusb_unref_device.
dev | the device to unreference. |
Implemented in ola::usb::BaseLibUsbAdaptor.