OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
Loading...
Searching...
No Matches
openlcb_defines.h File Reference

OpenLCB protocol constants, MTI codes, and memory configuration commands. More...

Go to the source code of this file.

Macros

#define OPENLCB_C_LIB_VERSION_MAJOR   1
 
#define OPENLCB_C_LIB_VERSION_MINOR   0
 
#define OPENLCB_C_LIB_VERSION_PATCH   0
 
#define OPENLCB_C_LIB_VERSION   "1.0.0"
 
#define RUNSTATE_INIT   0
 General boot initialization - sets Node ID as initial seed.
 
#define RUNSTATE_GENERATE_SEED   1
 Generate new 48-bit seed from previous seed (used after alias collision)
 
#define RUNSTATE_GENERATE_ALIAS   2
 Generate 12-bit alias from current seed using LFSR algorithm.
 
#define RUNSTATE_LOAD_CHECK_ID_07   3
 Send CID frame 7 with first 12 bits of 48-bit Node ID.
 
#define RUNSTATE_LOAD_CHECK_ID_06   4
 Send CID frame 6 with 2nd 12 bits of 48-bit Node ID.
 
#define RUNSTATE_LOAD_CHECK_ID_05   5
 Send CID frame 5 with 3rd 12 bits of 48-bit Node ID.
 
#define RUNSTATE_LOAD_CHECK_ID_04   6
 Send CID frame 4 with last 12 bits of 48-bit Node ID.
 
#define RUNSTATE_WAIT_200ms   7
 Wait 200ms for alias collision detection. An objection from another node could occur in this or the previous state, if they do then jump back to RUNSTATE_GENERATE_SEED to try again.
 
#define RUNSTATE_LOAD_RESERVE_ID   8
 Send Reserve ID (RID) frame to claim the alias.
 
#define RUNSTATE_LOAD_ALIAS_MAP_DEFINITION   9
 Send Alias Map Definition (AMD) frame, node becomes "Permitted".
 
#define RUNSTATE_LOAD_INITIALIZATION_COMPLETE   10
 Send Initialization Complete message, node becomes "Initialized".
 
#define RUNSTATE_LOAD_CONSUMER_EVENTS   11
 Broadcast all consumer event IDs that this node handles.
 
#define RUNSTATE_LOAD_PRODUCER_EVENTS   12
 Broadcast all producer event IDs that this node generates.
 
#define RUNSTATE_LOGIN_COMPLETE   13
 Callback to allow any startup messages to be sent.
 
#define RUNSTATE_RUN   14
 Normal operation mode - process messages from FIFO.
 
#define RESERVED_TOP_BIT   0x10000000
 Reserved bit in CAN identifier - must always be 0.
 
#define CAN_OPENLCB_MSG   0x08000000
 OpenLCB message indicator - bit 27 set means this is an OpenLCB message, clear means CAN control frame.
 
#define MASK_CAN_FRAME_SEQUENCE_NUMBER   0x07000000
 Mask for frame sequence number bits (26-24) in CAN control frames.
 
#define MASK_CAN_FRAME_TYPE   MASK_CAN_FRAME_SEQUENCE_NUMBER
 Mask for frame type bits (26-24) in OpenLCB messages - same bits as sequence number.
 
#define MASK_CAN_VARIABLE_FIELD   0x00FFF000
 Mask for variable field (bits 23-12) containing MTI in OpenLCB messages.
 
#define OPENLCB_MESSAGE_STANDARD_FRAME_TYPE   0x01000000
 Frame type: Global or addressed OpenLCB message.
 
#define CAN_FRAME_TYPE_DATAGRAM_ONLY   0x02000000
 Frame type: Datagram complete in single frame.
 
#define CAN_FRAME_TYPE_DATAGRAM_FIRST   0x03000000
 Frame type: First frame of multi-frame datagram.
 
#define CAN_FRAME_TYPE_DATAGRAM_MIDDLE   0x04000000
 Frame type: Middle frame of multi-frame datagram.
 
#define CAN_FRAME_TYPE_DATAGRAM_FINAL   0x05000000
 Frame type: Final frame of multi-frame datagram.
 
#define CAN_FRAME_TYPE_RESERVED   0x06000000
 Frame type: Reserved for future use.
 
#define CAN_FRAME_TYPE_STREAM   0x07000000
 Frame type: Stream data frame.
 
#define MTI_INITIALIZATION_COMPLETE   0x0100
 Node initialization complete with full protocol support.
 
#define MTI_INITIALIZATION_COMPLETE_SIMPLE   0x0101
 Node initialization complete - Simple Node Protocol only.
 
#define MTI_VERIFY_NODE_ID_ADDRESSED   0x0488
 Request specific node to identify itself (addressed)
 
#define MTI_VERIFY_NODE_ID_GLOBAL   0x0490
 Request all nodes to identify themselves (global)
 
#define MTI_VERIFIED_NODE_ID   0x0170
 Node ID verification response with full protocol support.
 
#define MTI_VERIFIED_NODE_ID_SIMPLE   0x0171
 Node ID verification response - Simple Node Protocol only.
 
#define MTI_OPTIONAL_INTERACTION_REJECTED   0x0068
 Node cannot or will not process the received message.
 
#define MTI_TERMINATE_DUE_TO_ERROR   0x00A8
 Fatal error detected, node is terminating operation.
 
#define MTI_PROTOCOL_SUPPORT_INQUIRY   0x0828
 Query what protocols a node supports.
 
#define MTI_PROTOCOL_SUPPORT_REPLY   0x0668
 Response indicating supported protocols (6-byte bit field)
 
#define MTI_CONSUMER_IDENTIFY   0x08F4
 Request: Identify all consumers of specified Event ID.
 
#define MTI_CONSUMER_RANGE_IDENTIFIED   0x04A4
 Response: Consumer identifies range of events with mask.
 
#define MTI_CONSUMER_IDENTIFIED_UNKNOWN   0x04C7
 Response: Node consumes event but current state unknown.
 
#define MTI_CONSUMER_IDENTIFIED_SET   0x04C4
 Response: Node consumes event and it is currently SET.
 
#define MTI_CONSUMER_IDENTIFIED_CLEAR   0x04C5
 Response: Node consumes event and it is currently CLEAR.
 
#define MTI_CONSUMER_IDENTIFIED_RESERVED   0x04C6
 Response: Node consumes event in RESERVED state.
 
#define MTI_PRODUCER_IDENTIFY   0x0914
 Request: Identify all producers of specified Event ID.
 
#define MTI_PRODUCER_RANGE_IDENTIFIED   0x0524
 Response: Producer identifies range of events with mask.
 
#define MTI_PRODUCER_IDENTIFIED_UNKNOWN   0x0547
 Response: Node produces event but current state unknown.
 
#define MTI_PRODUCER_IDENTIFIED_SET   0x0544
 Response: Node produces event and it is currently SET.
 
#define MTI_PRODUCER_IDENTIFIED_CLEAR   0x0545
 Response: Node produces event and it is currently CLEAR.
 
#define MTI_PRODUCER_IDENTIFIED_RESERVED   0x0546
 Response: Node produces event in RESERVED state.
 
#define MTI_EVENTS_IDENTIFY_DEST   0x0968
 Request specific node to identify all consumed/produced events.
 
#define MTI_EVENTS_IDENTIFY   0x0970
 Request all nodes to identify all consumed/produced events.
 
#define MTI_EVENT_LEARN   0x0594
 Teaching/learning message for event configuration.
 
#define MTI_PC_EVENT_REPORT   0x05B4
 Producer/Consumer Event Report - event has occurred.
 
#define MTI_PC_EVENT_REPORT_WITH_PAYLOAD   0x0F14
 Event report with payload data.
 
#define MTI_SIMPLE_NODE_INFO_REQUEST   0x0DE8
 Request simple node information from specific node.
 
#define MTI_SIMPLE_NODE_INFO_REPLY   0x0A08
 Response with SNIP data (manufacturer and user info)
 
#define MTI_TRAIN_PROTOCOL   0x05EB
 Train control command (speed, direction, functions)
 
#define MTI_TRAIN_REPLY   0x01E9
 Train control command reply/acknowledgment.
 
#define MTI_SIMPLE_TRAIN_INFO_REQUEST   0x0DA8
 Request train node information.
 
#define MTI_SIMPLE_TRAIN_INFO_REPLY   0x09C8
 Train node information response.
 
#define MTI_STREAM_INIT_REQUEST   0x0CC8
 Request to initiate a stream connection.
 
#define MTI_STREAM_INIT_REPLY   0x0868
 Response accepting or rejecting stream connection.
 
#define MTI_FRAME_TYPE_CAN_STREAM_SEND   0xF000
 Frame type identifier for stream data in CAN frame.
 
#define MTI_STREAM_SEND   0x1F88
 Stream data transmission message.
 
#define MTI_STREAM_PROCEED   0x0888
 Stream flow control - proceed with next window of data.
 
#define MTI_STREAM_COMPLETE   0x08A8
 Stream completed successfully.
 
#define MTI_DATAGRAM   0x1C48
 Datagram message (may be single or multi-frame)
 
#define MTI_DATAGRAM_OK_REPLY   0x0A28
 Datagram received successfully (positive acknowledgment)
 
#define MTI_DATAGRAM_REJECTED_REPLY   0x0A48
 Datagram rejected (negative acknowledgment with error code)
 
#define MASK_MULTIFRAME_BITS   0x30
 Mask for multi-frame indicator bits in first data byte (bits 5-4)
 
#define MULTIFRAME_ONLY   0x00
 Single frame only (complete message in one frame) - ff=00.
 
#define MULTIFRAME_FIRST   0x10
 First frame of multi-frame sequence - ff=01.
 
#define MULTIFRAME_MIDDLE   0x30
 Middle frame of multi-frame sequence - ff=11.
 
#define MULTIFRAME_FINAL   0x20
 Final frame of multi-frame sequence - ff=10.
 
#define MASK_STREAM_OR_DATAGRAM   0x01000
 Bit indicating stream or datagram message type.
 
#define MASK_PRIORITY   0x00C00
 Priority bits (2 bits)
 
#define MASK_SIMPLE_PROTOCOL   0x00010
 Simple protocol indicator bit.
 
#define MASK_DEST_ADDRESS_PRESENT   0x00008
 Destination address present indicator.
 
#define MASK_EVENT_PRESENT   0x00004
 Event ID present indicator.
 
#define MASK_PRIORITY_MODIFIER   0x00003
 Priority modifier bits.
 
#define CAN_CONTROL_FRAME_CID7   0x07000000
 Check ID frame 7 - carries first 12 bits of 48-bit Node ID.
 
#define CAN_CONTROL_FRAME_CID6   0x06000000
 Check ID frame 6 - carries 2nd 12 bits of 48-bit Node ID.
 
#define CAN_CONTROL_FRAME_CID5   0x05000000
 Check ID frame 5 - carries 3rd 12 bits of 48-bit Node ID.
 
#define CAN_CONTROL_FRAME_CID4   0x04000000
 Check ID frame 4 - carries last 12 bits of 48-bit Node ID.
 
#define CAN_CONTROL_FRAME_CID3   0x03000000
 Check ID frame 3 - non-OpenLCB protocol use.
 
#define CAN_CONTROL_FRAME_CID2   0x02000000
 Check ID frame 2 - non-OpenLCB protocol use.
 
#define CAN_CONTROL_FRAME_CID1   0x01000000
 Check ID frame 1 - non-OpenLCB protocol use.
 
#define CAN_CONTROL_FRAME_RID   0x00700000
 Reserve ID frame - claims alias.
 
#define CAN_CONTROL_FRAME_AMD   0x00701000
 Alias Map Definition frame - maps alias to Node ID.
 
#define CAN_CONTROL_FRAME_AME   0x00702000
 Alias Mapping Enquiry frame - query alias ownership.
 
#define CAN_CONTROL_FRAME_AMR   0x00703000
 Alias Map Reset frame - node releasing alias.
 
#define CAN_CONTROL_FRAME_ERROR_INFO_REPORT_0   0x00710000
 Error Information Report frame type 0.
 
#define CAN_CONTROL_FRAME_ERROR_INFO_REPORT_1   0x00711000
 Error Information Report frame type 1.
 
#define CAN_CONTROL_FRAME_ERROR_INFO_REPORT_2   0x00712000
 Error Information Report frame type 2.
 
#define CAN_CONTROL_FRAME_ERROR_INFO_REPORT_3   0x00713000
 Error Information Report frame type 3.
 
#define MASK_CAN_STREAM_OR_DATAGRAM   0x01000000
 Stream or datagram indicator in CAN identifier.
 
#define MASK_CAN_PRIORITY   0x00C00000
 Priority field in CAN identifier.
 
#define MASK_CAN_SIMPLE_PROTOCOL   0x00010000
 Simple protocol indicator in CAN identifier.
 
#define MASK_CAN_DEST_ADDRESS_PRESENT   0x00008000
 Destination address present indicator in CAN identifier.
 
#define MASK_CAN_EVENT_PRESENT   0x00004000
 Event ID present indicator in CAN identifier.
 
#define MASK_CAN_PRIORITY_MODIFIER   0x00003000
 Priority modifier field in CAN identifier.
 
#define MASK_CAN_SOURCE_ALIAS   0x00000FFF
 Source alias field (12 bits) in CAN identifier.
 
#define PSI_SIMPLE   0x800000
 Simple Node Protocol support (not used by this library)
 
#define PSI_DATAGRAM   0x400000
 Datagram Protocol support.
 
#define PSI_STREAM   0x200000
 Stream Protocol support.
 
#define PSI_MEMORY_CONFIGURATION   0x100000
 Memory Configuration Protocol support.
 
#define PSI_RESERVATION   0x080000
 Reservation Protocol support.
 
#define PSI_EVENT_EXCHANGE   0x040000
 Event Exchange (Producer/Consumer) Protocol support.
 
#define PSI_IDENTIFICATION   0x020000
 Identification Protocol support.
 
#define PSI_TEACHING_LEARNING   0x010000
 Teaching/Learning Configuration Protocol support.
 
#define PSI_REMOTE_BUTTON   0x008000
 Remote Button Protocol support.
 
#define PSI_ABBREVIATED_DEFAULT_CDI   0x004000
 Abbreviated Default CDI Protocol support.
 
#define PSI_DISPLAY   0x002000
 Display Protocol support.
 
#define PSI_SIMPLE_NODE_INFORMATION   0x001000
 Simple Node Information Protocol (SNIP) support.
 
#define PSI_CONFIGURATION_DESCRIPTION_INFO   0x000800
 Configuration Description Information (CDI) Protocol support.
 
#define PSI_TRAIN_CONTROL   0x000400
 Train Control Protocol support.
 
#define PSI_FUNCTION_DESCRIPTION   0x000200
 Function Description Information (FDI) Protocol support.
 
#define PSI_RESERVED_0   0x000100
 Reserved bit 0.
 
#define PSI_RESERVED_1   0x000080
 Reserved bit 1.
 
#define PSI_FUNCTION_CONFIGURATION   0x000040
 Function Configuration Protocol support.
 
#define PSI_FIRMWARE_UPGRADE   0x000020
 Firmware Upgrade Protocol support.
 
#define PSI_FIRMWARE_UPGRADE_ACTIVE   0x000010
 Firmware Upgrade Active indicator (node currently in upgrade mode)
 
#define EVENT_ID_EMERGENCY_OFF   0x010000000000FFFF
 Emergency Off - immediately stop all layout activity.
 
#define EVENT_ID_CLEAR_EMERGENCY_OFF   0x010000000000FFFE
 Clear Emergency Off - resume normal operation.
 
#define EVENT_ID_EMERGENCY_STOP   0x010000000000FFFD
 Emergency Stop - stop all moving trains but maintain power.
 
#define EVENT_ID_CLEAR_EMERGENCY_STOP   0x010000000000FFFC
 Clear Emergency Stop - trains may resume operation.
 
#define EVENT_ID_NODE_RECORDED_NEW_LOG   0x010000000000FFF8
 Node has recorded a new log entry.
 
#define EVENT_ID_POWER_SUPPLY_BROWN_OUT_NODE   0x010000000000FFF1
 Power supply brown-out detected on specific node.
 
#define EVENT_ID_POWER_SUPPLY_BROWN_OUT_STANDARD   0x010000000000FFF0
 Power supply brown-out detected on standard power bus.
 
#define EVENT_ID_IDENT_BUTTON_COMBO_PRESSED   0x010000000000FF00
 Identification button combination pressed on node.
 
#define EVENT_ID_LINK_ERROR_CODE_1   0x010000000000FF01
 Link layer error code 1 detected.
 
#define EVENT_ID_LINK_ERROR_CODE_2   0x010000000000FF02
 Link layer error code 2 detected.
 
#define EVENT_ID_LINK_ERROR_CODE_3   0x010000000000FF03
 Link layer error code 3 detected.
 
#define EVENT_ID_LINK_ERROR_CODE_4   0x010000000000FF04
 Link layer error code 4 detected.
 
#define EVENT_ID_DUPLICATE_NODE_DETECTED   0x0101000000000201
 Duplicate Node ID detected on network (sent via PCER)
 
#define EVENT_ID_TRAIN   0x0101000000000303
 Train node identification event.
 
#define EVENT_ID_TRAIN_PROXY   0x0101000000000304
 Train proxy node identification (deprecated)
 
#define EVENT_ID_FIRMWARE_CORRUPTED   0x0101000000000601
 Node firmware is corrupted.
 
#define EVENT_ID_FIRMWARE_UPGRADE_BY_HARDWARE_SWITCH   0x0101000000000602
 Firmware upgrade initiated by hardware switch.
 
#define EVENT_ID_CBUS_OFF_SPACE   0x0101010000000000
 CBUS (MERG) Off event space base.
 
#define EVENT_ID_CBUS_ON_SPACE   0x0101010100000000
 CBUS (MERG) On event space base.
 
#define EVENT_ID_DCC_ACCESSORY_ACTIVATE   0x0101020000FF0000
 DCC accessory decoder activate command space.
 
#define EVENT_ID_DCC_ACCESSORY_DEACTIVATE   0x0101020000FE0000
 DCC accessory decoder deactivate command space.
 
#define EVENT_ID_DCC_TURNOUT_FEEDBACK_HIGH   0x0101020000FD0000
 DCC turnout feedback high (thrown) space.
 
#define EVENT_ID_DCC_TURNOUT_FEEDBACK_LOW   0x0101020000FC0000
 DCC turnout feedback low (closed) space.
 
#define EVENT_ID_DCC_SENSOR_FEEDBACK_HIGH   0x0101020000FB0000
 DCC sensor feedback high (occupied) space.
 
#define EVENT_ID_DCC_SENSOR_FEEDBACK_LO   0x0101020000FA0000
 DCC sensor feedback low (clear) space.
 
#define EVENT_ID_DCC_EXTENDED_ACCESSORY_CMD_SPACE   0x01010200010000FF
 DCC extended accessory command space.
 
#define EVENT_TRAIN_SEARCH_SPACE   0x090099FF00000000
 Train search event space base.
 
#define TRAIN_SEARCH_MASK   0xFFFFFFFF00000000ULL
 Mask for upper 4 bytes of train search event ID.
 
#define TRAIN_SEARCH_FLAG_ALLOCATE   0x80
 Train search flags byte — allocate new node if no match.
 
#define TRAIN_SEARCH_FLAG_EXACT   0x40
 Train search flags byte — exact match only.
 
#define TRAIN_SEARCH_FLAG_ADDRESS_ONLY   0x20
 Train search flags byte — match address only (not name)
 
#define TRAIN_SEARCH_FLAG_DCC   0x08
 Train search flags byte — DCC protocol.
 
#define TRAIN_SEARCH_FLAG_LONG_ADDR   0x04
 Train search flags byte — force long (14-bit) DCC address.
 
#define TRAIN_SEARCH_SPEED_STEP_MASK   0x03
 Train search flags byte — speed step mode mask (bits 1-0)
 
#define TRAIN_MAX_DCC_SHORT_ADDRESS   128
 Maximum DCC short (7-bit) address; addresses >= this are long.
 
#define S_OK   0x00
 Success code - no error.
 
#define ERROR_PERMANENT   0x1000
 Permanent error base code.
 
#define ERROR_PERMANENT_CONFIG_MEM_ADDRESS_SPACE_UNKNOWN   0x1081
 Permanent: Unknown or unsupported address space (0x1080 | 0x0001)
 
#define ERROR_PERMANENT_CONFIG_MEM_OUT_OF_BOUNDS_INVALID_ADDRESS   0x1082
 Permanent: Address is out of bounds for the address space (0x1080 | 0x0002)
 
#define ERROR_PERMANENT_CONFIG_MEM_ADDRESS_WRITE_TO_READ_ONLY   0x1083
 Permanent: Attempted write to read-only memory (0x1080 | 0x0003)
 
#define ERROR_PERMANENT_SOURCE_NOT_PERMITTED   0x1020
 Permanent: Source node not permitted to access this resource.
 
#define ERROR_PERMANENT_NOT_IMPLEMENTED   0x1040
 Permanent: Command or protocol not implemented.
 
#define ERROR_PERMANENT_NOT_IMPLEMENTED_SUBCOMMAND_UNKNOWN   0x1041
 Permanent: Subcommand not recognized.
 
#define ERROR_PERMANENT_NOT_IMPLEMENTED_COMMAND_UNKNOWN   0x1042
 Permanent: Command not recognized.
 
#define ERROR_PERMANENT_NOT_IMPLEMENTED_UNKNOWN_MTI_OR_TRANPORT_PROTOCOL   0x1043
 Permanent: MTI or transport protocol not supported.
 
#define ERROR_CODE_PERMANENT_COUNT_OUT_OF_RANGE   0x1044
 Permanent: Count or length parameter out of valid range.
 
#define ERROR_PERMANENT_INVALID_ARGUMENTS   0x1080
 Permanent: Invalid arguments in command.
 
#define ERROR_TEMPORARY   0x2000
 Temporary error base code.
 
#define ERROR_TEMPORARY_BUFFER_UNAVAILABLE   0x2020
 Temporary: Buffer or resource currently unavailable.
 
#define ERROR_TEMPORARY_NOT_EXPECTED_OUT_OF_ORDER   0x2040
 Temporary: Message received out of expected sequence.
 
#define ERROR_TEMPORARY_TRANSFER_ERROR   0x2080
 Temporary: Transfer error occurred.
 
#define ERROR_TEMPORARY_TIME_OUT   0x2011
 Temporary: Timeout waiting for response.
 
#define ERROR_TEMPORARY_OUT_OF_ORDER_MIDDLE_END_WITH_NO_START   0x2041
 Temporary: Received middle/end frame without start frame.
 
#define ERROR_TEMPORARY_OUT_OF_ORDER_START_BEFORE_LAST_END   0x2042
 Temporary: Received start frame before previous sequence completed.
 
#define DATAGRAM_OK_REPLY_PENDING   0x80
 Datagram OK Reply flag: Response is pending, will send actual reply later.
 
#define CONFIG_MEM_CONFIGURATION   0x20
 Configuration Memory Protocol identifier (first byte of datagram)
 
#define CONFIG_MEM_READ_SPACE_IN_BYTE_6   0x40
 Read command: Address space in byte 6.
 
#define CONFIG_MEM_READ_SPACE_FD   0x41
 Read command: Address space 0xFD.
 
#define CONFIG_MEM_READ_SPACE_FE   0x42
 Read command: Address space 0xFE.
 
#define CONFIG_MEM_READ_SPACE_FF   0x43
 Read command: Address space 0xFF.
 
#define CONFIG_MEM_READ_REPLY_OK_SPACE_IN_BYTE_6   0x50
 Read reply OK: Address space in byte 6.
 
#define CONFIG_MEM_READ_REPLY_OK_SPACE_FD   0x51
 Read reply OK: Address space 0xFD.
 
#define CONFIG_MEM_READ_REPLY_OK_SPACE_FE   0x52
 Read reply OK: Address space 0xFE.
 
#define CONFIG_MEM_READ_REPLY_OK_SPACE_FF   0x53
 Read reply OK: Address space 0xFF.
 
#define CONFIG_MEM_READ_REPLY_FAIL_SPACE_IN_BYTE_6   0x58
 Read reply FAIL: Address space in byte 6.
 
#define CONFIG_MEM_READ_REPLY_FAIL_SPACE_FD   0x59
 Read reply FAIL: Address space 0xFD.
 
#define CONFIG_MEM_READ_REPLY_FAIL_SPACE_FE   0x5A
 Read reply FAIL: Address space 0xFE.
 
#define CONFIG_MEM_READ_REPLY_FAIL_SPACE_FF   0x5B
 Read reply FAIL: Address space 0xFF.
 
#define CONFIG_MEM_READ_STREAM_SPACE_IN_BYTE_6   0x60
 Read stream command: Address space in byte 6.
 
#define CONFIG_MEM_READ_STREAM_SPACE_FD   0x61
 Read stream command: Address space 0xFD.
 
#define CONFIG_MEM_READ_STREAM_SPACE_FE   0x62
 Read stream command: Address space 0xFE.
 
#define CONFIG_MEM_READ_STREAM_SPACE_FF   0x63
 Read stream command: Address space 0xFF.
 
#define CONFIG_MEM_READ_STREAM_REPLY_OK_SPACE_IN_BYTE_6   0x70
 Read stream reply OK: Address space in byte 6.
 
#define CONFIG_MEM_READ_STREAM_REPLY_OK_SPACE_FD   0x71
 Read stream reply OK: Address space 0xFD.
 
#define CONFIG_MEM_READ_STREAM_REPLY_OK_SPACE_FE   0x72
 Read stream reply OK: Address space 0xFE.
 
#define CONFIG_MEM_READ_STREAM_REPLY_OK_SPACE_FF   0x73
 Read stream reply OK: Address space 0xFF.
 
#define CONFIG_MEM_READ_STREAM_REPLY_FAIL_SPACE_IN_BYTE_6   0x78
 Read stream reply FAIL: Address space in byte 6.
 
#define CONFIG_MEM_READ_STREAM_REPLY_FAIL_SPACE_FD   0x79
 Read stream reply FAIL: Address space 0xFD.
 
#define CONFIG_MEM_READ_STREAM_REPLY_FAIL_SPACE_FE   0x7A
 Read stream reply FAIL: Address space 0xFE.
 
#define CONFIG_MEM_READ_STREAM_REPLY_FAIL_SPACE_FF   0x7B
 Read stream reply FAIL: Address space 0xFF.
 
#define CONFIG_MEM_WRITE_SPACE_IN_BYTE_6   0x00
 Write command: Address space in byte 6.
 
#define CONFIG_MEM_WRITE_SPACE_FD   0x01
 Write command: Address space 0xFD.
 
#define CONFIG_MEM_WRITE_SPACE_FE   0x02
 Write command: Address space 0xFE.
 
#define CONFIG_MEM_WRITE_SPACE_FF   0x03
 Write command: Address space 0xFF.
 
#define CONFIG_MEM_WRITE_REPLY_OK_SPACE_IN_BYTE_6   0x10
 Write reply OK: Address space in byte 6.
 
#define CONFIG_MEM_WRITE_REPLY_OK_SPACE_FD   0x11
 Write reply OK: Address space 0xFD.
 
#define CONFIG_MEM_WRITE_REPLY_OK_SPACE_FE   0x12
 Write reply OK: Address space 0xFE.
 
#define CONFIG_MEM_WRITE_REPLY_OK_SPACE_FF   0x13
 Write reply OK: Address space 0xFF.
 
#define CONFIG_MEM_WRITE_REPLY_FAIL_SPACE_IN_BYTE_6   0x18
 Write reply FAIL: Address space in byte 6.
 
#define CONFIG_MEM_WRITE_REPLY_FAIL_SPACE_FD   0x19
 Write reply FAIL: Address space 0xFD.
 
#define CONFIG_MEM_WRITE_REPLY_FAIL_SPACE_FE   0x1A
 Write reply FAIL: Address space 0xFE.
 
#define CONFIG_MEM_WRITE_REPLY_FAIL_SPACE_FF   0x1B
 Write reply FAIL: Address space 0xFF.
 
#define CONFIG_MEM_WRITE_UNDER_MASK_SPACE_IN_BYTE_6   0x08
 Write under mask command: Address space in byte 6.
 
#define CONFIG_MEM_WRITE_UNDER_MASK_SPACE_FD   0x09
 Write under mask command: Address space 0xFD.
 
#define CONFIG_MEM_WRITE_UNDER_MASK_SPACE_FE   0x0A
 Write under mask command: Address space 0xFE.
 
#define CONFIG_MEM_WRITE_UNDER_MASK_SPACE_FF   0x0B
 Write under mask command: Address space 0xFF.
 
#define CONFIG_MEM_WRITE_STREAM_SPACE_IN_BYTE_6   0x20
 Write stream command: Address space in byte 6.
 
#define CONFIG_MEM_WRITE_STREAM_SPACE_FD   0x21
 Write stream command: Address space 0xFD.
 
#define CONFIG_MEM_WRITE_STREAM_SPACE_FE   0x22
 Write stream command: Address space 0xFE.
 
#define CONFIG_MEM_WRITE_STREAM_SPACE_FF   0x23
 Write stream command: Address space 0xFF.
 
#define CONFIG_MEM_WRITE_STREAM_REPLY_OK_SPACE_IN_BYTE_6   0x30
 Write stream reply OK: Address space in byte 6.
 
#define CONFIG_MEM_WRITE_STREAM_REPLY_OK_SPACE_FD   0x31
 Write stream reply OK: Address space 0xFD.
 
#define CONFIG_MEM_WRITE_STREAM_REPLY_OK_SPACE_FE   0x32
 Write stream reply OK: Address space 0xFE.
 
#define CONFIG_MEM_WRITE_STREAM_REPLY_OK_SPACE_FF   0x33
 Write stream reply OK: Address space 0xFF.
 
#define CONFIG_MEM_WRITE_STREAM_REPLY_FAIL_SPACE_IN_BYTE_6   0x38
 Write stream reply FAIL: Address space in byte 6.
 
#define CONFIG_MEM_WRITE_STREAM_REPLY_FAIL_SPACE_FD   0x39
 Write stream reply FAIL: Address space 0xFD.
 
#define CONFIG_MEM_WRITE_STREAM_REPLY_FAIL_SPACE_FE   0x3A
 Write stream reply FAIL: Address space 0xFE.
 
#define CONFIG_MEM_WRITE_STREAM_REPLY_FAIL_SPACE_FF   0x3B
 Write stream reply FAIL: Address space 0xFF.
 
#define CONFIG_MEM_OPTIONS_CMD   0x80
 Get Configuration Options command.
 
#define CONFIG_MEM_OPTIONS_REPLY   0x82
 Get Configuration Options reply.
 
#define CONFIG_MEM_GET_ADDRESS_SPACE_INFO_CMD   0x84
 Get Address Space Information command.
 
#define CONFIG_MEM_GET_ADDRESS_SPACE_INFO_REPLY_NOT_PRESENT   0x86
 Get Address Space Information reply: Space not present.
 
#define CONFIG_MEM_GET_ADDRESS_SPACE_INFO_REPLY_PRESENT   0x87
 Get Address Space Information reply: Space present.
 
#define CONFIG_MEM_RESERVE_LOCK   0x88
 Lock/Reserve command.
 
#define CONFIG_MEM_RESERVE_LOCK_REPLY   0x8A
 Lock/Reserve reply.
 
#define CONFIG_MEM_GET_UNIQUE_ID   0x8C
 Get Unique ID command (request node's unique identifier)
 
#define CONFIG_MEM_GET_UNIQUE_ID_REPLY   0x8D
 Get Unique ID reply.
 
#define CONFIG_MEM_UNFREEZE   0xA0
 Unfreeze command (resume normal operation)
 
#define CONFIG_MEM_FREEZE   0xA1
 Freeze command (suspend operation for configuration)
 
#define CONFIG_MEM_UPDATE_COMPLETE   0xA8
 Indicate update complete command.
 
#define CONFIG_MEM_RESET_REBOOT   0xA9
 Reset/Reboot command.
 
#define CONFIG_MEM_FACTORY_RESET   0xAA
 Factory Reset command (restore defaults)
 
#define CONFIG_MEM_SPACE_CONFIGURATION_DEFINITION_INFO   0xFF
 CDI (Configuration Description Information) space - XML config description.
 
#define CONFIG_MEM_SPACE_ALL   0xFE
 All memory combined - virtual space containing all other spaces.
 
#define CONFIG_MEM_SPACE_CONFIGURATION_MEMORY   0xFD
 Configuration Memory space - user-configurable data.
 
#define CONFIG_MEM_SPACE_ACDI_MANUFACTURER_ACCESS   0xFC
 ACDI Manufacturer space - read-only manufacturer info.
 
#define CONFIG_MEM_SPACE_ACDI_USER_ACCESS   0xFB
 ACDI User space - user-assignable node name and description.
 
#define CONFIG_MEM_SPACE_TRAIN_FUNCTION_DEFINITION_INFO   0xFA
 FDI (Function Description Information) space - train function descriptions.
 
#define CONFIG_MEM_SPACE_TRAIN_FUNCTION_CONFIGURATION_MEMORY   0xF9
 Train Function Configuration Memory space.
 
#define CONFIG_MEM_SPACE_FIRMWARE   0xEF
 Firmware upgrade space.
 
#define CONFIG_MEM_ACDI_MANUFACTURER_VERSION_ADDRESS   0x00
 Address of version byte in ACDI manufacturer space.
 
#define CONFIG_MEM_ACDI_MANUFACTURER_ADDRESS   0x01
 Address of manufacturer name string.
 
#define CONFIG_MEM_ACDI_MODEL_ADDRESS   0x2A
 Address of model name string.
 
#define CONFIG_MEM_ACDI_HARDWARE_VERSION_ADDRESS   0x53
 Address of hardware version string.
 
#define CONFIG_MEM_ACDI_SOFTWARE_VERSION_ADDRESS   0x68
 Address of software version string.
 
#define CONFIG_MEM_ACDI_VERSION_LEN   1
 Length of version field (1 byte)
 
#define CONFIG_MEM_ACDI_MANUFACTURER_LEN   41
 Maximum length of manufacturer name (41 bytes including null)
 
#define CONFIG_MEM_ACDI_MODEL_LEN   41
 Maximum length of model name (41 bytes including null)
 
#define CONFIG_MEM_ACDI_HARDWARE_VERSION_LEN   21
 Maximum length of hardware version (21 bytes including null)
 
#define CONFIG_MEM_ACDI_SOFTWARE_VERSION_LEN   21
 Maximum length of software version (21 bytes including null)
 
#define CONFIG_MEM_USER_MODEL_ADDRESS   0x00
 Address of user-assigned model name (deprecated, use USER_NAME)
 
#define CONFIG_MEM_USER_DESCRIPTION_ADDRESS   0x3F
 Address of user description (deprecated, use proper offset)
 
#define CONFIG_MEM_ACDI_USER_VERSION_ADDRESS   0x00
 Address of version byte in ACDI user space.
 
#define CONFIG_MEM_ACDI_USER_NAME_ADDRESS   0x01
 Address of user-assigned name string.
 
#define CONFIG_MEM_ACDI_USER_DESCRIPTION_ADDRESS   0x40
 Address of user description string.
 
#define CONFIG_MEM_ACDI_USER_VERSION_LEN   1
 Length of version field (1 byte)
 
#define CONFIG_MEM_ACDI_USER_NAME_LEN   63
 Maximum length of user name (63 bytes including null)
 
#define CONFIG_MEM_ACDI_USER_DESCRIPTION_LEN   64
 Maximum length of user description (64 bytes including null)
 
#define CONFIG_MEM_CONFIG_USER_NAME_OFFSET   0x00000000
 Offset of user name in Configuration Memory (0xFD) address space.
 
#define CONFIG_MEM_CONFIG_USER_DESCRIPTION_OFFSET   63 /* CONFIG_MEM_ACDI_USER_NAME_LEN (63) */
 Offset of user description in Configuration Memory (0xFD) address space.
 
#define CONFIG_MEM_REPLY_OK_OFFSET   0x10
 Offset to add to command code to get OK reply code.
 
#define CONFIG_MEM_REPLY_FAIL_OFFSET   0x18
 Offset to add to command code to get FAIL reply code.
 
#define CONFIG_OPTIONS_COMMANDS_WRITE_UNDER_MASK   0x8000
 Write Under Mask command supported.
 
#define CONFIG_OPTIONS_COMMANDS_UNALIGNED_READS   0x4000
 Unaligned read operations supported.
 
#define CONFIG_OPTIONS_COMMANDS_UNALIGNED_WRITES   0x2000
 Unaligned write operations supported.
 
#define CONFIG_OPTIONS_COMMANDS_ACDI_MANUFACTURER_READ   0x0800
 ACDI Manufacturer space (0xFC) readable.
 
#define CONFIG_OPTIONS_COMMANDS_ACDI_USER_READ   0x0400
 ACDI User space (0xFB) readable.
 
#define CONFIG_OPTIONS_COMMANDS_ACDI_USER_WRITE   0x0200
 ACDI User space (0xFB) writable.
 
#define CONFIG_OPTIONS_WRITE_LENGTH_RESERVED   (0x80 | 0x40 | 0x20 | 0x02)
 Reserved bits in write length field.
 
#define CONFIG_OPTIONS_WRITE_LENGTH_STREAM_READ_WRITE   0x01
 Stream read/write supported.
 
#define CONFIG_OPTIONS_SPACE_INFO_FLAG_READ_ONLY   0x01
 Address space is read-only.
 
#define CONFIG_OPTIONS_SPACE_INFO_FLAG_USE_LOW_ADDRESS   0x02
 Low address field is valid and should be used.
 
#define MAX_INTERNAL_ENUM_KEYS_VALUES   4
 Maximum number of enumeration keys available for user/application.
 
#define MAX_USER_ENUM_KEYS_VALUES   4
 Maximum number of internal system enumeration keys.
 
#define USER_ENUM_KEYS_VALUES_1   0
 User enumeration key 1.
 
#define USER_ENUM_KEYS_VALUES_2   1
 User enumeration key 2.
 
#define USER_ENUM_KEYS_VALUES_3   2
 User enumeration key 3.
 
#define USER_ENUM_KEYS_VALUES_4   3
 User enumeration key 4.
 
#define MAX_NODE_ENUM_KEY_VALUES   (MAX_USER_ENUM_KEYS_VALUES + MAX_INTERNAL_ENUM_KEYS_VALUES)
 Total number of enumeration keys (user + internal)
 
#define OPENLCB_MAIN_STATMACHINE_NODE_ENUMERATOR_INDEX   MAX_USER_ENUM_KEYS_VALUES
 Enumeration key used by main OpenLCB state machine.
 
#define OPENLCB_LOGIN_STATMACHINE_NODE_ENUMERATOR_INDEX   (MAX_USER_ENUM_KEYS_VALUES + 1)
 Enumeration key used by login state machine.
 
#define CAN_STATEMACHINE_NODE_ENUMRATOR_KEY   (MAX_USER_ENUM_KEYS_VALUES + 2)
 Enumeration key used by CAN state machine.
 
#define DATAGRAM_TIMEOUT_ENUM_KEY   (MAX_USER_ENUM_KEYS_VALUES + 3)
 Enumeration key used by datagram timeout scanner.
 
#define BROADCAST_TIME_ID_DEFAULT_FAST_CLOCK   0x0101000001000000ULL
 Default Fast Clock identifier (upper 6 bytes of Event ID)
 
#define BROADCAST_TIME_ID_DEFAULT_REALTIME_CLOCK   0x0101000001010000ULL
 Default Real-time Clock identifier (upper 6 bytes of Event ID)
 
#define BROADCAST_TIME_ID_ALTERNATE_CLOCK_1   0x0101000001020000ULL
 Alternate Clock 1 identifier (upper 6 bytes of Event ID)
 
#define BROADCAST_TIME_ID_ALTERNATE_CLOCK_2   0x0101000001030000ULL
 Alternate Clock 2 identifier (upper 6 bytes of Event ID)
 
#define BROADCAST_TIME_MASK_CLOCK_ID   0xFFFFFFFFFFFF0000ULL
 Mask for extracting clock ID (upper 6 bytes) from Event ID.
 
#define BROADCAST_TIME_MASK_COMMAND_DATA   0x000000000000FFFFULL
 Mask for extracting command/data (lower 2 bytes) from Event ID.
 
#define BROADCAST_TIME_REPORT_TIME_BASE   0x0000
 Report Time event base (lower 2 bytes: 0x0000-0x17FF)
 
#define BROADCAST_TIME_REPORT_DATE_BASE   0x2100
 Report Date event base (lower 2 bytes: 0x2100-0x2CFF)
 
#define BROADCAST_TIME_REPORT_YEAR_BASE   0x3000
 Report Year event base (lower 2 bytes: 0x3000-0x3FFF)
 
#define BROADCAST_TIME_REPORT_RATE_BASE   0x4000
 Report Rate event base (lower 2 bytes: 0x4000-0x4FFF)
 
#define BROADCAST_TIME_SET_TIME_BASE   0x8000
 Set Time event base (lower 2 bytes: 0x8000-0x97FF)
 
#define BROADCAST_TIME_SET_DATE_BASE   0xA100
 Set Date event base (lower 2 bytes: 0xA100-0xACFF)
 
#define BROADCAST_TIME_SET_YEAR_BASE   0xB000
 Set Year event base (lower 2 bytes: 0xB000-0xBFFF)
 
#define BROADCAST_TIME_SET_RATE_BASE   0xC000
 Set Rate event base (lower 2 bytes: 0xC000-0xCFFF)
 
#define BROADCAST_TIME_QUERY   0xF000
 Query event (lower 2 bytes: 0xF000) - request synchronization.
 
#define BROADCAST_TIME_STOP   0xF001
 Stop event (lower 2 bytes: 0xF001) - stop clock.
 
#define BROADCAST_TIME_START   0xF002
 Start event (lower 2 bytes: 0xF002) - start clock.
 
#define BROADCAST_TIME_DATE_ROLLOVER   0xF003
 Date Rollover event (lower 2 bytes: 0xF003) - midnight crossing.
 
#define BROADCAST_TIME_SET_COMMAND_OFFSET   0x8000
 Offset to convert Report commands to Set commands (add 0x8000)
 
#define TRAIN_INSTRUCTION_P_BIT   0x80
 Bit 7 of the instruction byte: P=1 for train-to-listener forwarded commands.
 
#define TRAIN_SET_SPEED_DIRECTION   0x00
 Set speed and direction: [0x00] [speed_hi] [speed_lo] (float16)
 
#define TRAIN_SET_FUNCTION   0x01
 Set function: [0x01] [addr2] [addr1] [addr0] [val_hi] [val_lo].
 
#define TRAIN_EMERGENCY_STOP   0x02
 Emergency stop: [0x02].
 
#define TRAIN_QUERY_SPEEDS   0x10
 Query speeds: [0x10].
 
#define TRAIN_QUERY_FUNCTION   0x11
 Query function: [0x11] [addr2] [addr1] [addr0].
 
#define TRAIN_CONTROLLER_CONFIG   0x20
 Controller configuration: [0x20] [sub-cmd] ...
 
#define TRAIN_LISTENER_CONFIG   0x30
 Listener configuration: [0x30] [sub-cmd] ...
 
#define TRAIN_MANAGEMENT   0x40
 Management commands: [0x40] [sub-cmd].
 
#define TRAIN_CONTROLLER_ASSIGN   0x01
 Assign controller: [0x20] [0x01] [node_id 6B].
 
#define TRAIN_CONTROLLER_RELEASE   0x02
 Release controller: [0x20] [0x02] [node_id 6B].
 
#define TRAIN_CONTROLLER_QUERY   0x03
 Query controller: [0x20] [0x03].
 
#define TRAIN_CONTROLLER_CHANGED   0x04
 Controller changed notify: [0x20] [0x04] [node_id 6B].
 
#define TRAIN_LISTENER_ATTACH   0x01
 Attach listener: [0x30] [0x01] [flags] [node_id 6B].
 
#define TRAIN_LISTENER_DETACH   0x02
 Detach listener: [0x30] [0x02] [flags] [node_id 6B].
 
#define TRAIN_LISTENER_QUERY   0x03
 Query listener: [0x30] [0x03] [index (opt)].
 
#define TRAIN_MGMT_RESERVE   0x01
 Reserve train node: [0x40] [0x01].
 
#define TRAIN_MGMT_RELEASE   0x02
 Release train node: [0x40] [0x02].
 
#define TRAIN_MGMT_NOOP   0x03
 Heartbeat noop: [0x40] [0x03].
 
#define TRAIN_LISTENER_FLAG_REVERSE   0x02
 Reverse of train in consist.
 
#define TRAIN_LISTENER_FLAG_LINK_F0   0x04
 Link F0 (headlight) with consist lead.
 
#define TRAIN_LISTENER_FLAG_LINK_FN   0x08
 Link Fn functions with consist lead.
 
#define TRAIN_LISTENER_FLAG_HIDE   0x80
 Hide this listener from enumeration.
 

Detailed Description

OpenLCB protocol constants, MTI codes, and memory configuration commands.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

All numeric constants for the OpenLCB library in one place: login states, CAN frame fields, MTIs, error codes, Config Mem commands, Broadcast Time event IDs, Train Control instruction bytes, and well-known events.

Author
Jim Kueneman
Date
9 Mar 2026

Macro Definition Documentation

◆ OPENLCB_C_LIB_VERSION_MAJOR

#define OPENLCB_C_LIB_VERSION_MAJOR   1

◆ OPENLCB_C_LIB_VERSION_MINOR

#define OPENLCB_C_LIB_VERSION_MINOR   0

◆ OPENLCB_C_LIB_VERSION_PATCH

#define OPENLCB_C_LIB_VERSION_PATCH   0

◆ OPENLCB_C_LIB_VERSION

#define OPENLCB_C_LIB_VERSION   "1.0.0"

Copyright (c) 2026 Jim Kueneman all rights reserved. See the License