RDMnet
0.3.0
Implementation of ANSI E1.33 (RDMnet)
|
View other versions:
|
Handling and responding to RDM commands is the core functionality of RDMnet devices and gateways, and an optional part of the functionality of RDMnet controllers.
RDM commands are delivered via a callback that looks like the below:
An RDM command in RDMnet can be addressed to the default responder or a sub-responder (see Devices and Gateways for more information on these concepts). A command to the default responder addresses the RDM parameters of the device implementing RDMnet. A command to a sub-responder addresses either a portion of the device's functionality dedicated to handling sACN (a virtual responder) or a physical RDM responder connected to an RDMnet gateway.
Besides this special RDMnet addressing information, the RDM command structure delivered with the RDM command handler callback contains data typical to RDM handling logic; the command class, parameter ID, subdevice ID, and parameter data, if any. The only other RDMnet-specific construct is the sequence number, which is only used internally by the library.
This RDMnet library allows two different paradigms for responding to RDM commands: synchronous and asynchronous. The RDMnet Device API will be used as an example, but this also applies to the Controller API if using the RDM responder callbacks.
By the time this callback is called, the library will already have handled some error conditions internally. For example, if the received RDMnet RDM command was malformed, or not addressed to the local RDMnet component, the message will be dropped or an error response will be sent according to the rules of the RDMnet standard.
If you can access the data needed to respond to the RDM command relatively quickly from the code path of the notification callback, it's convenient to respond synchronously. The RDM command notification callbacks provide a way to set the response information directly from the callback, which the library will use to send a response after the callback returns.
Important note: Do not do this when accessing response data may block for a significant time. See "Responding asynchronously" below for that scenario.
There are two different ways to respond synchronously to an RDM command received over RDMnet:
An ACK response indicates that the action in the command was carried out. ACK responses can contain data; for example, the responses to most RDM GET commands contain data that was requested by a controller. When an ACK response contains data, it should be copied into the buffer that was provided when the RDMnet handle was created, before returning from the callback function. All notifications for any given RDMnet handle are delivered from the same thread, so accesses to this buffer from the callback context are thread-safe.
After copying the data, use the API-specific method to indicate that this is an ACK response as shown below.
Most SET commands don't require data in their ACK response; the response is just an acknowledgment that the changed parameter was acted upon. In this case, there's no need to copy any data before responding with an ACK.
A NACK response indicates that the RDMnet command was valid, but the RDM transaction cannot be acted upon for some reason. NACK responses contain a reason code that indicates the reason that the command cannot be acted upon. Common reasons to NACK an RDMnet RDM command include:
To respond with a NACK, use the API-specific method to indicate that this is a NACK response and provide the reason as shown below.
If you choose to defer the response to an RDM command to be sent at a later time, you must ensure that every RDM command gets a response eventually (one of ACK, NACK or RPT Status).
An RPT Status response is an RDMnet protocol level response to an RDM command. Most RPT Status messages (except kRptStatusBroadcastComplete) indicate that something has gone wrong at the RDMnet protocol level and the request cannot be handled. RPT Status responses include a code that indicates the reason for the status message.
Most conditions that would require sending an RPT Status are handled at the library level. The ones that must be handled by the application relate exclusively to the operation of RDMnet Gateways. RPT Status codes that need to be handled by a gateway application include:
The RDM command structures delivered to callbacks by the RDMnet library reference data that is kept in buffers owned by the library, and will be reused for other data when that callback returns. In order to defer responses to RDM commands to be sent later, it's necessary to save the command data to be sent along with its corresponding response.
RDMnet provides APIs for saving the command into different structs and/or classes which contain data buffers to hold the RDM parameter data.
The RDMnet library has all the information necessary to handle certain RDMnet-related RDM commands internally with no intervention by the application. The list of PIDs fully handled by the RDMnet library are:
There is no need to include these PID values in your response to the GET:SUPPORTED_PARAMETERS command; they will be automatically added by the library before sending the response.
Note that the RDMnet standard requires support for additional PIDs that are not handled by the library. If you are using the Controller or Device API, you must support these PIDs in your implementation (or configure the Controller API with RDM data; see Using the Controller API).