RDMnet APIs are non-ownership-transferring ; this means that when calling API functions that take pointers to data buffers as arguments, the data buffer memory is owned by the caller, and the caller is responsible for managing that memory both before and after the API function call.
For example, consider sending an RDM command with parameter data using the RDMnet controller API:
C
C++
#include <stdlib.h>
#include <stdint.h>
uint8_t* device_label_data = (uint8_t*)
malloc (32);
strcpy (device_label_data,
"New Device Label" );
uint32_t cmd_seq_num;
E120_DEVICE_LABEL, device_label_data,
strlen (device_label_data), &cmd_seq_num);
uint8_t device_label_data[32];
Definitions for the RDMnet Controller API.
#define RDMNET_ADDR_TO_DEFAULT_RESPONDER(manu_id, dev_id)
Initialize an RdmnetDestinationAddr with a default responder address.
Definition: client.h:106
etcpal_error_t rdmnet_controller_send_set_command(rdmnet_controller_t controller_handle, rdmnet_client_scope_t scope_handle, const RdmnetDestinationAddr *destination, uint16_t param_id, const uint8_t *data, uint8_t data_len, uint32_t *seq_num)
Send an RDM SET command from a controller on a scope.
Definition: controller.c:653
A destination address for an RDM command in RDMnet's RPT protocol.
Definition: client.h:84
#include <string>
reinterpret_cast< const uint8_t*
> (device_label.
c_str ()),
static constexpr DestinationAddr ToDefaultResponder(const rdm::Uid &rdmnet_uid, uint16_t subdevice=0)
Get a DestinationAddr representing a message addressed to a component's default responder.
Definition: client.h:94
C++ wrapper for the RDMnet Controller API.
Callbacks
The same non-ownership-transferring principle applies to callbacks delivered from the RDMnet library. The library retains ownership of any data buffers supplied to a callback; if a library user wants to access that data after the callback returns, it must be saved.
The API provides convenient saving functions to make copies of data buffers present in commands. Of course, data can also be saved manually from the data members.
C
C++
{
}
etcpal_error_t rdmnet_free_saved_rdm_response(RdmnetSavedRdmResponse *saved_response)
Free the memory owned by a saved RDM response.
Definition: message.c:265
int rdmnet_client_scope_t
A handle to a scope that an RDMnet client participates in.
Definition: client.h:41
etcpal_error_t rdmnet_save_rdm_response(const RdmnetRdmResponse *response, RdmnetSavedRdmResponse *saved_response)
Save the data in a received RDM response for later use from a different context.
Definition: message.c:102
int rdmnet_controller_t
A handle to an RDMnet controller.
Definition: controller.h:54
An RDMnet RDM response received by a local component.
Definition: message.h:90
size_t rdm_data_len
The length of the parameter data associated with the RDM response.
Definition: message.h:118
const uint8_t * rdm_data
Any parameter data associated with the RDM response.
Definition: message.h:116
An RDM response received over RDMnet and saved for later processing.
Definition: message.h:138
{
}
rdmnet_controller_t Handle
A handle type used by the RDMnet library to identify controller instances.
Definition: controller.h:62
An RDM response received over RDMnet and delivered to an RDMnet callback function.
Definition: rdm_response.h:47
constexpr const uint8_t * data() const noexcept
Get a pointer to the RDM parameter data buffer contained within this response.
Definition: rdm_response.h:279
SavedRdmResponse Save() const
Save the data in this response for later use from a different context.
Definition: rdm_response.h:411
std::vector< uint8_t > GetData() const
Copy out the data in a RdmResponse.
Definition: rdm_response.h:374
constexpr size_t data_len() const noexcept
Get the length of the RDM parameter data contained within this response.
Definition: rdm_response.h:285
An RDM response received over RDMnet and saved for later processing.
Definition: rdm_response.h:111
rdmnet_client_scope_t ScopeHandle
A handle to a scope that an RDMnet client participates in.
Definition: client.h:447