21 #ifndef LIBS_USB_JARULEWIDGETPORT_H_
22 #define LIBS_USB_JARULEWIDGETPORT_H_
26 #include <ola/io/ByteString.h>
27 #include <ola/thread/ExecutorInterface.h>
28 #include <ola/thread/Mutex.h>
29 #include <ola/util/SequenceNumber.h>
34 #include "libs/usb/JaRulePortHandle.h"
35 #include "libs/usb/LibUsbAdaptor.h"
36 #include "libs/usb/JaRuleWidget.h"
60 libusb_device_handle *usb_handle,
61 uint8_t endpoint_number,
63 uint8_t physical_port);
120 enum { IN_BUFFER_SIZE = 1024 };
121 enum { OUT_BUFFER_SIZE = 1024 };
127 uint8_t status_flags;
131 class PendingCommand {
147 typedef std::map<uint8_t, PendingCommand*> PendingCommandMap;
148 typedef std::queue<PendingCommand*> CommandQueue;
153 libusb_device_handle*
const m_usb_handle;
154 const uint8_t m_endpoint_number;
156 const uint8_t m_physical_port;
162 CommandQueue m_queued_commands;
163 PendingCommandMap m_pending_commands;
165 libusb_transfer *m_out_transfer;
166 bool m_out_in_progress;
168 uint8_t m_in_buffer[IN_BUFFER_SIZE];
169 libusb_transfer *m_in_transfer;
170 bool m_in_in_progress;
172 void MaybeSendCommand();
173 bool SubmitInTransfer();
174 void HandleResponse(
const uint8_t *data,
180 uint8_t status_flags,
185 static const uint8_t EOF_IDENTIFIER = 0xa5;
186 static const uint8_t SOF_IDENTIFIER = 0x5a;
187 static const unsigned int MAX_PAYLOAD_SIZE = 513;
188 static const unsigned int MIN_RESPONSE_SIZE = 9;
189 static const unsigned int USB_PACKET_SIZE = 64;
190 static const unsigned int MAX_IN_FLIGHT = 2;
191 static const unsigned int MAX_QUEUED_MESSAGES = 10;
193 static const unsigned int ENDPOINT_TIMEOUT_MS = 1000;
199 #endif // LIBS_USB_JARULEWIDGETPORT_H_
USBCommandResult
Indicates the eventual state of a Ja Rule command.
Definition: JaRuleConstants.h:53
Represents a DMX/RDM port on a Ja Rule device.
Definition: JaRulePortHandle.h:41
CommandClass
The Ja Rule command set.
Definition: JaRuleConstants.h:101
Defer execution of a callback.
Definition: ExecutorInterface.h:35
JaRuleReturnCode
JaRule command return codes.
Definition: JaRuleConstants.h:133
The base class for all 4 argument callbacks.
Definition: Callback.h:3811
Used to get the current time.
Definition: Clock.h:221
Represents a RDM UID.
Definition: UID.h:57
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
std::basic_string< uint8_t > ByteString
A contiguous block of uint8_t data.
Definition: ByteString.h:40
Wraps calls to libusb so we can test the code.
Definition: LibUsbAdaptor.h:36