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... | |
int RDMUtil_AppendChecksum | ( | uint8_t * | frame | ) |
Append the RDM checksum for a frame.
frame | The RDM frame. |
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.
our_uid | The UID of the responder to check |
uid | The UID to check. |
Action is required if any of the following is true:
unsigned int RDMUtil_SafeStringLength | ( | const char * | str, |
unsigned int | max_size | ||
) |
Calculate the size of the string, but never scan beyond max_size.
str | The string |
max_size | The max size of the string. |
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.
dst | The location to copy to. |
dest_size | The maximum number of bytes to copy to dst. |
src | The location to copy from. |
max_size | The maximum number of characters to copy. |
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.
|
inlinestatic |
Compare two UIDs.
uid1 | The first uid. |
uid2 | The second uid. |
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.
sensor | The sensor to update |
recorded_value_support | The bitfield to check if the sensor supports recording. |
new_value | The new value of the sensor. |
bool RDMUtil_VerifyChecksum | ( | const uint8_t * | frame, |
unsigned int | size | ||
) |
Verify the checksum of an RDM frame.
frame | The frame data, beginning with the start code. |
size | The size of the frame data. |
Frame sizes less than the minimum RDM frame size (26 bytes) will always return false.