RDM
HEAD (unstable)
Implementation of ANSI E1.31 (Streaming ACN)
|
View other versions:
|
Basic RDM message packing and unpacking. More...
Data Structures | |
struct | RdmBuffer |
struct | RdmCommandHeader |
struct | RdmResponseHeader |
Macros | |
#define | RDM_MAX_BYTES 257 |
#define | RDM_MIN_BYTES 26 |
#define | RDM_MAX_PDL 231 |
#define | RDM_HEADER_SIZE 24 |
#define | RDM_NUM_STANDARD_NR_CODES 20 |
#define | RDM_GET_COMMAND_CLASS(rdmbufptr) ((rdmbufptr)->data[RDM_OFFSET_COMMAND_CLASS]) |
Get the command class value from a packed RDM command. More... | |
#define | RDM_GET_TRANSACTION_NUM(rdmbufptr) ((rdmbufptr)->data[RDM_OFFSET_TRANSACTION]) |
Get the RDM transaction number from a packed RDM command. More... | |
#define | RDM_PACKED_SIZE(data_len) (RDM_HEADER_SIZE + (data_len) + 2u) |
Get the packed size in bytes of an RDM message. More... | |
Typedefs | |
typedef struct RdmBuffer | RdmBuffer |
typedef struct RdmCommandHeader | RdmCommandHeader |
typedef struct RdmResponseHeader | RdmResponseHeader |
Enumerations | |
enum | rdm_command_class_t { kRdmCCDiscoveryCommand = E120_DISCOVERY_COMMAND , kRdmCCDiscoveryCommandResponse = E120_DISCOVERY_COMMAND_RESPONSE , kRdmCCGetCommand = E120_GET_COMMAND , kRdmCCGetCommandResponse = E120_GET_COMMAND_RESPONSE , kRdmCCSetCommand = E120_SET_COMMAND , kRdmCCSetCommandResponse = E120_SET_COMMAND_RESPONSE } |
enum | rdm_response_type_t { kRdmResponseTypeAck = E120_RESPONSE_TYPE_ACK , kRdmResponseTypeAckTimer = E120_RESPONSE_TYPE_ACK_TIMER , kRdmResponseTypeNackReason = E120_RESPONSE_TYPE_NACK_REASON , kRdmResponseTypeAckOverflow = E120_RESPONSE_TYPE_ACK_OVERFLOW } |
enum | rdm_nack_reason_t { kRdmNRUnknownPid = E120_NR_UNKNOWN_PID , kRdmNRFormatError = E120_NR_FORMAT_ERROR , kRdmNRHardwareFault = E120_NR_HARDWARE_FAULT , kRdmNRProxyReject = E120_NR_PROXY_REJECT , kRdmNRWriteProtect = E120_NR_WRITE_PROTECT , kRdmNRUnsupportedCommandClass = E120_NR_UNSUPPORTED_COMMAND_CLASS , kRdmNRDataOutOfRange = E120_NR_DATA_OUT_OF_RANGE , kRdmNRBufferFull = E120_NR_BUFFER_FULL , kRdmNRPacketSizeUnsupported = E120_NR_PACKET_SIZE_UNSUPPORTED , kRdmNRSubDeviceOutOfRange = E120_NR_SUB_DEVICE_OUT_OF_RANGE , kRdmNRProxyBufferFull = E120_NR_PROXY_BUFFER_FULL , kRdmNRActionNotSupported = E137_2_NR_ACTION_NOT_SUPPORTED , kRdmNREndpointNumberInvalid = E137_7_NR_ENDPOINT_NUMBER_INVALID , kRdmNRInvalidEndpointMode = E137_7_NR_INVALID_ENDPOINT_MODE , kRdmNRUnknownUid = E137_7_NR_UNKNOWN_UID , kRdmNRUnknownScope = E133_NR_UNKNOWN_SCOPE , kRdmNRInvalidStaticConfigType = E133_NR_INVALID_STATIC_CONFIG_TYPE , kRdmNRInvalidIpv4Address = E133_NR_INVALID_IPV4_ADDRESS , kRdmNRInvalidIpv6Address = E133_NR_INVALID_IPV6_ADDRESS , kRdmNRInvalidPort = E133_NR_INVALID_PORT } |
Functions | |
void | rdm_pack_checksum (uint8_t *buffer, size_t data_len_without_checksum) |
Calculate and pack an RDM checksum at the end of an RDM message. More... | |
bool | rdm_validate_msg (const RdmBuffer *buffer) |
Perform basic validation of a packed RDM message. More... | |
bool | rdm_command_header_is_valid (const RdmCommandHeader *cmd_header) |
Determine whether the values contained in a command header are valid for an RDM command. More... | |
bool | rdm_response_header_is_valid (const RdmResponseHeader *resp_header) |
Determine whether the values contained in a response header are valid for an RDM response. More... | |
etcpal_error_t | rdm_pack_command (const RdmCommandHeader *cmd_header, const uint8_t *cmd_data, uint8_t cmd_data_len, RdmBuffer *buffer) |
Convert an RDM command header and data to the RDM wire format. More... | |
etcpal_error_t | rdm_pack_command_with_custom_buf (const RdmCommandHeader *cmd_header, const uint8_t *cmd_data, uint8_t cmd_data_len, uint8_t *buf, size_t buf_len) |
Convert an RDM command header and data to the RDM wire format in a user-provided buffer. More... | |
etcpal_error_t | rdm_pack_response (const RdmCommandHeader *cmd_header, uint8_t msg_count, const uint8_t *response_data, uint8_t response_data_len, RdmBuffer *buffer) |
Serialize an RDM ACK response to a previously-received command. More... | |
etcpal_error_t | rdm_pack_overflow_response (const RdmCommandHeader *cmd_header, const uint8_t *response_data, uint8_t response_data_len, RdmBuffer *buffer) |
Serialize an RDM ACK_OVERFLOW response to a previously-received command. More... | |
etcpal_error_t | rdm_pack_nack_response (const RdmCommandHeader *cmd_header, uint8_t msg_count, rdm_nack_reason_t nack_reason, RdmBuffer *buffer) |
Serialize an RDM NACK response to a previously-received command. More... | |
etcpal_error_t | rdm_pack_timer_response (const RdmCommandHeader *cmd_header, uint8_t msg_count, unsigned int delay_time_ms, RdmBuffer *buffer) |
Serialize an RDM ACK_TIMER response to a previously-received command. More... | |
etcpal_error_t | rdm_pack_dub_response (const RdmUid *responder_uid, RdmBuffer *buffer) |
Serialize an RDM DISC_UNIQUE_BRANCH response. More... | |
size_t | rdm_get_num_responses_needed (uint16_t param_id, size_t response_data_len) |
Get the number of RDM responses needed to send the given response data. More... | |
etcpal_error_t | rdm_pack_full_response (const RdmCommandHeader *cmd_header, const uint8_t *response_data, size_t response_data_len, RdmBuffer *buffers, size_t num_buffers) |
Serialize a full RDM ACK response, splitting ACK_OVERFLOW responses if necessary. More... | |
etcpal_error_t | rdm_append_parameter_data (RdmBuffer *buffer, const uint8_t *additional_data, uint8_t additional_data_len) |
Add additional parameter data to an already-serialized RDM command. More... | |
etcpal_error_t | rdm_unpack_command (const RdmBuffer *buffer, RdmCommandHeader *cmd_header, const uint8_t **param_data, uint8_t *param_data_len) |
Deserialize an RDM command from its wire format. More... | |
etcpal_error_t | rdm_unpack_response (const RdmBuffer *buffer, RdmResponseHeader *resp_header, const uint8_t **param_data, uint8_t *param_data_len) |
Deserialize an RDM response from its wire format. More... | |
etcpal_error_t | rdm_unpack_dub_response (const RdmBuffer *buffer, RdmUid *responder_uid) |
Deserialize an RDM DISC_UNIQUE_BRANCH from its wire format. More... | |
unsigned int | rdm_get_ack_timer_delay (const uint8_t *param_data) |
Get the ACK_TIMER delay in milliseconds from an ACK_TIMER message. More... | |
rdm_nack_reason_t | rdm_get_nack_reason_code (const uint8_t *param_data) |
Get the NACK reason code from a NACK_REASON message. More... | |
const char * | rdm_command_class_to_string (rdm_command_class_t command_class) |
Get a string representation of an RDM command class. More... | |
const char * | rdm_response_type_to_string (rdm_response_type_t resp_type) |
Get a string representation of an RDM response type. More... | |
const char * | rdm_nack_reason_to_string (rdm_nack_reason_t reason_code) |
Get a string representation of an RDM NACK reason code. More... | |
Basic RDM message packing and unpacking.
#define RDM_GET_COMMAND_CLASS | ( | rdmbufptr | ) | ((rdmbufptr)->data[RDM_OFFSET_COMMAND_CLASS]) |
Get the command class value from a packed RDM command.
rdmbufptr | Pointer to RdmBuffer containing the packed RDM command. |
#define RDM_GET_TRANSACTION_NUM | ( | rdmbufptr | ) | ((rdmbufptr)->data[RDM_OFFSET_TRANSACTION]) |
Get the RDM transaction number from a packed RDM command.
rdmbufptr | Pointer to RdmBuffer containing the packed RDM command. |
#define RDM_HEADER_SIZE 24 |
The length of the RDM message preceding the Parameter Data.
#define RDM_MAX_BYTES 257 |
The maximum size for an RDM packet, including the two checksum bytes.
#define RDM_MAX_PDL 231 |
The maximum length of the Parameter Data in an RDM packet.
#define RDM_MIN_BYTES 26 |
The minimum size for an RDM packet.
#define RDM_NUM_STANDARD_NR_CODES 20 |
The number of enumerated values in the rdm_nack_reason_t type.
#define RDM_PACKED_SIZE | ( | data_len | ) | (RDM_HEADER_SIZE + (data_len) + 2u) |
Get the packed size in bytes of an RDM message.
data_len | Length in bytes of the parameter data that the RDM message will contain. |
typedef struct RdmCommandHeader RdmCommandHeader |
A structure that represents the header fields of an RDM command. This includes everything except the parameter data.
typedef struct RdmResponseHeader RdmResponseHeader |
A structure that represents the header fields of an RDM response. This includes everything except the parameter data.
enum rdm_command_class_t |
An enumeration representing the RDM Command Class (CC) field.
enum rdm_nack_reason_t |
An enumeration representing a standard RDM NACK reason.
enum rdm_response_type_t |
An enumeration representing the RDM Response Type field.
etcpal_error_t rdm_append_parameter_data | ( | RdmBuffer * | buffer, |
const uint8_t * | additional_data, | ||
uint8_t | additional_data_len | ||
) |
Add additional parameter data to an already-serialized RDM command.
This function is useful when building an RDM command or response progressively. The length and checksum will be updated.
[in,out] | buffer | Packed RDM command to which to append data. |
[in] | additional_data | Parameter data to append. |
[in] | additional_data_len | Length of the parameter data to append. |
const char* rdm_command_class_to_string | ( | rdm_command_class_t | command_class | ) |
Get a string representation of an RDM command class.
[in] | command_class | Command class for which to get a string representation. |
bool rdm_command_header_is_valid | ( | const RdmCommandHeader * | cmd_header | ) |
Determine whether the values contained in a command header are valid for an RDM command.
[in] | cmd_header | Header to validate. |
unsigned int rdm_get_ack_timer_delay | ( | const uint8_t * | param_data | ) |
Get the ACK_TIMER delay in milliseconds from an ACK_TIMER message.
[in] | param_data | The message parameter data. Must be at least 2 bytes in length. |
rdm_nack_reason_t rdm_get_nack_reason_code | ( | const uint8_t * | param_data | ) |
Get the NACK reason code from a NACK_REASON message.
[in] | param_data | The message parameter data. Must be at least 2 bytes in length. |
size_t rdm_get_num_responses_needed | ( | uint16_t | param_id, |
size_t | response_data_len | ||
) |
Get the number of RDM responses needed to send the given response data.
If this functions returns greater than 1, ACK_OVERFLOW responses must be sent.
This function takes into account parameter data which the RDM standard family requires to be split on specified boundaries.
[in] | param_id | The RDM parameter ID for the response being generated. |
[in] | response_data_len | The length in bytes of the requested response data. |
const char* rdm_nack_reason_to_string | ( | rdm_nack_reason_t | reason_code | ) |
Get a string representation of an RDM NACK reason code.
[in] | reason_code | Reason code for which to get a string representation. |
void rdm_pack_checksum | ( | uint8_t * | buffer, |
size_t | data_len_without_checksum | ||
) |
Calculate and pack an RDM checksum at the end of an RDM message.
[in,out] | buffer | Buffer representing packed RDM message without checksum. Two-byte checksum is packed starting at &buffer[data_len_without_checksum]. |
[in] | data_len_without_checksum | Length of the RDM message without checksum. |
etcpal_error_t rdm_pack_command | ( | const RdmCommandHeader * | cmd_header, |
const uint8_t * | cmd_data, | ||
uint8_t | cmd_data_len, | ||
RdmBuffer * | buffer | ||
) |
Convert an RDM command header and data to the RDM wire format.
[in] | cmd_header | The header data for the command. |
[in] | cmd_data | The parameter data that accompanies the command, or NULL if no data. |
[in] | cmd_data_len | Length in bytes of cmd_data, or 0 if no data. |
[out] | buffer | RdmBuffer struct to hold the serialized command. |
etcpal_error_t rdm_pack_command_with_custom_buf | ( | const RdmCommandHeader * | cmd_header, |
const uint8_t * | cmd_data, | ||
uint8_t | cmd_data_len, | ||
uint8_t * | buf, | ||
size_t | buf_len | ||
) |
Convert an RDM command header and data to the RDM wire format in a user-provided buffer.
[in] | cmd_header | The header data for the command. |
[in] | cmd_data | The parameter data that accompanies the command, or NULL if no data. |
[in] | cmd_data_len | Length in bytes of cmd_data, or 0 if no data. |
[out] | buf | Data buffer to hold the serialized command. |
[out] | buf_len | Length in bytes of buf. |
etcpal_error_t rdm_pack_dub_response | ( | const RdmUid * | responder_uid, |
RdmBuffer * | buffer | ||
) |
Serialize an RDM DISC_UNIQUE_BRANCH response.
The DISC_UNIQUE_BRANCH response does not adhere to the normal RDM packet format and is sent without a break. The only information encoded is this responder's UID.
[in] | responder_uid | UID of the responder responding to the DISC_UNIQUE_BRANCH command. |
[out] | buffer | Data buffer filled in with serialized response. |
etcpal_error_t rdm_pack_full_response | ( | const RdmCommandHeader * | cmd_header, |
const uint8_t * | response_data, | ||
size_t | response_data_len, | ||
RdmBuffer * | buffers, | ||
size_t | num_buffers | ||
) |
Serialize a full RDM ACK response, splitting ACK_OVERFLOW responses if necessary.
This function will pack a potentially-oversized RDM ACK response into one or more RDM buffers, splitting it into ACK_OVERFLOW responses if necessary. It is most often used by higher-level protocols like RDMnet.
[in] | cmd_header | Header from the received RDM command. |
[in] | response_data | The full response parameter data. |
[in] | response_data_len | The length of the response parameter data. |
[out] | buffers | Set of buffers into which to pack serialized RDM ACK_OVERFLOW/ACK responses in order. |
[out] | num_buffers | Size of buffers array. |
etcpal_error_t rdm_pack_nack_response | ( | const RdmCommandHeader * | cmd_header, |
uint8_t | msg_count, | ||
rdm_nack_reason_t | nack_reason, | ||
RdmBuffer * | buffer | ||
) |
Serialize an RDM NACK response to a previously-received command.
Creates and serializes the NACK response into a format suitable for sending on the wire.
[in] | cmd_header | Header from the received RDM command. |
[in] | msg_count | The current queued message count. |
[in] | nack_reason | The RDM NACK reason to send. |
[out] | buffer | Data buffer filled in with serialized response. |
etcpal_error_t rdm_pack_overflow_response | ( | const RdmCommandHeader * | cmd_header, |
const uint8_t * | response_data, | ||
uint8_t | response_data_len, | ||
RdmBuffer * | buffer | ||
) |
Serialize an RDM ACK_OVERFLOW response to a previously-received command.
ACK_OVERFLOW responses represent part of an RDM response whose data is too large to send in a single response. Creates and serializes the ACK_OVERFLOW response into a format suitable for sending on the wire.
[in] | cmd_header | Header from the received RDM command. |
[in] | response_data | The portion of the response parameter data being sent in this overflow response. |
[in] | response_data_len | The length of the response_data. |
[out] | buffer | Data buffer filled in with serialized response. |
etcpal_error_t rdm_pack_response | ( | const RdmCommandHeader * | cmd_header, |
uint8_t | msg_count, | ||
const uint8_t * | response_data, | ||
uint8_t | response_data_len, | ||
RdmBuffer * | buffer | ||
) |
Serialize an RDM ACK response to a previously-received command.
Creates and serializes the ACK response into a format suitable for sending on the wire. Response data must fit in a single response (must be <= RDM_MAX_PDL); if it doesn't, split the data into N chunks and call rdm_pack_overflow_response() for the first N - 1, and this function for the Nth chunk.
[in] | cmd_header | Header from the received RDM command. |
[in] | msg_count | The current queued message count. |
[in] | response_data | (optional) The response parameter data, if any. |
[in] | response_data_len | (optional) The length of the response parameter data, if any. |
[out] | buffer | Data buffer filled in with serialized response. |
etcpal_error_t rdm_pack_timer_response | ( | const RdmCommandHeader * | cmd_header, |
uint8_t | msg_count, | ||
unsigned int | delay_time_ms, | ||
RdmBuffer * | buffer | ||
) |
Serialize an RDM ACK_TIMER response to a previously-received command.
Creates and serializes the ACK_TIMER response into a format suitable for sending on the wire.
[in] | cmd_header | Header from the received RDM command. |
[in] | msg_count | The current queued message count. |
[in] | delay_time_ms | The amount of time in milliseconds before the response will be available. Must be in the range [1, 6553500]. |
[out] | buffer | Data buffer filled in with serialized response. |
bool rdm_response_header_is_valid | ( | const RdmResponseHeader * | resp_header | ) |
Determine whether the values contained in a response header are valid for an RDM response.
[in] | resp_header | Header to validate. |
const char* rdm_response_type_to_string | ( | rdm_response_type_t | resp_type | ) |
Get a string representation of an RDM response type.
[in] | resp_type | Response type for which to get a string representation. |
etcpal_error_t rdm_unpack_command | ( | const RdmBuffer * | buffer, |
RdmCommandHeader * | cmd_header, | ||
const uint8_t ** | param_data, | ||
uint8_t * | param_data_len | ||
) |
Deserialize an RDM command from its wire format.
[in] | buffer | Buffer holding serialized RDM command data. |
[out] | cmd_header | Filled in with the RDM command header data. |
[out] | param_data | Filled in with pointer to the start of the RDM parameter data in the original buffer. |
[out] | param_data_len | Filled in with the length of the RDM parameter data accompanying the command. |
etcpal_error_t rdm_unpack_dub_response | ( | const RdmBuffer * | buffer, |
RdmUid * | responder_uid | ||
) |
Deserialize an RDM DISC_UNIQUE_BRANCH from its wire format.
DISC_UNIQUE_BRANCH (aka DUB) responses have a special format. The only information encoded is the responder's UID.
[in] | buffer | Buffer holding serialized RDM DISC_UNIQUE_BRANCH response data. |
[out] | responder_uid | Filled in with the RDM responder's UID. |
etcpal_error_t rdm_unpack_response | ( | const RdmBuffer * | buffer, |
RdmResponseHeader * | resp_header, | ||
const uint8_t ** | param_data, | ||
uint8_t * | param_data_len | ||
) |
Deserialize an RDM response from its wire format.
[in] | buffer | Buffer holding serialized RDM response data. |
[out] | resp_header | Filled in with the RDM response header data. |
[out] | param_data | Filled in with pointer to the start of the RDM parameter data in the original buffer. |
[out] | param_data_len | Filled in with the length of the RDM parameter data accompanying the response. |
bool rdm_validate_msg | ( | const RdmBuffer * | buffer | ) |
Perform basic validation of a packed RDM message.
Checks that the message has a correctly formed length, the correct start code values, and that the checksum is correct.
[in] | buffer | RDM message to validate. |