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> 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);
194 uint8_t m_transaction_number;
200 const UID &destination,
201 uint8_t transaction_number,
203 uint8_t message_count,
207 unsigned int length);
209 void SetParamData(
const uint8_t *data,
unsigned int length);
218 uint8_t m_message_count;
219 uint16_t m_sub_device;
222 unsigned int m_data_length;
224 static uint16_t CalculateChecksum(
const uint8_t *data,
225 unsigned int packet_length);
243 : has_message_length(false),
245 sub_start_code(SUB_START_CODE),
251 void SetMessageLength(uint8_t message_length_arg) {
252 has_message_length =
true;
253 message_length = message_length_arg;
256 void SetChecksum(uint16_t checksum_arg) {
258 checksum = checksum_arg;
261 bool has_message_length;
264 uint8_t sub_start_code;
265 uint8_t message_length;
266 uint8_t message_count;
284 const UID &destination,
285 uint8_t transaction_number,
300 uint8_t
PortId()
const {
return m_port_id; }
322 bool unpack_param_data)
const {
323 printer->Print(
this, summarize, unpack_param_data);
334 uint16_t
Checksum(uint16_t checksum)
const;
346 m_source = source_uid;
354 m_transaction_number = transaction_number;
373 static RDMRequest* InflateFromData(
const uint8_t *data,
374 unsigned int length);
403 const UID &destination,
404 uint8_t transaction_number,
412 :
RDMRequest(source, destination, transaction_number, port_id,
413 sub_device, command_class, param_id, data, length, options) {
418 template <RDMCommand::RDMCommandClass command_
class>
422 const UID &destination,
423 uint8_t transaction_number,
431 sub_device, command_class, param_id, data, length,
473 const UID &destination,
474 uint8_t transaction_number,
475 uint8_t response_type,
476 uint8_t message_count,
482 :
RDMCommand(source, destination, transaction_number, response_type,
483 message_count, sub_device, param_id, data, length),
484 m_command_class(command_class) {
489 bool unpack_param_data)
const {
490 printer->Print(
this, summarize, unpack_param_data);
536 m_destination = destination_uid;
544 m_transaction_number = transaction_number;
554 static const unsigned int MAX_OVERFLOW_SIZE = 4 << 10;
564 static RDMResponse* InflateFromData(
const uint8_t *data,
579 return InflateFromData(input.data(), input.size(), status_code, request);
606 const UID &destination,
607 uint8_t transaction_number,
608 uint8_t response_type,
609 uint8_t message_count,
615 :
RDMResponse(source, destination, transaction_number, response_type,
616 message_count, sub_device, command_class, param_id, data,
622 template <RDMCommand::RDMCommandClass command_
class>
626 const UID &destination,
627 uint8_t transaction_number,
628 uint8_t response_type,
629 uint8_t message_count,
635 response_type, message_count, sub_device,
636 command_class, param_id, data, length) {
650 rdm_nack_reason reason,
651 uint8_t outstanding_messages = 0);
656 const uint8_t *data = NULL,
657 unsigned int length = 0,
659 uint8_t outstanding_messages = 0);
668 uint8_t type = RDM_ACK,
669 uint8_t outstanding_messages = 0);
677 const UID &destination,
678 uint8_t transaction_number,
697 uint8_t PortId()
const {
return m_port_id; }
701 bool unpack_param_data)
const {
702 printer->Print(
this, summarize, unpack_param_data);
706 unsigned int length);
719 uint8_t transaction_number,
720 uint8_t port_id = 1);
727 const UID &destination,
728 uint8_t transaction_number,
729 uint8_t port_id = 1);
735 const UID &destination,
736 uint8_t transaction_number,
737 uint8_t port_id = 1);
746 const UID &destination,
747 uint8_t transaction_number,
749 uint8_t message_count,
768 bool unpack_param_data)
const {
769 printer->Print(
this, summarize, unpack_param_data);
773 unsigned int length);
778 #endif // INCLUDE_OLA_RDM_RDMCOMMAND_H_ Definition: RDMCommand.h:71
unsigned int ParamDataSize() const
Returns the Size of the Parameter Data of the RDMCommand.
Definition: RDMCommand.h:140
virtual uint8_t MessageLength() const
The Message length field.
Definition: RDMCommand.cpp:162
Structures and constants used with RDM Packets.
Definition: RDMCommand.h:419
RDMDiscoveryRequest * NewUnMuteRequest(const UID &source, const UID &destination, uint8_t transaction_number, uint8_t port_id)
Definition: RDMCommand.cpp:745
RDMStatusCode
RDM Status Codes.
Definition: RDMResponseCodes.h:45
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:472
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition: RDMCommand.h:457
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:595
void SetSourceUID(const UID &source_uid)
Set the source UID.
Definition: RDMCommand.h:345
rdm_response_type
RDM response types.
Definition: RDMResponseCodes.h:76
virtual uint8_t SubStartCode() const
The Sub-Start code for the RDMCommand.
Definition: RDMCommand.h:110
The base class for GET/SET responses.
Definition: RDMCommand.h:603
Definition: RDMCommand.h:67
RDMCommandClass
A set of values representing CommandClasses in E1.20.
Definition: RDMCommand.h:66
virtual void Print(CommandPrinter *printer, bool summarize, bool unpack_param_data) const
Output the contents of the command to a CommandPrinter.
Definition: RDMCommand.h:487
Definition: CommandPrinter.h:31
RDMCommandClass
A set of values representing CommandClasses in E1.20.
Definition: RDMEnums.h:55
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
BaseRDMRequest< command_class > * Duplicate() const
Make a copy of the request.
Definition: RDMCommand.h:435
uint8_t PortIdResponseType() const
Returns the Port ID of the RDMCommand.
Definition: RDMCommand.h:125
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition: RDMCommand.h:234
A RDM unique identifier (UID).
An RDM response of type DISCOVER_COMMAND.
Definition: RDMCommand.h:743
uint8_t ResponseType() const
The Response Type.
Definition: RDMCommand.h:520
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:583
virtual RDMCommandClass CommandClass() const =0
The CommmandClass of this message.
void SetTransactionNumber(uint8_t transaction_number)
Set the transaction number.
Definition: RDMCommand.h:353
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:543
uint8_t MessageCount() const
Returns the Message Count of the RDMCommand.
Definition: RDMCommand.h:128
An RDM Get / Set Request.
Definition: RDMCommand.h:387
virtual uint16_t Checksum(uint16_t checksum) const
Modify the calculated checksum for this command.
Definition: RDMCommand.h:154
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:402
uint16_t ParamId() const
Returns the Parameter ID of the RDMCommand.
Definition: RDMCommand.h:137
const UID & DestinationUID() const
Returns the Destination UID of the RDMCommand.
Definition: RDMCommand.h:119
static RDMResponse * InflateFromData(const ola::io::ByteString &input, RDMStatusCode *status_code, const RDMRequest *request=NULL)
Definition: RDMCommand.h:576
An RDM request of type DISCOVER_COMMAND.
Definition: RDMCommand.h:674
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:535
Definition: RDMCommand.h:68
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:361
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:609
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:703
Enums representing the states of a response. This is generated from the proto file.
const uint8_t * ParamData() const
Returns the Parameter Data of the RDMCommand.
Definition: RDMCommand.h:143
bool operator==(const RDMCommand &other) const
Test for equality.
Definition: RDMCommand.cpp:127
virtual void Print(CommandPrinter *printer, bool summarize, bool unpack_param_data) const
Output the contents of the command to a CommandPrinter.
Definition: RDMCommand.h:320
void SetParamData(const uint8_t *data, unsigned int length)
Definition: RDMCommand.cpp:171
Definition: RDMCommand.h:623
Definition: RDMCommand.h:236
static const uint8_t START_CODE
The RDM Start Code.
Definition: RDMCommand.h:180
OverrideOptions()
Allow all fields in a RDMRequest to be specified. Using values other than the default may result in i...
Definition: RDMCommand.h:242
RDMCommandClass CommandClass() const
The CommmandClass of this message.
Definition: RDMCommand.h:522
uint8_t TransactionNumber() const
Returns the Transaction Number of the RDMCommand.
Definition: RDMCommand.h:122
std::string ToString() const
Create a human readable string from the RDMCommand object.
Definition: RDMCommand.cpp:112
Definition: RDMCommand.h:73
virtual RDMRequest * Duplicate() const
Make a copy of the request.
Definition: RDMCommand.h:306
virtual void Print(CommandPrinter *printer, bool summarize, bool unpack_param_data) const
Output the contents of the command to a CommandPrinter.
Definition: RDMCommand.h:766
static RDMCommand * Inflate(const uint8_t *data, unsigned int length)
Extract a RDMCommand from raw data.
Definition: RDMCommand.cpp:141
uint8_t PortId() const
The Port ID for this request.
Definition: RDMCommand.h:300
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:727
Various constants used in RDM.
virtual void Print(CommandPrinter *printer, bool summarize, bool unpack_param_data) const
Output the contents of the command to a CommandPrinter.
Definition: RDMCommand.h:699
RDMResponse * Duplicate() const
Make a copy of the response.
Definition: RDMCommand.h:497
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
const UID & SourceUID() const
Returns the Source UID of the RDMCommand.
Definition: RDMCommand.h:116
RDMCommandClass CommandClass() const
The CommmandClass of this message.
Definition: RDMCommand.h:294
uint16_t SubDevice() const
Returns the SubDevice of the RDMCommand.
Definition: RDMCommand.h:131
Definition: RDMCommand.h:70
Definition: RDMCommand.h:69
Definition: RDMCommand.h:72