|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Implementation of the 10-state CAN alias allocation login handlers. More...
Functions | |
| void | CanLoginMessageHandler_initialize (const interface_can_login_message_handler_t *interface) |
| Stores the interface pointer for use by all state handlers. | |
| void | CanLoginMessageHandler_state_init (can_statemachine_info_t *can_statemachine_info) |
| State 1: Seeds the PRNG with the Node ID, then jumps directly to GENERATE_ALIAS. | |
| void | CanLoginMessageHandler_state_generate_seed (can_statemachine_info_t *can_statemachine_info) |
| State 2: Advances the seed one LFSR step, then transitions to GENERATE_ALIAS. | |
| void | CanLoginMessageHandler_state_generate_alias (can_statemachine_info_t *can_statemachine_info) |
| State 3: Derives a 12-bit alias from the seed, registers it, and transitions to LOAD_CID07. | |
| void | CanLoginMessageHandler_state_load_cid07 (can_statemachine_info_t *can_statemachine_info) |
| State 4: Loads a CID7 frame (Node ID bits 47-36) into the outgoing buffer. | |
| void | CanLoginMessageHandler_state_load_cid06 (can_statemachine_info_t *can_statemachine_info) |
| State 5: Loads a CID6 frame (Node ID bits 35-24) into the outgoing buffer. | |
| void | CanLoginMessageHandler_state_load_cid05 (can_statemachine_info_t *can_statemachine_info) |
| State 6: Loads a CID5 frame (Node ID bits 23-12) into the outgoing buffer. | |
| void | CanLoginMessageHandler_state_load_cid04 (can_statemachine_info_t *can_statemachine_info) |
| State 7: Loads a CID4 frame (Node ID bits 11-0) and snapshots current_tick for the 200 ms wait. | |
| void | CanLoginMessageHandler_state_wait_200ms (can_statemachine_info_t *can_statemachine_info) |
| State 8: Waits until 200ms have elapsed (via elapsed-time subtraction on current_tick), then transitions to LOAD_RESERVE_ID. | |
| void | CanLoginMessageHandler_state_load_rid (can_statemachine_info_t *can_statemachine_info) |
| State 9: Loads an RID frame to claim the alias, then transitions to LOAD_AMD. | |
| void | CanLoginMessageHandler_state_load_amd (can_statemachine_info_t *can_statemachine_info) |
| State 10: Loads an AMD frame, marks the node permitted, and updates the alias mapping. | |
Implementation of the 10-state CAN alias allocation login handlers.
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.
Includes LFSR-based seed generation and 12-bit alias extraction per the OpenLCB CAN Frame Transfer Standard.
| void CanLoginMessageHandler_initialize | ( | const interface_can_login_message_handler_t * | interface | ) |
Stores the interface pointer for use by all state handlers.
Registers the dependency-injection interface for this module.
* @param interface Pointer to the populated dependency-injection interface. *
| void CanLoginMessageHandler_state_init | ( | can_statemachine_info_t * | can_statemachine_info | ) |
State 1: Seeds the PRNG with the Node ID, then jumps directly to GENERATE_ALIAS.
State 1: Sets node seed to its Node ID, then jumps to GENERATE_ALIAS.
On first login the Node ID itself is the initial seed, so GENERATE_SEED (which advances the PRNG one step) is skipped. GENERATE_SEED is only entered on alias conflict retry, when _reset_node() sets run_state back to RUNSTATE_GENERATE_SEED.
* @param can_statemachine_info State machine context. *
| void CanLoginMessageHandler_state_generate_seed | ( | can_statemachine_info_t * | can_statemachine_info | ) |
State 2: Advances the seed one LFSR step, then transitions to GENERATE_ALIAS.
State 2: Generates a new seed via LFSR, then transitions to GENERATE_ALIAS.
| void CanLoginMessageHandler_state_generate_alias | ( | can_statemachine_info_t * | can_statemachine_info | ) |
State 3: Derives a 12-bit alias from the seed, registers it, and transitions to LOAD_CID07.
State 3: Derives a 12-bit alias from the seed, registers it, then transitions to LOAD_CID07.
| void CanLoginMessageHandler_state_load_cid07 | ( | can_statemachine_info_t * | can_statemachine_info | ) |
State 4: Loads a CID7 frame (Node ID bits 47-36) into the outgoing buffer.
| can_statemachine_info | State machine context. |
| void CanLoginMessageHandler_state_load_cid06 | ( | can_statemachine_info_t * | can_statemachine_info | ) |
State 5: Loads a CID6 frame (Node ID bits 35-24) into the outgoing buffer.
| can_statemachine_info | State machine context. |
| void CanLoginMessageHandler_state_load_cid05 | ( | can_statemachine_info_t * | can_statemachine_info | ) |
State 6: Loads a CID5 frame (Node ID bits 23-12) into the outgoing buffer.
| can_statemachine_info | State machine context. |
| void CanLoginMessageHandler_state_load_cid04 | ( | can_statemachine_info_t * | can_statemachine_info | ) |
State 7: Loads a CID4 frame (Node ID bits 11-0) and snapshots current_tick for the 200 ms wait.
State 7: Loads a CID4 frame (Node ID bits 11-0) and resets the 200 ms timer.
| void CanLoginMessageHandler_state_wait_200ms | ( | can_statemachine_info_t * | can_statemachine_info | ) |
State 8: Waits until 200ms have elapsed (via elapsed-time subtraction on current_tick), then transitions to LOAD_RESERVE_ID.
State 8: Waits until timerticks > 2, then transitions to LOAD_RESERVE_ID.
| void CanLoginMessageHandler_state_load_rid | ( | can_statemachine_info_t * | can_statemachine_info | ) |
State 9: Loads an RID frame to claim the alias, then transitions to LOAD_AMD.
| can_statemachine_info | State machine context. |
| void CanLoginMessageHandler_state_load_amd | ( | can_statemachine_info_t * | can_statemachine_info | ) |
State 10: Loads an AMD frame, marks the node permitted, and updates the alias mapping.
State 10: Loads an AMD frame with the full Node ID, marks the node permitted, and updates the alias mapping to permitted status.
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License