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

Core type definitions, structures, and configuration constants for the OpenLCB library. More...

Go to the source code of this file.

Data Structures

struct  event_id_struct_t
 Event ID paired with its current status. More...
 
struct  event_id_range_t
 Contiguous range of Event IDs starting at a base address. More...
 
struct  broadcast_time_t
 Broadcast Time hour/minute. More...
 
struct  broadcast_date_t
 Broadcast Time month/day. More...
 
struct  broadcast_year_t
 Broadcast Time year. More...
 
struct  broadcast_rate_t
 Broadcast Time clock rate (12-bit signed fixed point, 2 fractional bits). More...
 
struct  broadcast_clock_state_t
 Complete state for one Broadcast Time clock. More...
 
struct  broadcast_clock_t
 A clock slot with state and subscription flags. More...
 
struct  openlcb_msg_state_t
 Message buffer allocation/assembly state flags. More...
 
union  openlcb_msg_timer_t
 Timer field union for openlcb_msg_t. More...
 
struct  openlcb_msg_t
 Core OpenLCB message structure. More...
 
struct  message_buffer_t
 Master buffer storage: message structures + segregated payload pools. More...
 
struct  user_snip_struct_t
 SNIP identification strings (manufacturer + user version byte). More...
 
struct  user_configuration_options
 Capability flags returned by Get Configuration Options command. More...
 
struct  user_address_space_info_t
 Properties of a single configuration memory address space. More...
 
struct  node_parameters_TAG
 Complete node configuration parameters (typically const/flash). More...
 
struct  event_id_enum_t
 Event list enumeration state. More...
 
struct  event_id_consumer_list_t
 List of events consumed by a node. More...
 
struct  event_id_producer_list_t
 List of events produced by a node. More...
 
struct  openlcb_node_state_t
 Bit-packed node state flags. More...
 
struct  train_listener_entry_t
 A single listener entry for a train consist. More...
 
struct  train_state_TAG
 Mutable runtime state for a single train node. More...
 
struct  openlcb_node_TAG
 OpenLCB virtual node. More...
 
struct  openlcb_nodes_t
 Collection of all virtual nodes. More...
 
struct  openlcb_statemachine_worker_t
 State machine temporary working buffers. More...
 
struct  openlcb_stream_message_t
 Message with inline STREAM-sized payload. More...
 
struct  openlcb_outgoing_stream_msg_info_t
 Outgoing message context for the main state machine. More...
 
struct  openlcb_incoming_msg_info_t
 Incoming message context. More...
 
struct  openlcb_statemachine_info_t
 Complete context passed to protocol handler functions. More...
 
struct  openlcb_basic_message_t
 Message with inline BASIC-sized payload. More...
 
struct  openlcb_outgoing_basic_msg_info_t
 Outgoing message context for the login state machine. More...
 
struct  openlcb_login_statemachine_info_t
 Login state machine context. More...
 
struct  config_mem_operations_request_info_TAG
 Request info for Get Options / Get Address Space Info commands. More...
 
struct  config_mem_read_request_info_TAG
 Request info for a configuration memory read operation. More...
 
struct  config_mem_write_request_info_TAG
 Request info for a configuration memory write operation. More...
 

Macros

#define LEN_CONFIG_MEM_OPTIONS_DESCRIPTION   (64 - 1)
 Maximum description length for Configuration Options reply.
 
#define LEN_CONFIG_MEM_ADDRESS_SPACE_DESCRIPTION   (60 - 1)
 Maximum description length for Address Space Info reply.
 
#define NULL_NODE_ID   0x000000000000
 NULL/unassigned Node ID value.
 
#define NULL_EVENT_ID   0x0000000000000000
 NULL/unassigned Event ID value.
 
#define LEN_SNIP_NAME_BUFFER   41
 SNIP manufacturer name field length (including null)
 
#define LEN_SNIP_MODEL_BUFFER   41
 SNIP model name field length (including null)
 
#define LEN_SNIP_HARDWARE_VERSION_BUFFER   21
 SNIP hardware version field length (including null)
 
#define LEN_SNIP_SOFTWARE_VERSION_BUFFER   21
 SNIP software version field length (including null)
 
#define LEN_SNIP_USER_NAME_BUFFER   63
 SNIP user-assigned name field length (including null)
 
#define LEN_SNIP_USER_DESCRIPTION_BUFFER   64
 SNIP user description field length (including null)
 
#define LEN_SNIP_USER_DATA   (LEN_SNIP_USER_NAME_BUFFER + LEN_SNIP_USER_DESCRIPTION_BUFFER)
 Total SNIP user data size (name + description)
 
#define LEN_SNIP_VERSION   1
 SNIP manufacturer version field length (1 byte)
 
#define LEN_SNIP_USER_VERSION   1
 SNIP user version field length (1 byte)
 
#define LEN_SNIP_STRUCTURE   264
 Maximum SNIP structure size (256 payload + 8 Event ID)
 
#define LEN_MESSAGE_BYTES_BASIC   16
 BASIC message payload size.
 
#define LEN_MESSAGE_BYTES_DATAGRAM   72
 DATAGRAM message maximum payload size.
 
#define LEN_MESSAGE_BYTES_SNIP   256
 SNIP message payload size (also covers Events with Payload)
 
#define LEN_MESSAGE_BYTES_STREAM   512
 STREAM message payload size.
 
#define LEN_EVENT_ID   8
 Event ID size in bytes.
 
#define LEN_MESSAGE_BUFFER   (USER_DEFINED_BASIC_BUFFER_DEPTH + USER_DEFINED_DATAGRAM_BUFFER_DEPTH + USER_DEFINED_SNIP_BUFFER_DEPTH + USER_DEFINED_STREAM_BUFFER_DEPTH)
 Total number of message buffers (sum of all buffer types)
 
#define LEN_DATAGRAM_MAX_PAYLOAD   64
 Maximum datagram payload after protocol overhead.
 
#define LEN_EVENT_PAYLOAD   LEN_MESSAGE_BYTES_SNIP
 Event payload maximum size (uses SNIP buffer)
 

Typedefs

typedef uint8_t payload_basic_t[LEN_MESSAGE_BYTES_BASIC]
 BASIC message payload buffer (16 bytes)
 
typedef uint8_t payload_datagram_t[LEN_MESSAGE_BYTES_DATAGRAM]
 DATAGRAM message payload buffer (72 bytes)
 
typedef uint8_t payload_snip_t[LEN_MESSAGE_BYTES_SNIP]
 SNIP message payload buffer (256 bytes)
 
typedef uint8_t payload_stream_t[LEN_MESSAGE_BYTES_STREAM]
 STREAM message payload buffer (512 bytes)
 
typedef payload_basic_t openlcb_basic_data_buffer_t[USER_DEFINED_BASIC_BUFFER_DEPTH]
 Array of BASIC payload buffers.
 
typedef payload_datagram_t openlcb_datagram_data_buffer_t[USER_DEFINED_DATAGRAM_BUFFER_DEPTH]
 Array of DATAGRAM payload buffers.
 
typedef payload_snip_t openlcb_snip_data_buffer_t[USER_DEFINED_SNIP_BUFFER_DEPTH]
 Array of SNIP payload buffers.
 
typedef payload_stream_t openlcb_stream_data_buffer_t[USER_DEFINED_STREAM_BUFFER_DEPTH]
 Array of STREAM payload buffers.
 
typedef uint8_t openlcb_payload_t[1]
 Generic 1-byte payload pointer type for casting.
 
typedef uint64_t event_id_t
 64-bit Event ID.
 
typedef uint64_t node_id_t
 48-bit Node ID stored in a 64-bit type (upper 16 bits unused).
 
typedef uint8_t event_payload_t[LEN_EVENT_PAYLOAD]
 Event payload data buffer (LEN_EVENT_PAYLOAD bytes).
 
typedef uint8_t configuration_memory_buffer_t[LEN_DATAGRAM_MAX_PAYLOAD]
 Configuration memory read/write operation buffer (64 bytes).
 
typedef openlcb_msg_t openlcb_msg_array_t[LEN_MESSAGE_BUFFER]
 Array of all message structures in the buffer store.
 
typedef struct node_parameters_TAG node_parameters_t
 Complete node configuration parameters (typically const/flash).
 
typedef struct train_state_TAG train_state_t
 Mutable runtime state for a single train node.
 
typedef struct openlcb_node_TAG openlcb_node_t
 OpenLCB virtual node.
 
typedef void(* parameterless_callback_t) (void)
 Callback function type with no parameters.
 
typedef void(* operations_config_mem_space_func_t) (openlcb_statemachine_info_t *statemachine_info, struct config_mem_operations_request_info_TAG *config_mem_operations_request_info)
 Config mem operations callback function type.
 
typedef struct config_mem_operations_request_info_TAG config_mem_operations_request_info_t
 Request info for Get Options / Get Address Space Info commands.
 
typedef void(* read_config_mem_space_func_t) (openlcb_statemachine_info_t *statemachine_info, struct config_mem_read_request_info_TAG *config_mem_read_request_info)
 Config mem read callback function type.
 
typedef struct config_mem_read_request_info_TAG config_mem_read_request_info_t
 Request info for a configuration memory read operation.
 
typedef void(* write_config_mem_space_func_t) (openlcb_statemachine_info_t *statemachine_info, struct config_mem_write_request_info_TAG *config_mem_write_request_info)
 Config mem write callback function type.
 
typedef struct config_mem_write_request_info_TAG config_mem_write_request_info_t
 Request info for a configuration memory write operation.
 

Enumerations

enum  payload_type_enum { BASIC , DATAGRAM , SNIP , STREAM }
 Message buffer payload type identifier. More...
 
enum  event_status_enum { EVENT_STATUS_UNKNOWN , EVENT_STATUS_SET , EVENT_STATUS_CLEAR }
 Event status for Producer/Consumer identification messages. More...
 
enum  space_encoding_enum { ADDRESS_SPACE_IN_BYTE_1 = 0 , ADDRESS_SPACE_IN_BYTE_6 = 1 }
 Where the address space byte is encoded in a Config Mem command. More...
 
enum  event_range_count_enum {
  EVENT_RANGE_COUNT_1 = 0 , EVENT_RANGE_COUNT_2 = 2 , EVENT_RANGE_COUNT_4 = 4 , EVENT_RANGE_COUNT_8 = 8 ,
  EVENT_RANGE_COUNT_16 = 16 , EVENT_RANGE_COUNT_32 = 32 , EVENT_RANGE_COUNT_64 = 64 , EVENT_RANGE_COUNT_128 = 128 ,
  EVENT_RANGE_COUNT_256 = 256 , EVENT_RANGE_COUNT_512 = 512 , EVENT_RANGE_COUNT_1024 = 1024 , EVENT_RANGE_COUNT_2048 = 2048 ,
  EVENT_RANGE_COUNT_4096 = 4096 , EVENT_RANGE_COUNT_8192 = 8192 , EVENT_RANGE_COUNT_16384 = 16384 , EVENT_RANGE_COUNT_32768 = 32768
}
 Power-of-two event range sizes for range-identified events. More...
 
enum  broadcast_time_event_type_enum {
  BROADCAST_TIME_EVENT_REPORT_TIME = 0 , BROADCAST_TIME_EVENT_REPORT_DATE = 1 , BROADCAST_TIME_EVENT_REPORT_YEAR = 2 , BROADCAST_TIME_EVENT_REPORT_RATE = 3 ,
  BROADCAST_TIME_EVENT_SET_TIME = 4 , BROADCAST_TIME_EVENT_SET_DATE = 5 , BROADCAST_TIME_EVENT_SET_YEAR = 6 , BROADCAST_TIME_EVENT_SET_RATE = 7 ,
  BROADCAST_TIME_EVENT_QUERY = 8 , BROADCAST_TIME_EVENT_STOP = 9 , BROADCAST_TIME_EVENT_START = 10 , BROADCAST_TIME_EVENT_DATE_ROLLOVER = 11 ,
  BROADCAST_TIME_EVENT_UNKNOWN = 255
}
 Broadcast Time Protocol event type decoded from an Event ID. More...
 
enum  train_emergency_type_enum { TRAIN_EMERGENCY_TYPE_ESTOP = 0 , TRAIN_EMERGENCY_TYPE_GLOBAL_STOP = 1 , TRAIN_EMERGENCY_TYPE_GLOBAL_OFF = 2 }
 Emergency state type for train protocol callbacks. More...
 

Detailed Description

Core type definitions, structures, and configuration constants for the OpenLCB library.

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.

Defines all fundamental data types used across the library: message buffers (BASIC/DATAGRAM/SNIP/STREAM pools), node structures with event producer/consumer lists, configuration memory request types, broadcast time clock state, and train state. All memory is statically allocated at compile time — there is no dynamic allocation at runtime.

Author
Jim Kueneman
Date
8 Mar 2026

Typedef Documentation

◆ openlcb_payload_t

typedef uint8_t openlcb_payload_t[1]

Generic 1-byte payload pointer type for casting.

◆ event_id_t

typedef uint64_t event_id_t

64-bit Event ID.

◆ node_id_t

typedef uint64_t node_id_t

48-bit Node ID stored in a 64-bit type (upper 16 bits unused).

◆ event_payload_t

typedef uint8_t event_payload_t[LEN_EVENT_PAYLOAD]

Event payload data buffer (LEN_EVENT_PAYLOAD bytes).

◆ configuration_memory_buffer_t

typedef uint8_t configuration_memory_buffer_t[LEN_DATAGRAM_MAX_PAYLOAD]

Configuration memory read/write operation buffer (64 bytes).

◆ openlcb_msg_array_t

typedef openlcb_msg_t openlcb_msg_array_t[LEN_MESSAGE_BUFFER]

Array of all message structures in the buffer store.

◆ node_parameters_t

Complete node configuration parameters (typically const/flash).

Contains SNIP strings, protocol support bits, CDI/FDI data, and address space information for every supported space.

◆ train_state_t

Mutable runtime state for a single train node.

Allocated from a static pool by OpenLcbApplicationTrain_setup().

◆ openlcb_node_t

OpenLCB virtual node.

Holds identity, state, event lists, and a pointer to const configuration parameters. Nodes cannot be deallocated once allocated.

◆ parameterless_callback_t

typedef void(* parameterless_callback_t) (void)

Callback function type with no parameters.

◆ operations_config_mem_space_func_t

typedef void(* operations_config_mem_space_func_t) (openlcb_statemachine_info_t *statemachine_info, struct config_mem_operations_request_info_TAG *config_mem_operations_request_info)

Config mem operations callback function type.

◆ config_mem_operations_request_info_t

Request info for Get Options / Get Address Space Info commands.

◆ read_config_mem_space_func_t

typedef void(* read_config_mem_space_func_t) (openlcb_statemachine_info_t *statemachine_info, struct config_mem_read_request_info_TAG *config_mem_read_request_info)

Config mem read callback function type.

◆ config_mem_read_request_info_t

Request info for a configuration memory read operation.

◆ write_config_mem_space_func_t

typedef void(* write_config_mem_space_func_t) (openlcb_statemachine_info_t *statemachine_info, struct config_mem_write_request_info_TAG *config_mem_write_request_info)

Config mem write callback function type.

◆ config_mem_write_request_info_t

Request info for a configuration memory write operation.

Enumeration Type Documentation

◆ payload_type_enum

Message buffer payload type identifier.

Enumerator
BASIC 

16-byte payload buffer

DATAGRAM 

72-byte payload buffer

SNIP 

256-byte payload buffer

STREAM 

512-byte payload buffer

◆ event_status_enum

Event status for Producer/Consumer identification messages.

Enumerator
EVENT_STATUS_UNKNOWN 

State is unknown

EVENT_STATUS_SET 

Event is SET

EVENT_STATUS_CLEAR 

Event is CLEAR

◆ space_encoding_enum

Where the address space byte is encoded in a Config Mem command.

Enumerator
ADDRESS_SPACE_IN_BYTE_1 

Space ID in command byte 1

ADDRESS_SPACE_IN_BYTE_6 

Space ID in command byte 6

◆ event_range_count_enum

Power-of-two event range sizes for range-identified events.

Enumerator
EVENT_RANGE_COUNT_1 
EVENT_RANGE_COUNT_2 
EVENT_RANGE_COUNT_4 
EVENT_RANGE_COUNT_8 
EVENT_RANGE_COUNT_16 
EVENT_RANGE_COUNT_32 
EVENT_RANGE_COUNT_64 
EVENT_RANGE_COUNT_128 
EVENT_RANGE_COUNT_256 
EVENT_RANGE_COUNT_512 
EVENT_RANGE_COUNT_1024 
EVENT_RANGE_COUNT_2048 
EVENT_RANGE_COUNT_4096 
EVENT_RANGE_COUNT_8192 
EVENT_RANGE_COUNT_16384 
EVENT_RANGE_COUNT_32768 

◆ broadcast_time_event_type_enum

Broadcast Time Protocol event type decoded from an Event ID.

Enumerator
BROADCAST_TIME_EVENT_REPORT_TIME 
BROADCAST_TIME_EVENT_REPORT_DATE 
BROADCAST_TIME_EVENT_REPORT_YEAR 
BROADCAST_TIME_EVENT_REPORT_RATE 
BROADCAST_TIME_EVENT_SET_TIME 
BROADCAST_TIME_EVENT_SET_DATE 
BROADCAST_TIME_EVENT_SET_YEAR 
BROADCAST_TIME_EVENT_SET_RATE 
BROADCAST_TIME_EVENT_QUERY 
BROADCAST_TIME_EVENT_STOP 
BROADCAST_TIME_EVENT_START 
BROADCAST_TIME_EVENT_DATE_ROLLOVER 
BROADCAST_TIME_EVENT_UNKNOWN 

◆ train_emergency_type_enum

Emergency state type for train protocol callbacks.

Enumerator
TRAIN_EMERGENCY_TYPE_ESTOP 

Point-to-point Emergency Stop

TRAIN_EMERGENCY_TYPE_GLOBAL_STOP 

Global Emergency Stop (event-based)

TRAIN_EMERGENCY_TYPE_GLOBAL_OFF 

Global Emergency Off (event-based)


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