30 #ifndef INCLUDE_OLA_RDM_RDMCOMMAND_H_
31 #define INCLUDE_OLA_RDM_RDMCOMMAND_H_
34 #include <ola/io/OutputStream.h>
35 #include <ola/rdm/CommandPrinter.h>
38 #include <ola/rdm/RDMResponseCodes.h>
135 friend ostream& operator<< (ostream &out,
const RDMCommand &command) {
170 uint16_t
ParamId()
const {
return m_param_id; }
189 bool unpack_param_data)
const {
190 printer->Print(
this, summarize, unpack_param_data);
199 static const uint8_t START_CODE = 0xcc;
207 const UID &destination,
208 uint8_t transaction_number,
210 uint8_t message_count,
214 unsigned int length);
216 void SetParamData(
const uint8_t *data,
unsigned int length);
218 static rdm_response_code VerifyData(
228 uint8_t m_transaction_number;
229 uint8_t m_message_count;
230 uint16_t m_sub_device;
233 unsigned int m_data_length;
236 bool operator=(
const RDMCommand &other)
const;
238 static uint16_t CalculateChecksum(
const uint8_t *data,
239 unsigned int packet_length);
249 const UID &destination,
250 uint8_t transaction_number,
252 uint8_t message_count,
257 unsigned int length):
267 m_command_class(command_class) {
271 uint8_t PortId()
const {
return m_port_id; }
273 virtual RDMRequest *Duplicate()
const {
274 return DuplicateWithControllerParams(
280 virtual RDMRequest *DuplicateWithControllerParams(
282 uint8_t transaction_number,
283 uint8_t port_id)
const {
284 return new RDMRequest(
299 bool unpack_param_data)
const {
300 printer->Print(
this, summarize, unpack_param_data);
304 static RDMRequest* InflateFromData(
const uint8_t *data,
305 unsigned int length);
306 static RDMRequest* InflateFromData(
const string &data);
319 const UID &destination,
320 uint8_t transaction_number,
322 uint8_t message_count,
327 unsigned int length):
342 template <RDMCommand::RDMCommandClass command_
class>
346 const UID &destination,
347 uint8_t transaction_number,
349 uint8_t message_count,
353 unsigned int length):
368 return DuplicateWithControllerParams(
374 BaseRDMRequest<command_class> *DuplicateWithControllerParams(
376 uint8_t transaction_number,
377 uint8_t port_id)
const {
378 return new BaseRDMRequest<command_class>(
391 typedef BaseRDMRequest<RDMCommand::GET_COMMAND> RDMGetRequest;
392 typedef BaseRDMRequest<RDMCommand::SET_COMMAND> RDMSetRequest;
402 const UID &destination,
403 uint8_t transaction_number,
404 uint8_t response_type,
405 uint8_t message_count,
409 unsigned int length):
421 uint8_t ResponseType()
const {
return m_port_id; }
425 bool unpack_param_data)
const {
426 printer->Print(
this, summarize, unpack_param_data);
431 static const unsigned int MAX_OVERFLOW_SIZE = 4 << 10;
436 rdm_response_code *response_code,
440 rdm_response_code *response_code,
442 uint8_t transaction_number);
444 rdm_response_code *response_code,
447 rdm_response_code *response_code,
449 uint8_t transaction_number);
463 const UID &destination,
464 uint8_t transaction_number,
465 uint8_t response_type,
466 uint8_t message_count,
470 unsigned int length):
484 template <RDMCommand::RDMCommandClass command_
class>
488 const UID &destination,
489 uint8_t transaction_number,
490 uint8_t response_type,
491 uint8_t message_count,
495 unsigned int length):
509 typedef BaseRDMResponse<RDMCommand::GET_COMMAND_RESPONSE> RDMGetResponse;
510 typedef BaseRDMResponse<RDMCommand::SET_COMMAND_RESPONSE> RDMSetResponse;
517 unsigned int length);
518 RDMResponse *NackWithReason(
const RDMRequest *request,
519 rdm_nack_reason reason,
520 uint8_t outstanding_messages = 0);
521 RDMResponse *GetResponseFromData(
const RDMRequest *request,
522 const uint8_t *data = NULL,
523 unsigned int length = 0,
524 rdm_response_type type = RDM_ACK,
525 uint8_t outstanding_messages = 0);
531 uint8_t type = RDM_ACK,
532 uint8_t outstanding_messages = 0);
540 const UID &destination,
541 uint8_t transaction_number,
543 uint8_t message_count,
560 uint8_t PortId()
const {
return m_port_id; }
564 bool unpack_param_data)
const {
565 printer->Print(
this, summarize, unpack_param_data);
569 unsigned int length);
583 uint8_t transaction_number,
584 uint8_t port_id = 1);
591 const UID &destination,
592 uint8_t transaction_number,
593 uint8_t port_id = 1);
599 const UID &destination,
600 uint8_t transaction_number,
601 uint8_t port_id = 1);
610 const UID &destination,
611 uint8_t transaction_number,
613 uint8_t message_count,
633 bool unpack_param_data)
const {
634 printer->Print(
this, summarize, unpack_param_data);
638 unsigned int length);
644 #endif // INCLUDE_OLA_RDM_RDMCOMMAND_H_