OLE Developer Guide  Latest Git
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
RDM Helper functions

Detailed Description

RDM Helper Functions.

Files

file  rdm_util.h
 RDM Helper functions.
 

Functions

static int RDMUtil_UIDCompare (const uint8_t *uid1, const uint8_t *uid2)
 Compare two UIDs. More...
 
bool RDMUtil_RequiresAction (const uint8_t our_uid[UID_LENGTH], const uint8_t uid[UID_LENGTH])
 Check if a RDM request sent to a UID requires us to take action. More...
 
bool RDMUtil_IsUnicast (const uint8_t uid[UID_LENGTH])
 
bool RDMUtil_VerifyChecksum (const uint8_t *frame, unsigned int size)
 Verify the checksum of an RDM frame. More...
 
int RDMUtil_AppendChecksum (uint8_t *frame)
 Append the RDM checksum for a frame. More...
 
unsigned int RDMUtil_StringCopy (char *dst, unsigned int dest_size, const char *src, unsigned int max_size)
 Copy a string from one location to another. More...
 
unsigned int RDMUtil_SafeStringLength (const char *str, unsigned int max_size)
 Calculate the size of the string, but never scan beyond max_size. More...
 
void RDMUtil_UpdateSensor (SensorData *sensor, uint8_t recorded_value_support, int16_t new_value)
 Update the value of a sensor, setting the lowest / highest values if appropriate. More...
 

Function Documentation

int RDMUtil_AppendChecksum ( uint8_t *  frame)

Append the RDM checksum for a frame.

Parameters
frameThe RDM frame.
Returns
The size of the complete RDM frame.
Precondition
The frame points to a well formed RDM message.
bool RDMUtil_RequiresAction ( const uint8_t  our_uid[UID_LENGTH],
const uint8_t  uid[UID_LENGTH] 
)

Check if a RDM request sent to a UID requires us to take action.

Parameters
our_uidThe UID of the responder to check
uidThe UID to check.
Returns
true if we should process the RDM request, false otherwise.

Action is required if any of the following is true:

  • The UID exactly matches our UID.
  • The UID is the broadcast UID (ffff:ffffffff)
  • The UID is a vendorcast UID, and the manufacturer ID matches ours.
unsigned int RDMUtil_SafeStringLength ( const char *  str,
unsigned int  max_size 
)

Calculate the size of the string, but never scan beyond max_size.

Parameters
strThe string
max_sizeThe max size of the string.
Returns
The size of the string, at most max_size.

Since RDM strings may be missing the NULL terminator, this should be used when determining string lengths.

unsigned int RDMUtil_StringCopy ( char *  dst,
unsigned int  dest_size,
const char *  src,
unsigned int  max_size 
)

Copy a string from one location to another.

Parameters
dstThe location to copy to.
dest_sizeThe maximum number of bytes to copy to dst.
srcThe location to copy from.
max_sizeThe maximum number of characters to copy.
Returns
The size of the final string, excluding any NULL if there is one.

RDM strings are not required to have a NULL terminator, which means we can't use the usual string functions like strncpy(). This function should be used when copying strings.

static int RDMUtil_UIDCompare ( const uint8_t *  uid1,
const uint8_t *  uid2 
)
inlinestatic

Compare two UIDs.

Parameters
uid1The first uid.
uid2The second uid.
Returns
< 0 if uid1 < uid2, 0 if the UIDs are the same, > 0 if uid1 > uid2.
void RDMUtil_UpdateSensor ( SensorData sensor,
uint8_t  recorded_value_support,
int16_t  new_value 
)

Update the value of a sensor, setting the lowest / highest values if appropriate.

Parameters
sensorThe sensor to update
recorded_value_supportThe bitfield to check if the sensor supports recording.
new_valueThe new value of the sensor.
bool RDMUtil_VerifyChecksum ( const uint8_t *  frame,
unsigned int  size 
)

Verify the checksum of an RDM frame.

Parameters
frameThe frame data, beginning with the start code.
sizeThe size of the frame data.
Returns
True if the checksum was correct, false otherwise.

Frame sizes less than the minimum RDM frame size (26 bytes) will always return false.