21 #ifndef PLUGINS_USBPRO_DMXTRIWIDGET_H_
22 #define PLUGINS_USBPRO_DMXTRIWIDGET_H_
32 #include "ola/thread/SchedulerInterface.h"
33 #include "plugins/usbpro/BaseUsbProWidget.h"
51 void UseRawRDM(
bool use_raw_rdm) { m_use_raw_rdm = use_raw_rdm; }
63 SINGLE_TX_COMMAND_ID = 0x21,
64 DISCOVER_AUTO_COMMAND_ID = 0x33,
65 DISCOVER_STATUS_COMMAND_ID = 0x34,
66 REMOTE_UID_COMMAND_ID = 0x35,
67 RAW_RDM_COMMAND_ID = 0x37,
68 REMOTE_GET_COMMAND_ID = 0x38,
69 REMOTE_SET_COMMAND_ID = 0x39,
70 QUEUED_GET_COMMAND_ID = 0x3a,
71 SET_FILTER_COMMAND_ID = 0x3d,
73 RESERVED_COMMAND_ID = 0xff,
78 DISCOVER_AUTO_REQUIRED,
79 DISCOVER_STATUS_REQUIRED,
83 typedef std::map<ola::rdm::UID, uint8_t> UIDToIndexMap;
86 UIDToIndexMap m_uid_index_map;
88 uint16_t m_last_esta_id;
97 TriDiscoveryState m_discovery_state;
103 std::auto_ptr<ola::rdm::RDMRequest> m_pending_rdm_request;
104 uint8_t m_transaction_number;
106 uint8_t m_last_command, m_expected_command;
108 void SendDMXBuffer();
109 void SendQueuedRDMCommand();
111 bool CheckDiscoveryStatus();
112 void HandleMessage(uint8_t label,
114 unsigned int length);
115 void SendDiscoveryAuto();
116 void SendDiscoveryStat();
118 void SendRawRDMRequest();
119 void DispatchRequest();
120 void DispatchQueuedGet();
121 void StopDiscovery();
123 void HandleSingleTXResponse(uint8_t return_code);
124 void HandleDiscoveryAutoResponse(uint8_t return_code,
126 unsigned int length);
127 void HandleDiscoverStatResponse(uint8_t return_code,
129 unsigned int length);
130 void HandleRemoteUIDResponse(uint8_t return_code,
132 unsigned int length);
133 void HandleRawRDMResponse(uint8_t return_code,
135 unsigned int length);
136 void HandleRemoteRDMResponse(uint8_t return_code,
138 unsigned int length);
139 void HandleQueuedGetResponse(uint8_t return_code,
141 unsigned int length);
142 void HandleGenericRDMResponse(uint8_t return_code,
145 unsigned int length);
146 void HandleSetFilterResponse(uint8_t return_code,
148 unsigned int length);
149 bool PendingTransaction()
const;
150 void MaybeSendNextRequest();
151 void HandleRDMError(ola::rdm::RDMStatusCode error_code);
152 bool SendCommandToTRI(uint8_t label,
const uint8_t *data,
153 unsigned int length);
154 bool TriToOlaReturnCode(uint8_t return_code,
155 ola::rdm::RDMStatusCode *code);
156 bool ReturnCodeToNackReason(uint8_t return_code,
157 ola::rdm::rdm_nack_reason *reason);
162 EC_UNKNOWN_COMMAND = 2,
163 EC_INVALID_OPTION = 3,
165 EC_DATA_TOO_LONG = 5,
169 EC_DATA_CHECKSUM = 0x0a,
170 EC_INCOMPATIBLE = 0x0b,
171 EC_RESPONSE_TIME = 0x10,
172 EC_RESPONSE_WAIT = 0x11,
173 EC_RESPONSE_MORE = 0x12,
174 EC_RESPONSE_TRANSACTION = 0x13,
175 EC_RESPONSE_SUB_DEVICE = 0x14,
176 EC_RESPONSE_FORMAT = 0x15,
177 EC_RESPONSE_CHECKSUM = 0x16,
178 EC_RESPONSE_NONE = 0x18,
179 EC_RESPONSE_IDENTITY = 0x1a,
180 EC_RESPONSE_MUTE = 0x1b,
181 EC_RESPONSE_DISCOVERY = 0x1c,
182 EC_RESPONSE_UNEXPECTED = 0x1d,
183 EC_UNKNOWN_PID = 0x20,
184 EC_FORMAT_ERROR = 0x21,
185 EC_HARDWARE_FAULT = 0x22,
186 EC_PROXY_REJECT = 0x23,
187 EC_WRITE_PROTECT = 0x24,
188 EC_UNSUPPORTED_COMMAND_CLASS = 0x25,
189 EC_OUT_OF_RANGE = 0x26,
190 EC_BUFFER_FULL = 0x27,
191 EC_FRAME_OVERFLOW = 0x28,
192 EC_SUBDEVICE_UNKNOWN = 0x29,
193 EC_PROXY_BUFFER_FULL = 0x2a,
194 } dmx_tri_error_codes;
196 static const unsigned int DATA_OFFSET = 2;
197 static const uint8_t EXTENDED_COMMAND_LABEL = 88;
200 static const unsigned int RDM_STATUS_INTERVAL_MS = 100;
212 unsigned int queue_size = 20,
213 bool use_raw_rdm =
false);
215 void UseRawRDM(
bool use_raw_rdm) { m_impl->UseRawRDM(use_raw_rdm); }
217 void Stop() { m_impl->
Stop(); }
219 bool SendDMX(
const DmxBuffer &buffer)
const {
220 return m_impl->
SendDMX(buffer);
237 return m_impl->GetDescriptor();
243 DmxTriWidgetImpl *m_impl;
246 void ResumeRDMCommands() {
253 #endif // PLUGINS_USBPRO_DMXTRIWIDGET_H_