30 #ifndef INCLUDE_OLA_RDM_RDMCOMMAND_H_
31 #define INCLUDE_OLA_RDM_RDMCOMMAND_H_
35 #include <ola/io/ByteString.h>
36 #include <ola/io/OutputStream.h>
37 #include <ola/rdm/CommandPrinter.h>
40 #include <ola/rdm/RDMResponseCodes.h>
137 uint16_t
ParamId()
const {
return m_param_id; }
154 virtual uint16_t
Checksum(uint16_t checksum)
const {
return checksum; }
165 bool unpack_param_data)
const {
166 printer->Print(
this, summarize, unpack_param_data);
193 uint8_t m_transaction_number;
199 const UID &destination,
200 uint8_t transaction_number,
202 uint8_t message_count,
206 unsigned int length);
208 void SetParamData(
const uint8_t *data,
unsigned int length);
210 static RDMStatusCode VerifyData(
const uint8_t *data,
217 uint8_t m_message_count;
218 uint16_t m_sub_device;
221 unsigned int m_data_length;
223 static uint16_t CalculateChecksum(
const uint8_t *data,
224 unsigned int packet_length);
242 : has_message_length(false),
244 sub_start_code(SUB_START_CODE),
250 void SetMessageLength(uint8_t message_length_arg) {
251 has_message_length =
true;
252 message_length = message_length_arg;
255 void SetChecksum(uint16_t checksum_arg) {
257 checksum = checksum_arg;
260 bool has_message_length;
263 uint8_t sub_start_code;
264 uint8_t message_length;
265 uint8_t message_count;
283 const UID &destination,
284 uint8_t transaction_number,
291 const OverrideOptions &options = OverrideOptions());
299 uint8_t
PortId()
const {
return m_port_id; }
321 bool unpack_param_data)
const {
322 printer->Print(
this, summarize, unpack_param_data);
333 uint16_t
Checksum(uint16_t checksum)
const;
345 m_source = source_uid;
353 m_transaction_number = transaction_number;
373 unsigned int length);
376 OverrideOptions m_override_options;
402 const UID &destination,
403 uint8_t transaction_number,
411 :
RDMRequest(source, destination, transaction_number, port_id,
412 sub_device, command_class, param_id, data, length, options) {
417 template <RDMCommand::RDMCommandClass command_
class>
421 const UID &destination,
422 uint8_t transaction_number,
430 sub_device, command_class, param_id, data, length,
448 typedef BaseRDMRequest<RDMCommand::GET_COMMAND> RDMGetRequest;
449 typedef BaseRDMRequest<RDMCommand::SET_COMMAND> RDMSetRequest;
472 const UID &destination,
473 uint8_t transaction_number,
474 uint8_t response_type,
475 uint8_t message_count,
481 :
RDMCommand(source, destination, transaction_number, response_type,
482 message_count, sub_device, param_id, data, length),
483 m_command_class(command_class) {
488 bool unpack_param_data)
const {
489 printer->Print(
this, summarize, unpack_param_data);
535 m_destination = destination_uid;
543 m_transaction_number = transaction_number;
565 RDMStatusCode *status_code,
576 RDMStatusCode *status_code,
578 return InflateFromData(input.data(), input.size(), status_code, request);
605 const UID &destination,
606 uint8_t transaction_number,
607 uint8_t response_type,
608 uint8_t message_count,
614 :
RDMResponse(source, destination, transaction_number, response_type,
615 message_count, sub_device, command_class, param_id, data,
621 template <RDMCommand::RDMCommandClass command_
class>
625 const UID &destination,
626 uint8_t transaction_number,
627 uint8_t response_type,
628 uint8_t message_count,
634 response_type, message_count, sub_device,
635 command_class, param_id, data, length) {
649 rdm_nack_reason reason,
650 uint8_t outstanding_messages = 0);
655 const uint8_t *data = NULL,
656 unsigned int length = 0,
657 rdm_response_type type = RDM_ACK,
658 uint8_t outstanding_messages = 0);
667 uint8_t type = RDM_ACK,
668 uint8_t outstanding_messages = 0);
676 const UID &destination,
677 uint8_t transaction_number,
696 uint8_t PortId()
const {
return m_port_id; }
700 bool unpack_param_data)
const {
701 printer->Print(
this, summarize, unpack_param_data);
705 unsigned int length);
718 uint8_t transaction_number,
719 uint8_t port_id = 1);
726 const UID &destination,
727 uint8_t transaction_number,
728 uint8_t port_id = 1);
734 const UID &destination,
735 uint8_t transaction_number,
736 uint8_t port_id = 1);
745 const UID &destination,
746 uint8_t transaction_number,
748 uint8_t message_count,
767 bool unpack_param_data)
const {
768 printer->Print(
this, summarize, unpack_param_data);
772 unsigned int length);
777 #endif // INCLUDE_OLA_RDM_RDMCOMMAND_H_
bool operator==(const RDMCommand &other) const
Test for equality.
Definition: RDMCommand.cpp:127
Structures and constants used with RDM Packets.
Definition: RDMCommand.h:418
RDMDiscoveryRequest * NewUnMuteRequest(const UID &source, const UID &destination, uint8_t transaction_number, uint8_t port_id)
Definition: RDMCommand.cpp:734
RDMCommandClass CommandClass() const
The CommmandClass of this message.
Definition: RDMCommand.h:521
Definition: RDMPacket.h:44
RDMResponse(const UID &source, const UID &destination, uint8_t transaction_number, uint8_t response_type, uint8_t message_count, uint16_t sub_device, RDMCommand::RDMCommandClass command_class, uint16_t param_id, const uint8_t *data, unsigned int length)
Create a new RDM Response.
Definition: RDMCommand.h:471
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition: RDMCommand.h:456
RDMResponse * GetResponseFromData(const RDMRequest *request, const uint8_t *data, unsigned int length, rdm_response_type type, uint8_t outstanding_messages)
Generate an ACK Response with some data.
Definition: RDMCommand.cpp:584
void SetSourceUID(const UID &source_uid)
Set the source UID.
Definition: RDMCommand.h:344
The base class for GET/SET responses.
Definition: RDMCommand.h:602
virtual void Print(CommandPrinter *printer, bool summarize, bool unpack_param_data) const
Output the contents of the command to a CommandPrinter.
Definition: RDMCommand.h:765
virtual void Print(CommandPrinter *printer, bool summarize, bool unpack_param_data) const
Output the contents of the command to a CommandPrinter.
Definition: RDMCommand.h:698
Definition: CommandPrinter.h:31
const uint8_t * ParamData() const
Returns the Parameter Data of the RDMCommand.
Definition: RDMCommand.h:143
uint16_t Checksum(uint16_t checksum) const
Modify the calculated checksum for this command.
Definition: RDMCommand.cpp:313
RDMCommandClass
A set of values representing CommandClasses in E1.20.
Definition: RDMEnums.h:55
static const unsigned int MAX_OVERFLOW_SIZE
The maximum size of an ACK_OVERFLOW session that we'll buffer.
Definition: RDMCommand.h:553
virtual RDMRequest * Duplicate() const
Make a copy of the request.
Definition: RDMCommand.h:305
Definition: RDMCommand.h:68
std::string ToString() const
Create a human readable string from the RDMCommand object.
Definition: RDMCommand.cpp:112
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition: RDMCommand.h:233
A RDM unique identifier (UID).
RDMRequest(const UID &source, const UID &destination, uint8_t transaction_number, uint8_t port_id, uint16_t sub_device, RDMCommandClass command_class, uint16_t param_id, const uint8_t *data, unsigned int length, const OverrideOptions &options=OverrideOptions())
Create a new request.
Definition: RDMCommand.cpp:280
An RDM response of type DISCOVER_COMMAND.
Definition: RDMCommand.h:742
Definition: RDMCommand.h:69
static RDMResponse * InflateFromData(const uint8_t *data, size_t length, RDMStatusCode *status_code, const RDMRequest *request=NULL)
Definition: RDMCommand.cpp:378
const UID & SourceUID() const
Returns the Source UID of the RDMCommand.
Definition: RDMCommand.h:116
Definition: RDMCommand.h:73
RDMResponse * NackWithReason(const RDMRequest *request, rdm_nack_reason reason_enum, uint8_t outstanding_messages)
Generate a NACK response with a reason code.
Definition: RDMCommand.cpp:572
virtual RDMCommandClass CommandClass() const =0
The CommmandClass of this message.
void SetTransactionNumber(uint8_t transaction_number)
Set the transaction number.
Definition: RDMCommand.h:352
friend std::ostream & operator<<(std::ostream &out, const RDMCommand &command)
Output an RDMCommand object to an ostream.
Definition: RDMCommand.h:97
void SetTransactionNumber(uint8_t transaction_number)
Set the transaction number.
Definition: RDMCommand.h:542
An RDM Get / Set Request.
Definition: RDMCommand.h:386
RDMGetSetRequest(const UID &source, const UID &destination, uint8_t transaction_number, uint8_t port_id, uint16_t sub_device, RDMCommandClass command_class, uint16_t param_id, const uint8_t *data, unsigned int length, const OverrideOptions &options)
Create a new Get / Set Request.
Definition: RDMCommand.h:401
static RDMResponse * InflateFromData(const ola::io::ByteString &input, RDMStatusCode *status_code, const RDMRequest *request=NULL)
Definition: RDMCommand.h:575
An RDM request of type DISCOVER_COMMAND.
Definition: RDMCommand.h:673
RDMCommandClass
A set of values representing CommandClasses in E1.20.
Definition: RDMCommand.h:66
The base class that all RDM requests & responses inherit from.
Definition: RDMCommand.h:59
void SetDestinationUID(const UID &destination_uid)
Set the destination UID.
Definition: RDMCommand.h:534
BaseRDMRequest< command_class > * Duplicate() const
Make a copy of the request.
Definition: RDMCommand.h:434
static RDMDiscoveryRequest * InflateFromData(const uint8_t *data, unsigned int length)
Inflate a discovery request.
Definition: RDMCommand.cpp:650
RDMResponse * Duplicate() const
Make a copy of the response.
Definition: RDMCommand.h:496
RDMCommand(const UID &source, const UID &destination, uint8_t transaction_number, uint8_t port_id, uint8_t message_count, uint16_t sub_device, uint16_t param_id, const uint8_t *data, unsigned int length)
Protected constructor for derived classes.
Definition: RDMCommand.cpp:84
void SetPortId(uint8_t port_id)
Set the Port Id.
Definition: RDMCommand.h:360
RDMResponse * GetResponseWithPid(const RDMRequest *request, uint16_t pid, const uint8_t *data, unsigned int length, uint8_t type, uint8_t outstanding_messages)
Construct an RDM response from a RDMRequest object.
Definition: RDMCommand.cpp:598
RDMDiscoveryRequest * NewDiscoveryUniqueBranchRequest(const UID &source, const UID &lower, const UID &upper, uint8_t transaction_number, uint8_t port_id)
Create a new DUB request object.
Definition: RDMCommand.cpp:692
void SetParamData(const uint8_t *data, unsigned int length)
Definition: RDMCommand.cpp:171
Definition: RDMCommand.h:622
Definition: RDMCommand.h:235
virtual uint16_t Checksum(uint16_t checksum) const
Modify the calculated checksum for this command.
Definition: RDMCommand.h:154
unsigned int ParamDataSize() const
Returns the Size of the Parameter Data of the RDMCommand.
Definition: RDMCommand.h:140
uint8_t MessageLength() const
The Message length field.
Definition: RDMCommand.cpp:305
static RDMRequest * InflateFromData(const uint8_t *data, unsigned int length)
Inflate a request from some data.
Definition: RDMCommand.cpp:318
virtual void Print(CommandPrinter *printer, bool summarize, bool unpack_param_data) const
Output the contents of the command to a CommandPrinter.
Definition: RDMCommand.h:163
const UID & DestinationUID() const
Returns the Destination UID of the RDMCommand.
Definition: RDMCommand.h:119
static const uint8_t START_CODE
The RDM Start Code.
Definition: RDMCommand.h:179
Definition: RDMCommand.h:72
OverrideOptions()
Allow all fields in a RDMRequest to be specified. Using values other than the default may result in i...
Definition: RDMCommand.h:241
virtual void Print(CommandPrinter *printer, bool summarize, bool unpack_param_data) const
Output the contents of the command to a CommandPrinter.
Definition: RDMCommand.h:319
virtual void Print(CommandPrinter *printer, bool summarize, bool unpack_param_data) const
Output the contents of the command to a CommandPrinter.
Definition: RDMCommand.h:486
uint8_t PortIdResponseType() const
Returns the Port ID of the RDMCommand.
Definition: RDMCommand.h:125
virtual uint8_t MessageLength() const
The Message length field.
Definition: RDMCommand.cpp:162
Definition: RDMCommand.h:71
bool IsDUB() const
Check if this is a DUB request.
Definition: RDMCommand.cpp:296
static RDMCommand * Inflate(const uint8_t *data, unsigned int length)
Extract a RDMCommand from raw data.
Definition: RDMCommand.cpp:141
uint16_t ParamId() const
Returns the Parameter ID of the RDMCommand.
Definition: RDMCommand.h:137
RDMDiscoveryRequest * NewMuteRequest(const UID &source, const UID &destination, uint8_t transaction_number, uint8_t port_id)
Create a new Mute Request Object.
Definition: RDMCommand.cpp:716
uint16_t SubDevice() const
Returns the SubDevice of the RDMCommand.
Definition: RDMCommand.h:131
RDMCommandClass CommandClass() const
The CommmandClass of this message.
Definition: RDMCommand.h:293
Various constants used in RDM.
virtual uint8_t SubStartCode() const
The Sub-Start code for the RDMCommand.
Definition: RDMCommand.h:110
static RDMDiscoveryResponse * InflateFromData(const uint8_t *data, unsigned int length)
Definition: RDMCommand.cpp:752
Represents a RDM UID.
Definition: UID.h:57
uint8_t MessageCount() const
Returns the Message Count of the RDMCommand.
Definition: RDMCommand.h:128
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
Definition: RDMCommand.h:70
uint8_t SubStartCode() const
The Sub-Start code for the RDMCommand.
Definition: RDMCommand.cpp:301
uint8_t PortId() const
The Port ID for this request.
Definition: RDMCommand.h:299
Definition: RDMCommand.h:67
uint8_t TransactionNumber() const
Returns the Transaction Number of the RDMCommand.
Definition: RDMCommand.h:122
uint8_t ResponseType() const
The Response Type.
Definition: RDMCommand.h:519
static RDMResponse * CombineResponses(const RDMResponse *response1, const RDMResponse *response2)
Combine two RDMResponses.
Definition: RDMCommand.cpp:516