Appendix D — Event ID Encoding Reference

Event IDs are 64-bit (8-byte) values carried in Producer/Consumer Event Report (PCER) messages and identification messages. This appendix documents the well-known event IDs, broadcast time encoding, train search encoding, and range encoding used by the library.

D.1 Well-Known Events: Auto-Routed

Events in the 0x0100000000xxxxxx range are automatically forwarded by gateways between network segments:

ConstantEvent IDDescription
EVENT_ID_EMERGENCY_OFF0x010000000000FFFFEmergency Off -- immediately stop all layout activity
EVENT_ID_CLEAR_EMERGENCY_OFF0x010000000000FFFEClear Emergency Off -- resume normal operation
EVENT_ID_EMERGENCY_STOP0x010000000000FFFDEmergency Stop -- stop all trains but maintain power
EVENT_ID_CLEAR_EMERGENCY_STOP0x010000000000FFFCClear Emergency Stop -- trains may resume
EVENT_ID_NODE_RECORDED_NEW_LOG0x010000000000FFF8Node has recorded a new log entry
EVENT_ID_POWER_SUPPLY_BROWN_OUT_NODE0x010000000000FFF1Power supply brown-out detected on specific node
EVENT_ID_POWER_SUPPLY_BROWN_OUT_STANDARD0x010000000000FFF0Power supply brown-out on standard power bus
EVENT_ID_IDENT_BUTTON_COMBO_PRESSED0x010000000000FF00Identification button combination pressed
EVENT_ID_LINK_ERROR_CODE_10x010000000000FF01Link layer error code 1
EVENT_ID_LINK_ERROR_CODE_20x010000000000FF02Link layer error code 2
EVENT_ID_LINK_ERROR_CODE_30x010000000000FF03Link layer error code 3
EVENT_ID_LINK_ERROR_CODE_40x010000000000FF04Link layer error code 4

D.2 Well-Known Events: Non-Auto-Routed

Events in the 0x0101xxxxxxxxxxxx range are segment-local and not forwarded by gateways:

ConstantEvent IDDescription
EVENT_ID_DUPLICATE_NODE_DETECTED0x0101000000000201Duplicate Node ID detected on network
EVENT_ID_TRAIN0x0101000000000303Train node identification event
EVENT_ID_TRAIN_PROXY0x0101000000000304Train proxy identification (deprecated)
EVENT_ID_FIRMWARE_CORRUPTED0x0101000000000601Node firmware is corrupted
EVENT_ID_FIRMWARE_UPGRADE_BY_HARDWARE_SWITCH0x0101000000000602Firmware upgrade initiated by hardware switch

D.3 Broadcast Time Event Encoding

Broadcast time events use 8-byte Event IDs where the upper 6 bytes identify the clock and the lower 2 bytes encode the time data or command:

Event ID layout:
Bytes 0-5: Clock ID (identifies which clock)
Bytes 6-7: Command/Data (time, date, year, rate, or control command)

Example: Default Fast Clock, Report Time 14:30
  Clock ID: 01.01.00.00.01.00
  Data:     0E.1E  (hour=14 in bits 12-8, minute=30 in bits 7-0)
  Event ID: 01.01.00.00.01.00.0E.1E

Clock Identifiers

ConstantClock ID (6 bytes)Description
BROADCAST_TIME_ID_DEFAULT_FAST_CLOCK01.01.00.00.01.00Default Fast Clock
BROADCAST_TIME_ID_DEFAULT_REALTIME_CLOCK01.01.00.00.01.01Default Real-time Clock
BROADCAST_TIME_ID_ALTERNATE_CLOCK_101.01.00.00.01.02Alternate Clock 1
BROADCAST_TIME_ID_ALTERNATE_CLOCK_201.01.00.00.01.03Alternate Clock 2

Data Type Ranges (Lower 2 Bytes)

ConstantRangeDescription
BROADCAST_TIME_REPORT_TIME_BASE0x0000-0x17FFReport Time: hour (bits 12-8) + minute (bits 7-0)
BROADCAST_TIME_REPORT_DATE_BASE0x2100-0x2CFFReport Date: month (bits 11-8) + day (bits 7-0)
BROADCAST_TIME_REPORT_YEAR_BASE0x3000-0x3FFFReport Year: year (bits 11-0)
BROADCAST_TIME_REPORT_RATE_BASE0x4000-0x4FFFReport Rate: 12-bit signed fixed-point (2 fractional bits)
BROADCAST_TIME_SET_TIME_BASE0x8000-0x97FFSet Time command (same encoding as Report Time)
BROADCAST_TIME_SET_DATE_BASE0xA100-0xACFFSet Date command (same encoding as Report Date)
BROADCAST_TIME_SET_YEAR_BASE0xB000-0xBFFFSet Year command (same encoding as Report Year)
BROADCAST_TIME_SET_RATE_BASE0xC000-0xCFFFSet Rate command (same encoding as Report Rate)
BROADCAST_TIME_QUERY0xF000Query -- request synchronization
BROADCAST_TIME_STOP0xF001Stop clock
BROADCAST_TIME_START0xF002Start clock
BROADCAST_TIME_DATE_ROLLOVER0xF003Date Rollover (midnight crossing)

D.4 Train Search Event Encoding

Train search events use the 09.00.99.FF prefix. The lower 4 bytes encode the search address and flags:

Event ID: 09.00.99.FF.xx.xx.xx.xx

Bytes 4-6: Search address encoded as 6 BCD nibbles, MSB first
           Short queries padded with 0xF nibbles
Byte 7:   Flags byte

Train Search Flags

ConstantValueDescription
TRAIN_SEARCH_FLAG_ALLOCATE0x80Allocate new train node if no match found
TRAIN_SEARCH_FLAG_EXACT0x40Exact match only (no partial matching)
TRAIN_SEARCH_FLAG_ADDRESS_ONLY0x20Match address only (not name)
TRAIN_SEARCH_FLAG_DCC0x08DCC protocol
TRAIN_SEARCH_FLAG_LONG_ADDR0x04Force long (14-bit) DCC address
TRAIN_SEARCH_SPEED_STEP_MASK0x03Speed step mode (bits 1-0): 0=default, 1=14, 2=28, 3=128

D.5 Event Range Encoding

Event ranges allow a node to express interest in a contiguous block of Event IDs using a single identification message. The range is defined by a base Event ID and a power-of-2 count:

// Range structure
typedef struct {
    event_id_t start_base;              // Starting Event ID
    event_range_count_enum event_count; // Number of consecutive IDs
} event_id_range_t;

Supported range sizes (defined in event_range_count_enum):

Enum ValueRange Size
EVENT_RANGE_COUNT_11 (single event)
EVENT_RANGE_COUNT_22
EVENT_RANGE_COUNT_44
EVENT_RANGE_COUNT_88
EVENT_RANGE_COUNT_1616
...(powers of 2)
EVENT_RANGE_COUNT_3276832768
Source Reference

Well-known event IDs are defined in openlcb_defines.h (groups well_known_events_auto and well_known_events_local). Broadcast time constants are in the broadcast_time_events group. Train search constants are in the well_known_events_local group. Range types are in openlcb_types.h.

← Prev: Appendix C — Address Spaces Next: Appendix E — Compile-Time Config →