|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Central MTI-based message dispatcher. More...
Go to the source code of this file.
Data Structures | |
| struct | interface_openlcb_main_statemachine_t |
| Dependency-injection interface for the main state machine. Required pointers must be non-NULL; optional ones may be NULL (causes automatic Interaction Rejected). Internal pointers are exposed for unit testing. More... | |
Functions | |
| void | OpenLcbMainStatemachine_initialize (const interface_openlcb_main_statemachine_t *interface_openlcb_main_statemachine) |
| Stores the callback interface and prepares internal state. | |
| void | OpenLcbMainStatemachine_run (void) |
| Runs one non-blocking step of protocol processing. | |
| void | OpenLcbMainStatemachine_load_interaction_rejected (openlcb_statemachine_info_t *statemachine_info) |
| Builds an Interaction Rejected response for the current incoming message. Internal use. | |
| bool | OpenLcbMainStatemachine_handle_outgoing_openlcb_message (void) |
| Tries to send the pending message. Returns true if one was pending. | |
| bool | OpenLcbMainStatemachine_handle_try_reenumerate (void) |
| Re-enters the state processor if the enumerate flag is set. | |
| bool | OpenLcbMainStatemachine_handle_try_pop_next_incoming_openlcb_message (void) |
| Pops the next message from the FIFO (thread-safe). Returns true if popped. | |
| bool | OpenLcbMainStatemachine_handle_try_enumerate_first_node (void) |
| Starts node enumeration from the first node. Returns true if processed. | |
| bool | OpenLcbMainStatemachine_handle_try_enumerate_next_node (void) |
| Advances to the next node; frees message at end. Returns true if processed. | |
| void | OpenLcbMainStatemachine_process_main_statemachine (openlcb_statemachine_info_t *statemachine_info) |
| MTI dispatcher. Routes incoming message to the correct handler. | |
| bool | OpenLcbMainStatemachine_does_node_process_msg (openlcb_statemachine_info_t *statemachine_info) |
| Address filter. Returns true if the node should process this message. | |
| openlcb_statemachine_info_t * | OpenLcbMainStatemachine_get_statemachine_info (void) |
| Returns pointer to internal static state machine info. For unit testing only — do not modify. | |
Central MTI-based message dispatcher.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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.
Pops messages from the FIFO, enumerates all nodes, and routes to the correct protocol handler via function pointers. NULL optional handlers trigger Interaction Rejected automatically. Required handlers include message network, protocol support, and resource locking; optional handlers cover SNIP, events, trains, datagrams, and streams.
|
extern |
Stores the callback interface and prepares internal state.
Call once at startup after buffer/FIFO initialization and before OpenLcbMainStatemachine_run().
| interface_openlcb_main_statemachine | Pointer to interface_openlcb_main_statemachine_t. Must remain valid for application lifetime. |
Stores the callback interface and prepares internal state.
Algorithm:
* @param interface_openlcb_main_statemachine Pointer to populated interface structure *
|
extern |
Runs one non-blocking step of protocol processing.
Priority order: send pending → re-enumerate → pop FIFO → enumerate nodes. Call as fast as possible from your main loop.
Runs one non-blocking step of protocol processing.
Algorithm:
|
extern |
Builds an Interaction Rejected response for the current incoming message. Internal use.
| statemachine_info | Pointer to openlcb_statemachine_info_t context. |
Builds an Interaction Rejected response for the current incoming message. Internal use.
Algorithm:
* @param statemachine_info Pointer to state machine context *
|
extern |
Tries to send the pending message. Returns true if one was pending.
Tries to send the pending message. Returns true if one was pending.
Algorithm:
|
extern |
Re-enters the state processor if the enumerate flag is set.
Re-enters the state processor if the enumerate flag is set.
Algorithm:
|
extern |
Pops the next message from the FIFO (thread-safe). Returns true if popped.
Pops the next message from the FIFO (thread-safe). Returns true if popped.
Algorithm:
|
extern |
Starts node enumeration from the first node. Returns true if processed.
Starts node enumeration from the first node. Returns true if processed.
Algorithm:
|
extern |
Advances to the next node; frees message at end. Returns true if processed.
Advances to the next node; frees message at end. Returns true if processed.
Algorithm:
|
extern |
MTI dispatcher. Routes incoming message to the correct handler.
| statemachine_info | Pointer to openlcb_statemachine_info_t context. |
MTI dispatcher. Routes incoming message to the correct handler.
Algorithm:
* @param statemachine_info Pointer to state machine context with message and node information *
|
extern |
Address filter. Returns true if the node should process this message.
| statemachine_info | Pointer to openlcb_statemachine_info_t context. |
Address filter. Returns true if the node should process this message.
Algorithm:
* @param statemachine_info Pointer to state machine context *
|
extern |
Returns pointer to internal static state machine info. For unit testing only — do not modify.
Returns pointer to internal static state machine info. For unit testing only — do not modify.
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License