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);
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);
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);
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,
292 const OverrideOptions &options = OverrideOptions());
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;
374 unsigned int length);
377 OverrideOptions m_override_options;
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) {
418template <RDMCommand::RDMCommandClass command_
class>
422 const UID &destination,
423 uint8_t transaction_number,
431 sub_device, command_class, param_id, data, length,
449typedef BaseRDMRequest<RDMCommand::GET_COMMAND> RDMGetRequest;
450typedef BaseRDMRequest<RDMCommand::SET_COMMAND> RDMSetRequest;
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;
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,
622template <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);
Various constants used in RDM.
Structures and constants used with RDM Packets.
Enums representing the states of a response. This is generated from the proto file.
A RDM unique identifier (UID).
Definition RDMCommand.h:419
BaseRDMRequest< command_class > * Duplicate() const
Make a copy of the request.
Definition RDMCommand.h:435
Definition RDMCommand.h:623
Definition CommandPrinter.h:31
The base class that all RDM requests & responses inherit from.
Definition RDMCommand.h:59
uint16_t SubDevice() const
Returns the SubDevice of the RDMCommand.
Definition RDMCommand.h:131
uint8_t TransactionNumber() const
Returns the Transaction Number of the RDMCommand.
Definition RDMCommand.h:122
unsigned int ParamDataSize() const
Returns the Size of the Parameter Data of the RDMCommand.
Definition RDMCommand.h:140
static const uint8_t START_CODE
The RDM Start Code.
Definition RDMCommand.h:179
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
virtual uint16_t Checksum(uint16_t checksum) const
Modify the calculated checksum for this command.
Definition RDMCommand.h:154
const UID & SourceUID() const
Returns the Source UID of the RDMCommand.
Definition RDMCommand.h:116
uint16_t ParamId() const
Returns the Parameter ID of the RDMCommand.
Definition RDMCommand.h:137
const uint8_t * ParamData() const
Returns the Parameter Data of the RDMCommand.
Definition RDMCommand.h:143
virtual RDMCommandClass CommandClass() const =0
The CommmandClass of this message.
uint8_t MessageCount() const
Returns the Message Count of the RDMCommand.
Definition RDMCommand.h:128
RDMCommandClass
A set of values representing CommandClasses in E1.20.
Definition RDMCommand.h:66
@ GET_COMMAND
Definition RDMCommand.h:69
@ GET_COMMAND_RESPONSE
Definition RDMCommand.h:70
@ INVALID_COMMAND
Definition RDMCommand.h:73
@ SET_COMMAND
Definition RDMCommand.h:71
@ DISCOVER_COMMAND
Definition RDMCommand.h:67
@ DISCOVER_COMMAND_RESPONSE
Definition RDMCommand.h:68
@ SET_COMMAND_RESPONSE
Definition RDMCommand.h:72
const UID & DestinationUID() const
Returns the Destination UID of the RDMCommand.
Definition RDMCommand.h:119
virtual uint8_t SubStartCode() const
The Sub-Start code for the RDMCommand.
Definition RDMCommand.h:110
uint8_t PortIdResponseType() const
Returns the Port ID of the RDMCommand.
Definition RDMCommand.h:125
An RDM request of type DISCOVER_COMMAND.
Definition RDMCommand.h:674
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
An RDM response of type DISCOVER_COMMAND.
Definition RDMCommand.h:743
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
An RDM Get / Set Request.
Definition RDMCommand.h:387
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
The base class for GET/SET responses.
Definition RDMCommand.h:603
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition RDMCommand.h:234
void SetSourceUID(const UID &source_uid)
Set the source UID.
Definition RDMCommand.h:345
RDMCommandClass CommandClass() const
The CommmandClass of this message.
Definition RDMCommand.h:294
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
uint8_t PortId() const
The Port ID for this request.
Definition RDMCommand.h:300
void SetPortId(uint8_t port_id)
Set the Port Id.
Definition RDMCommand.h:361
void SetTransactionNumber(uint8_t transaction_number)
Set the transaction number.
Definition RDMCommand.h:353
virtual RDMRequest * Duplicate() const
Make a copy of the request.
Definition RDMCommand.h:306
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition RDMCommand.h:457
void SetTransactionNumber(uint8_t transaction_number)
Set the transaction number.
Definition RDMCommand.h:543
RDMCommandClass CommandClass() const
The CommmandClass of this message.
Definition RDMCommand.h:522
uint8_t ResponseType() const
The Response Type.
Definition RDMCommand.h:520
void SetDestinationUID(const UID &destination_uid)
Set the destination UID.
Definition RDMCommand.h:535
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
static RDMResponse * InflateFromData(const ola::io::ByteString &input, RDMStatusCode *status_code, const RDMRequest *request=NULL)
Definition RDMCommand.h:576
static const unsigned int MAX_OVERFLOW_SIZE
The maximum size of an ACK_OVERFLOW session that we'll buffer.
Definition RDMCommand.h:554
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
RDMResponse * Duplicate() const
Make a copy of the response.
Definition RDMCommand.h:497
Represents a RDM UID.
Definition UID.h:57
static RDMCommand * Inflate(const uint8_t *data, unsigned int length)
Extract a RDMCommand from raw data.
Definition RDMCommand.cpp:141
uint8_t MessageLength() const
The Message length field.
Definition RDMCommand.cpp:305
static RDMDiscoveryResponse * InflateFromData(const uint8_t *data, unsigned int length)
Definition RDMCommand.cpp:752
static RDMRequest * InflateFromData(const uint8_t *data, unsigned int length)
Inflate a request from some data.
Definition RDMCommand.cpp:318
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
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
bool IsDUB() const
Check if this is a DUB request.
Definition RDMCommand.cpp:296
std::string ToString() const
Create a human readable string from the RDMCommand object.
Definition RDMCommand.cpp:112
RDMDiscoveryRequest * NewUnMuteRequest(const UID &source, const UID &destination, uint8_t transaction_number, uint8_t port_id)
Definition RDMCommand.cpp:734
friend std::ostream & operator<<(std::ostream &out, const RDMCommand &command)
Output an RDMCommand object to an ostream.
Definition RDMCommand.h:97
static RDMDiscoveryRequest * InflateFromData(const uint8_t *data, unsigned int length)
Inflate a discovery request.
Definition RDMCommand.cpp:650
void SetParamData(const uint8_t *data, unsigned int length)
Definition RDMCommand.cpp:171
uint8_t SubStartCode() const
The Sub-Start code for the RDMCommand.
Definition RDMCommand.cpp:301
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 Checksum(uint16_t checksum) const
Modify the calculated checksum for this command.
Definition RDMCommand.cpp:313
bool operator==(const RDMCommand &other) const
Test for equality.
Definition RDMCommand.cpp:127
virtual uint8_t MessageLength() const
The Message length field.
Definition RDMCommand.cpp:162
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
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
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
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
static RDMResponse * InflateFromData(const uint8_t *data, size_t length, RDMStatusCode *status_code, const RDMRequest *request=NULL)
Definition RDMCommand.cpp:378
static RDMResponse * CombineResponses(const RDMResponse *response1, const RDMResponse *response2)
Combine two RDMResponses.
Definition RDMCommand.cpp:516
RDMCommandClass
A set of values representing CommandClasses in E1.20.
Definition RDMEnums.h:55
RDMStatusCode
RDM Status Codes.
Definition RDMResponseCodes.h:45
rdm_response_type
RDM response types.
Definition RDMResponseCodes.h:76
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
Definition RDMPacket.h:44
Definition RDMCommand.h:236
OverrideOptions()
Allow all fields in a RDMRequest to be specified. Using values other than the default may result in i...
Definition RDMCommand.h:242