|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Main CAN layer state machine — orchestrates alias management, login, and message dispatch. More...
Go to the source code of this file.
Data Structures | |
| struct | interface_can_main_statemachine_t |
| Dependency-injection interface for the CAN main state machine. More... | |
Functions | |
| void | CanMainStatemachine_initialize (const interface_can_main_statemachine_t *interface_can_main_statemachine) |
| Registers the dependency-injection interface and prepares internal buffers. | |
| void | CanMainStateMachine_run (void) |
| Executes one iteration of the main CAN state machine. | |
| can_statemachine_info_t * | CanMainStateMachine_get_can_statemachine_info (void) |
| Returns a pointer to the internal state machine context. | |
| bool | CanMainStatemachine_handle_duplicate_aliases (void) |
| Scans the alias table, unregisters duplicates, and resets affected nodes. | |
| bool | CanMainStatemachine_handle_login_outgoing_can_message (void) |
| Attempts to transmit the pending login frame (CID, RID, or AMD). | |
| bool | CanMainStatemachine_handle_outgoing_can_message (void) |
| Pops one message from the outgoing CAN FIFO and attempts transmission. | |
| bool | CanMainStatemachine_handle_try_enumerate_first_node (void) |
| Gets the first node and processes it through its appropriate state machine. | |
| bool | CanMainStatemachine_handle_try_enumerate_next_node (void) |
| Continues enumeration and processes the next node. | |
| bool | CanMainStatemachine_handle_listener_verification (void) |
| Probes one listener alias for staleness and queues an AME if due. | |
Main CAN layer state machine — orchestrates alias management, login, and message dispatch.
Coordinates duplicate alias detection, outgoing message transmission, login sequencing, and round-robin node enumeration across all virtual nodes. Non-blocking: call CanMainStateMachine_run() as fast as possible in the main loop.
|
extern |
Registers the dependency-injection interface and prepares internal buffers.
Must be called once at startup, after CanBufferStore_initialize(), CanBufferFifo_initialize(), and CanLoginStateMachine_initialize(), and before CAN reception begins.
| interface_can_main_statemachine | Pointer to a fully populated interface_can_main_statemachine_t. Must remain valid for the lifetime of the application. All pointers must be non-NULL. |
Registers the dependency-injection interface and prepares internal buffers.
Stores the interface pointer, clears the static login frame buffer, links it to the state machine context, and zeroes all context flags.
* @param interface_can_main_statemachine Pointer to the populated dependency interface. *
|
extern |
Executes one iteration of the main CAN state machine.
Non-blocking. Processes one operation per call and returns immediately. Call as fast as possible in the main loop.
Executes one iteration of the main CAN state machine.
Calls each handler in priority order, returning after the first one that does work. Listener verification runs unconditionally before the priority chain. Priority: duplicate aliases -> outgoing CAN frame -> login frame -> enumerate first node -> enumerate next node.
|
extern |
Returns a pointer to the internal state machine context.
Intended for unit testing and debugging only.
Returns a pointer to the internal state machine context.
|
extern |
Scans the alias table, unregisters duplicates, and resets affected nodes.
Exposed for unit testing. Normally called via the interface pointer.
Scans the alias table, unregisters duplicates, and resets affected nodes.
Locks shared resources, reads the flag, calls _process_duplicate_aliases() if needed, then unlocks.
|
extern |
Attempts to transmit the pending login frame (CID, RID, or AMD).
Exposed for unit testing. Normally called via the interface pointer.
Attempts to transmit the pending login frame (CID, RID, or AMD).
Clears login_outgoing_can_msg_valid only after successful transmission. Returns true if a login frame was pending (sent or retried), false if none.
|
extern |
Pops one message from the outgoing CAN FIFO and attempts transmission.
Exposed for unit testing. Normally called via the interface pointer. Frees the buffer only on successful transmission; retries on the next call otherwise.
Pops one message from the outgoing CAN FIFO and attempts transmission.
Algorithm:
|
extern |
Gets the first node and processes it through its appropriate state machine.
Exposed for unit testing. Normally called via the interface pointer.
Gets the first node and processes it through its appropriate state machine.
Returns false if enumeration is already active (node pointer non-NULL). Otherwise fetches the first node, runs its login state machine if still logging in, and returns true.
|
extern |
Continues enumeration and processes the next node.
Exposed for unit testing. Normally called via the interface pointer.
Continues enumeration and processes the next node.
Fetches the next node and runs its login state machine if still logging in. Returns true when there are no more nodes (enumeration complete), false otherwise.
|
extern |
Probes one listener alias for staleness and queues an AME if due.
Exposed for unit testing. Normally called via the interface pointer.
Algorithm:
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License