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

Detailed Description

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.

See Also
https://github.com/OpenLightingProject/ja-rule

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.

Member Typedef Documentation

A command completion callback.

Template Parameters
Theresult of the command operation
Thereturn code from the device.
Thestatus flags.
Theresponse payload.

If the CommandResult is not COMMAND_COMPLETED_OK, the remaining values are undefined.

Member Enumeration Documentation

Indicates the eventual state of a Ja Rule command.

Various failures can occur at the libusb layer.

Enumerator:
COMMAND_COMPLETED_OK 

The command was sent and a response was received.

COMMAND_MALFORMED 

The command is malformed.

This could mean the payload is too big or a NULL pointer with a non-0 size was provided.

COMMAND_SEND_ERROR 

An error occured when trying to send the command.

COMMAND_QUEUE_FULL 

The command was not sent as the TX queue was full.

COMMAND_TIMEOUT 

The command was sent but no response was received.

COMMAND_CLASS_MISMATCH 

The command class returned did not match the request.

COMMAND_CANCELLED 

The command was cancelled.

Enumerator:
LOGS_PENDING_FLAG 

Log messages are pending.

FLAGS_CHANGED_FLAG 

Flags have changed.

MSG_TRUNCATED_FLAG 

The message has been truncated.

Constructor & Destructor Documentation

ola::plugin::usbdmx::JaRuleEndpoint::JaRuleEndpoint ( ola::thread::ExecutorInterface executor,
AsyncronousLibUsbAdaptor adaptor,
libusb_device *  device 
)

Create a new JaRuleEndpoint.

Parameters
executorThe Executor to run the command complete callbacks on.
adaptorThe LibUsbAdaptor to use.
devicethe underlying libusb device. Ownership is not transferred.

Member Function Documentation

bool ola::plugin::usbdmx::JaRuleEndpoint::Init ( )

Open the device and claim the USB interface.

Returns
true if the device was opened and claimed correctly, false otherwise.
void ola::plugin::usbdmx::JaRuleEndpoint::SendCommand ( CommandClass  command,
const uint8_t *  data,
unsigned int  size,
CommandCompleteCallback callback 
)

Send a command to the Device.

Parameters
commandthe Command type.
datathe payload data. The data is copied and can be freed once the method returns.
sizethe payload size.
callbackThe 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.


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