lwpa  0.1.0
LightWeight Platform Abstraction (lwpa)
View other versions:
lwpa_uid

Overview

Type and helper functions for the Unique ID (UID) used in the RDM family of protocols.

RDM-based protocols use an identifier called a UID to identify an entity that generates or consumes RDM messages.

The top bit of the UID is reserved for indicating broadcast values, or indicating Dynamic UIDs in ANSI E1.33.

The next 15 bits is the ESTA Manufacturer ID; each manufacturer of RDM equipment has a unique Manufacturer ID registered with ESTA. The MSB of the UID is reserved for indicating broadcast values, or indicating Dynamic UIDs in ANSI E1.33.

The remaining 32 bits is the Device ID. The Device ID is unique within a given scope; in the case of a Static UID, it is unique across all products made by the manufacturer indicated by the ESTA Manufacturer ID. In the case of a Dynamic UID, it is unique within its current E1.33 Scope.

#include "lwpa_uid.h"

Data Structures

struct  LwpaUid
 The UID type. More...
 

Macros

#define uid_cmp(uidptr1, uidptr2)
 Compare two UIDs. More...
 
#define uid_equal(uidptr1, uidptr2)   ((uidptr1)->manu == (uidptr2)->manu && (uidptr1)->id == (uidptr2)->id)
 Determine if two UIDs are equal. More...
 
#define init_static_uid(uidptr, manu_val, id_val)
 Initialize a Static UID with a Manufacturer ID and Device ID. More...
 
#define init_dynamic_uid(uidptr, manu_val, id_val)
 Initialize a Dynamic UID with a Manufacturer ID and Device ID. More...
 
#define uid_is_broadcast(uidptr)   ((uidptr)->manu == kBroadcastUid.manu && (uidptr)->id == kBroadcastUid.id)
 Determine whether a UID is the E1.20 value BROADCAST_ALL_DEVICES_ID. More...
 
#define uid_is_rdmnet_controller_broadcast(uidptr)    ((uidptr)->manu == kRdmnetControllerBroadcastUid.manu && (uidptr)->id == kRdmnetControllerBroadcastUid.id)
 Determine whether a UID is the E1.33 value RPT_ALL_CONTROLLERS. More...
 
#define uid_is_rdmnet_device_broadcast(uidptr)    ((uidptr)->manu == kRdmnetDeviceBroadcastUid.manu && (uidptr)->id == kRdmnetDeviceBroadcastUid.id)
 Determine whether a UID is the E1.33 value RPT_ALL_DEVICES. More...
 
#define uid_is_rdmnet_device_manu_broadcast(uidptr)    ((uidptr)->manu == kRdmnetControllerBroadcastUid.manu && (((uidptr)->id & 0xffffu) == 0xffffu))
 Determine whether a UID is one of the E1.33 values defined by RPT_ALL_MID_DEVICES. More...
 
#define rdmnet_device_broadcast_manu_matches(uidptr, manu_val)   (rdmnet_device_broadcast_manu_id(uidptr) == manu_val)
 Determine whether an RDMnet Device Manufacturer Broadcast UID matches a specific ESTA Manufacturer ID. More...
 
#define rdmnet_device_broadcast_manu_id(uidptr)   ((uint16_t)((uidptr)->id >> 16))
 Get the ESTA Manufacturer ID from an RDMnet Device Manufacturer Broadcast UID. More...
 
#define uid_is_dynamic(uidptr)
 Determine whether a UID is a Dynamic UID as defined in ANSI E1.33. More...
 
#define get_manufacturer_id(uidptr)   ((uidptr)->manu & 0x7fffu)
 Get the ESTA Manufacturer ID from a UID. More...
 
#define get_device_id(uidptr)   ((uidptr)->id)
 Get the Device ID from a UID. More...
 

Typedefs

typedef struct LwpaUid LwpaUid
 The UID type. More...
 

Variables

const LwpaUid kBroadcastUid
 A UID that is equal to BROADCAST_ALL_DEVICES_ID as defined in ANSI E1.20.
 
const LwpaUid kRdmnetControllerBroadcastUid
 A UID that is equal to RPT_ALL_CONTROLLERS as defined in ANSI E1.33.
 
const LwpaUid kRdmnetDeviceBroadcastUid
 A UID that is equal to RPT_ALL_DEVICES as defined in ANSI E1.33.
 

Macro Definition Documentation

◆ get_device_id

#define get_device_id (   uidptr)    ((uidptr)->id)

Get the Device ID from a UID.

Parameters
uidptrPointer to LwpaUid from which to get the Device ID.
Returns
Device ID.

◆ get_manufacturer_id

#define get_manufacturer_id (   uidptr)    ((uidptr)->manu & 0x7fffu)

Get the ESTA Manufacturer ID from a UID.

Parameters
uidptrPointer to LwpaUid from which to get the ESTA Manufacturer ID.
Returns
ESTA Manufacturer ID.

◆ init_dynamic_uid

#define init_dynamic_uid (   uidptr,
  manu_val,
  id_val 
)
Value:
do \
{ \
(uidptr)->manu = (0x8000u | (manu_val)); \
(uidptr)->id = (id_val); \
} while (0)

Initialize a Dynamic UID with a Manufacturer ID and Device ID.

Parameters
uidptrPointer to LwpaUid to initialize.
manu_valESTA Manufacturer ID.
id_valDevice ID.

◆ init_static_uid

#define init_static_uid (   uidptr,
  manu_val,
  id_val 
)
Value:
do \
{ \
(uidptr)->manu = (manu_val); \
(uidptr)->id = (id_val); \
} while (0)

Initialize a Static UID with a Manufacturer ID and Device ID.

Parameters
uidptrPointer to LwpaUid to initialize.
manu_valESTA Manufacturer ID.
id_valDevice ID.

◆ rdmnet_device_broadcast_manu_id

#define rdmnet_device_broadcast_manu_id (   uidptr)    ((uint16_t)((uidptr)->id >> 16))

Get the ESTA Manufacturer ID from an RDMnet Device Manufacturer Broadcast UID.

Use uid_is_rdmnet_device_manu_broadcast() first to determine whether this UID is an RDMnet Device Manufacturer Broadcast.

Parameters
uidptrPointer to LwpaUid from which to get the Broadcast Manufacturer ID.
Returns
ESTA Manufacturer ID.

◆ rdmnet_device_broadcast_manu_matches

#define rdmnet_device_broadcast_manu_matches (   uidptr,
  manu_val 
)    (rdmnet_device_broadcast_manu_id(uidptr) == manu_val)

Determine whether an RDMnet Device Manufacturer Broadcast UID matches a specific ESTA Manufacturer ID.

Use uid_is_rdmnet_device_manu_broadcast() first to determine whether this UID is an RDMnet Device Manufacturer Broadcast.

Parameters
uidptrPointer to LwpaUid to check.
manu_valESTA Manufacturer ID to check against the Broadcast UID.
Returns
true (RDMnet Device Manufacturer Broadcast matches this Manufacturer ID) or false (RDMnet Device Manufacturer Broadcast does not match this Manufacturer ID).

◆ uid_cmp

#define uid_cmp (   uidptr1,
  uidptr2 
)
Value:
(((uidptr1)->manu == (uidptr2)->manu) ? ((int)(uidptr1)->id - (int)(uidptr2)->id) \
: ((int)(uidptr1)->manu - (int)(uidptr2)->manu))

Compare two UIDs.

Parameters
uidptr1Pointer to first LwpaUid to compare.
uidptr2Pointer to second LwpaUid to compare.
Returns
< 0 (uidptr1 is less than uidptr2)
0 (uidptr1 is equal to uidptr2)
> 0 (uidptr1 is greater than uidptr2)

◆ uid_equal

#define uid_equal (   uidptr1,
  uidptr2 
)    ((uidptr1)->manu == (uidptr2)->manu && (uidptr1)->id == (uidptr2)->id)

Determine if two UIDs are equal.

Parameters
uidptr1Pointer to first struct lwpa_uid.
uidptr2Pointer to second struct lwpa_uid.
Returns
true (UIDs are equal) or false (UIDs are not equal).

◆ uid_is_broadcast

#define uid_is_broadcast (   uidptr)    ((uidptr)->manu == kBroadcastUid.manu && (uidptr)->id == kBroadcastUid.id)

Determine whether a UID is the E1.20 value BROADCAST_ALL_DEVICES_ID.

Parameters
uidptrPointer to LwpaUid to check.
Returns
true (uidptr is equal to BROADCAST_ALL_DEVICES_ID) or false (uidptr is not equal to BROADCAST_ALL_DEVICES_ID).

◆ uid_is_dynamic

#define uid_is_dynamic (   uidptr)
Value:
((((uidptr)->manu & 0x8000u) != 0) && !uid_is_rdmnet_controller_broadcast(uidptr) && \
#define uid_is_broadcast(uidptr)
Determine whether a UID is the E1.20 value BROADCAST_ALL_DEVICES_ID.
Definition: lwpa_uid.h:114
#define uid_is_rdmnet_device_manu_broadcast(uidptr)
Determine whether a UID is one of the E1.33 values defined by RPT_ALL_MID_DEVICES.
Definition: lwpa_uid.h:146
#define uid_is_rdmnet_controller_broadcast(uidptr)
Determine whether a UID is the E1.33 value RPT_ALL_CONTROLLERS.
Definition: lwpa_uid.h:121

Determine whether a UID is a Dynamic UID as defined in ANSI E1.33.

Parameters
uidptrPointer to LwpaUid to check.
Returns
true (UID is an E1.33 Dynamic UID) or false (UID is not an E1.33 Dynamic UID).

◆ uid_is_rdmnet_controller_broadcast

#define uid_is_rdmnet_controller_broadcast (   uidptr)     ((uidptr)->manu == kRdmnetControllerBroadcastUid.manu && (uidptr)->id == kRdmnetControllerBroadcastUid.id)

Determine whether a UID is the E1.33 value RPT_ALL_CONTROLLERS.

Parameters
uidptrPointer to LwpaUid to check.
Returns
true (uidptr is equal to RPT_ALL_CONTROLLERS) or false (uidptr is not equal to RPT_ALL_CONTROLLERS).

◆ uid_is_rdmnet_device_broadcast

#define uid_is_rdmnet_device_broadcast (   uidptr)     ((uidptr)->manu == kRdmnetDeviceBroadcastUid.manu && (uidptr)->id == kRdmnetDeviceBroadcastUid.id)

Determine whether a UID is the E1.33 value RPT_ALL_DEVICES.

Parameters
uidptrPointer to LwpaUid to check.
Returns
true (uidptr is equal to RPT_ALL_DEVICES) or false (uidptr is not equal to RPT_ALL_DEVICES).

◆ uid_is_rdmnet_device_manu_broadcast

#define uid_is_rdmnet_device_manu_broadcast (   uidptr)     ((uidptr)->manu == kRdmnetControllerBroadcastUid.manu && (((uidptr)->id & 0xffffu) == 0xffffu))

Determine whether a UID is one of the E1.33 values defined by RPT_ALL_MID_DEVICES.

RDMnet Device Manufacturer Broadcasts are directed to all Devices with a specific ESTA Manufacturer ID. If this check returns true, use rdmnet_device_broadcast_manu_id() to determine which Manufacturer ID this broadcast is directed to, or rdmnet_device_broadcast_manu_matches() to determine whether it matches a specific Manufacturer ID.

Parameters
uidptrPointer to LwpaUid to check.
Returns
true (uidptr is one of the values defined by RPT_ALL_MID_DEVICES) or false (uidptr is not one of the values defined by RPT_ALL_MID_DEVICES).

Typedef Documentation

◆ LwpaUid

typedef struct LwpaUid LwpaUid

The UID type.

Don't forget that the top bit of the manu field has special meaning. The helper macros are your friend!