OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
Loading...
Searching...
No Matches
interface_openlcb_application_t Struct Reference

Application-provided callbacks required by the OpenLCB library. More...

Data Fields

bool(* send_openlcb_msg )(openlcb_msg_t *openlcb_msg)
 Queues an outgoing OpenLCB message for transmission.
 
uint16_t(* config_memory_read )(openlcb_node_t *openlcb_node, uint32_t address, uint16_t count, configuration_memory_buffer_t *buffer)
 Reads bytes from the node's configuration memory.
 
uint16_t(* config_memory_write )(openlcb_node_t *openlcb_node, uint32_t address, uint16_t count, configuration_memory_buffer_t *buffer)
 Writes bytes to the node's configuration memory.
 

Detailed Description

Application-provided callbacks required by the OpenLCB library.

All three function pointers must be set before calling OpenLcbApplication_initialize(). The library calls these to send messages and to read or write configuration memory. The structure must remain valid for the entire lifetime of the program.

Warning
All three function pointers must be non-NULL before initialization.
See also
OpenLcbApplication_initialize

Field Documentation

◆ send_openlcb_msg

bool(* send_openlcb_msg) (openlcb_msg_t *openlcb_msg)

Queues an outgoing OpenLCB message for transmission.

The implementation must queue the message for the transport layer (CAN, TCP/IP, etc.) and return immediately without blocking.

Parameters
openlcb_msgPointer to the openlcb_msg_t to transmit.
Returns
true if queued successfully, false if the transmit buffer is full.
Warning
NULL pointer causes a crash — this field must always be set.

◆ config_memory_read

uint16_t(* config_memory_read) (openlcb_node_t *openlcb_node, uint32_t address, uint16_t count, configuration_memory_buffer_t *buffer)

Reads bytes from the node's configuration memory.

Called when the library needs to read from the node's persistent storage (CDI, ACDI, SNIP data, user-configurable parameters). The callback is responsible for address validation and bounds checking.

Parameters
openlcb_nodePointer to the requesting openlcb_node_t.
addressStarting address within the configuration address space.
countNumber of bytes to read (64 or fewer for network operations).
bufferDestination configuration_memory_buffer_t (must hold at least count bytes).
Returns
Number of bytes read, or 0xFFFF on error.
Warning
NULL pointer causes a crash — this field must always be set.
The buffer must have room for at least count bytes.

◆ config_memory_write

uint16_t(* config_memory_write) (openlcb_node_t *openlcb_node, uint32_t address, uint16_t count, configuration_memory_buffer_t *buffer)

Writes bytes to the node's configuration memory.

Called when the library needs to write to the node's persistent storage. Read-only spaces (CDI, ACDI, manufacturer data) should return 0xFFFF. The application is responsible for the persistence mechanism (EEPROM, flash, etc.) and for address validation.

Parameters
openlcb_nodePointer to the requesting openlcb_node_t.
addressStarting address within the configuration address space.
countNumber of bytes to write (64 or fewer for network operations).
bufferSource configuration_memory_buffer_t containing the data.
Returns
Number of bytes written, or 0xFFFF on error.
Warning
NULL pointer causes a crash — this field must always be set.
Read-only address spaces must return 0xFFFF, not silently succeed.

The documentation for this struct was generated from the following file:

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