Open Lighting Architecture
0.9.6
|
Handles communication with a Ja Rule USB Endpoint. This class manages sending commands to the Ja Rule device. It builds the frame and handles the USB transfers required to send the command to the device and retrieve the response.
Classes | |
struct | CallbackArgs |
struct | PendingCommand |
struct | QueuedCommand |
Public Types | |
enum | StatusFlags { LOGS_PENDING_FLAG = 0x01, FLAGS_CHANGED_FLAG = 0x02, MSG_TRUNCATED_FLAG = 0x04 } |
enum | CommandResult { COMMAND_COMPLETED_OK, COMMAND_MALFORMED, COMMAND_SEND_ERROR, COMMAND_QUEUE_FULL, COMMAND_TIMEOUT, COMMAND_CLASS_MISMATCH, COMMAND_CANCELLED } |
Indicates the eventual state of a Ja Rule command. More... | |
enum | CommandClass { RESET_DEVICE = 0x00, SET_BREAK_TIME = 0x10, GET_BREAK_TIME = 0x11, SET_MAB_TIME = 0x12, GET_MAB_TIME = 0x13, SET_RDM_BROADCAST_LISTEN = 0x20, GET_RDM_BROADCAST_LISTEN = 0x21, SET_RDM_WAIT_TIME = 0x22, GET_RDM_WAIT_TIME = 0x23, TX_DMX = 0x30, RDM_DUB = 0x40, RDM_REQUEST = 0x41, RDM_BROADCAST_REQUEST = 0x42, ECHO_COMMAND = 0xf0, GET_LOG = 0xf1, GET_FLAGS = 0xf2, WRITE_LOG = 0xf3 } |
The Ja Rule commands. | |
typedef ola::BaseCallback4 < void, CommandResult, uint8_t, uint8_t, const ola::io::ByteString & > | CommandCompleteCallback |
A command completion callback. |
Public Member Functions | |
JaRuleEndpoint (ola::thread::ExecutorInterface *executor, AsyncronousLibUsbAdaptor *adaptor, libusb_device *device) | |
Create a new JaRuleEndpoint. | |
~JaRuleEndpoint () | |
Destructor. | |
bool | Init () |
Open the device and claim the USB interface. | |
void | CancelAll () |
Cancel all queued and inflight commands. This will immediately run all CommandCompleteCallbacks with the COMMAND_CANCELLED code. | |
void | SendCommand (CommandClass command, const uint8_t *data, unsigned int size, CommandCompleteCallback *callback) |
Send a command to the Device. | |
void | _OutTransferComplete () |
Called by the libusb callback when the transfer completes or is cancelled. | |
void | _InTransferComplete () |
Called by the libusb callback when the transfer completes or is cancelled. |
typedef ola::BaseCallback4< void, CommandResult, uint8_t, uint8_t, const ola::io::ByteString&> ola::plugin::usbdmx::JaRuleEndpoint::CommandCompleteCallback |
A command completion callback.
The | result of the command operation |
The | return code from the device. |
The | status flags. |
The | response payload. |
If the CommandResult is not COMMAND_COMPLETED_OK, the remaining values are undefined.
Indicates the eventual state of a Ja Rule command.
Various failures can occur at the libusb layer.
ola::plugin::usbdmx::JaRuleEndpoint::JaRuleEndpoint | ( | ola::thread::ExecutorInterface * | executor, |
AsyncronousLibUsbAdaptor * | adaptor, | ||
libusb_device * | device | ||
) |
Create a new JaRuleEndpoint.
executor | The Executor to run the command complete callbacks on. |
adaptor | The LibUsbAdaptor to use. |
device | the underlying libusb device. Ownership is not transferred. |
bool ola::plugin::usbdmx::JaRuleEndpoint::Init | ( | ) |
Open the device and claim the USB interface.
void ola::plugin::usbdmx::JaRuleEndpoint::SendCommand | ( | CommandClass | command, |
const uint8_t * | data, | ||
unsigned int | size, | ||
CommandCompleteCallback * | callback | ||
) |
Send a command to the Device.
command | the Command type. |
data | the payload data. The data is copied and can be freed once the method returns. |
size | the payload size. |
callback | The callback to run when the message operation completes. This may be run immediately in some conditions. |
SendMessage can be called from any thread, and messages will be queued.