Open Lighting Architecture: ola::plugin::usbdmx::AsyncUsbReceiver Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
ola::plugin::usbdmx::AsyncUsbReceiver Class Referenceabstract

## Detailed Description

A base class that receives DMX data asynchronously from a libusb_device.

This encapsulates much of the asynchronous libusb logic. Subclasses should implement the SetupHandle() and PerformTransfer() methods.

Inheritance diagram for ola::plugin::usbdmx::AsyncUsbReceiver:

## Public Member Functions
| AsyncUsbReceiver (ola::usb::LibUsbAdaptor *const adaptor, libusb_device *usb_device, PluginAdaptor *plugin_adaptor)
| Create a new AsyncUsbReceiver.
virtual | ~AsyncUsbReceiver ()
| Destructor.
bool | Init ()
| Initialize the receiver.
bool | Init (libusb_device_handle *handle)
| Initialize the receiver with an already setup handle.
bool | Start ()
| Start receiving DMX.
void | SetReceiveCallback (Callback0< void > *callback)
| Set the callback to be called when the receive buffer is updated.
void | GetDmx (DmxBuffer *buffer)
| Get DMX Buffer.
void | TransferComplete (struct libusb_transfer *transfer)
| Called from the libusb callback when the asynchronous transfer completes.
Public Member Functions inherited from ola::plugin::usbdmx::AsyncUsbTransceiverBase
| AsyncUsbTransceiverBase (ola::usb::LibUsbAdaptor *const adaptor, libusb_device *usb_device)
| Create a new AsyncUsbTransceiverBase.
virtual | ~AsyncUsbTransceiverBase ()
| Destructor.
bool | Init ()
| Initialize the transceiver.
libusb_device_handle * | GetHandle ()
| Get the libusb_device_handle of an already opened widget.

## Protected Member Functions
virtual bool | PerformTransfer ()=0
| Start the request of data from the widget.
virtual bool | TransferCompleted (DmxBuffer *buffer, int transferred_size)=0
| Called when the transfer completes.
Protected Member Functions inherited from ola::plugin::usbdmx::AsyncUsbTransceiverBase
virtual libusb_device_handle * | SetupHandle ()=0
| Open the device handle.
virtual void | PostTransferHook ()
| Called when the transfer completes.
void | CancelTransfer ()
| Cancel any pending transfers.
void | FillControlTransfer (unsigned char *buffer, unsigned int timeout)
| Fill a control transfer.
void | FillBulkTransfer (unsigned char endpoint, unsigned char *buffer, int length, unsigned int timeout)
| Fill a bulk transfer.
void | FillInterruptTransfer (unsigned char endpoint, unsigned char *buffer, int length, unsigned int timeout)
| Fill an interrupt transfer.
int | SubmitTransfer ()
| Submit the transfer for tx.

## Additional Inherited Members
Protected Types inherited from ola::plugin::usbdmx::AsyncUsbTransceiverBase
enum | TransferState { IDLE , IN_PROGRESS , DISCONNECTED }
Protected Attributes inherited from ola::plugin::usbdmx::AsyncUsbTransceiverBase
ola::usb::LibUsbAdaptor *const | m_adaptor
| The LibUsbAdaptor passed in the constructor.
libusb_device *const | m_usb_device
| The libusb_device passed in the constructor.
libusb_device_handle * | m_usb_handle
bool | m_suppress_continuation
struct libusb_transfer * | m_transfer
TransferState | m_transfer_state
ola::thread::Mutex | m_mutex

## Constructor & Destructor Documentation

## ◆ AsyncUsbReceiver()

ola::plugin::usbdmx::AsyncUsbReceiver::AsyncUsbReceiver | ( | ola::usb::LibUsbAdaptor *const | adaptor,
|  | libusb_device * | usb_device,
|  | PluginAdaptor * | plugin_adaptor )

Create a new AsyncUsbReceiver.

Parameters

  adaptor | the LibUsbAdaptor to use.
  usb_device | the libusb_device to use for the widget.
  plugin_adaptor | the PluginAdaptor to use for the widget.

## Member Function Documentation

## ◆ GetDmx()

void ola::plugin::usbdmx::AsyncUsbReceiver::GetDmx | ( | DmxBuffer * | buffer | ) |
| inline

Get DMX Buffer.

Parameters

  buffer | DmxBuffer that will get updated with the current input.

## ◆ Init() [1/2]

bool ola::plugin::usbdmx::AsyncUsbReceiver::Init | ( |  | ) |

Initialize the receiver.

Returns
  true if SetupHandle() returned a valid handle, false otherwise.

## ◆ Init() [2/2]

bool ola::plugin::usbdmx::AsyncUsbReceiver::Init | ( | libusb_device_handle * | handle | ) |

Initialize the receiver with an already setup handle.

Parameters

  handle | the handle returned by a previous SetupHandle() call

Returns
  true

## ◆ PerformTransfer()

virtual bool ola::plugin::usbdmx::AsyncUsbReceiver::PerformTransfer | ( |  | ) |
| protectedpure virtual

Start the request of data from the widget.

Returns
  true if the transfer was scheduled, false otherwise.

This method is implemented by the subclass. The subclass should call FillControlTransfer() / FillBulkTransfer() as appropriate and then call SubmitTransfer().

Implemented in ola::plugin::usbdmx::DMXCProjectsNodleU1AsyncUsbReceiver.

## ◆ SetReceiveCallback()

void ola::plugin::usbdmx::AsyncUsbReceiver::SetReceiveCallback | ( | Callback0< void > * | callback | ) |
| inline

Set the callback to be called when the receive buffer is updated.

Parameters

  callback | The callback to call.

## ◆ Start()

bool ola::plugin::usbdmx::AsyncUsbReceiver::Start | ( |  | ) |

Start receiving DMX.

Returns
  the value of PerformTransfer().

## ◆ TransferComplete()

void ola::plugin::usbdmx::AsyncUsbReceiver::TransferComplete | ( | struct libusb_transfer * | transfer | ) |
| virtual

Called from the libusb callback when the asynchronous transfer completes.

Parameters

  transfer | the completed transfer.

Implements ola::plugin::usbdmx::AsyncUsbTransceiverBase.

## ◆ TransferCompleted()

virtual bool ola::plugin::usbdmx::AsyncUsbReceiver::TransferCompleted | ( | DmxBuffer * | buffer,
|  | int | transferred_size )
| protectedpure virtual

Called when the transfer completes.

Parameters

  buffer | the DmxBuffer to receive into
  transferred_size | the number of bytes actually transferred returns true if the buffer was updated

Implemented in ola::plugin::usbdmx::DMXCProjectsNodleU1AsyncUsbReceiver.

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

- plugins/usbdmx/AsyncUsbReceiver.h
- plugins/usbdmx/AsyncUsbReceiver.cpp