State handlers for the 10-state CAN alias allocation login sequence.
- Copyright
- Copyright (c) 2024, Jim Kueneman All rights reserved. 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.
Each handler builds the appropriate CAN control frame (CID, RID, AMD) per the OpenLCB CAN Frame Transfer Standard.
- Author
- Jim Kueneman
- Date
- 4 Mar 2026
State 1: Sets node seed to its Node ID, then jumps to GENERATE_ALIAS.
- Parameters
-
| can_statemachine_info | State machine context (node + outgoing message buffer). |
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.
*
State 8: Waits until timerticks > 2, then transitions to LOAD_RESERVE_ID.
Non-blocking — returns immediately each call until the timer expires. timerticks is reset to 0 at the end of State 7 (CID4) and incremented every 100 ms, so this waits at least 300 ms — satisfying the spec minimum of 200 ms (§6.2.1). Requires the 100 ms timer tick to be running (OpenLcbNode_100ms_timer_tick).
- Parameters
-
| can_statemachine_info | State machine context. |
State 8: Waits until timerticks > 2, then transitions to LOAD_RESERVE_ID.
State 10: Loads an AMD frame with the full Node ID, marks the node permitted, and updates the alias mapping to permitted status.
This is the final state. After transmission the node may send OpenLCB messages.
- Parameters
-
| can_statemachine_info | State machine context. |
- See also
- CanUtilities_copy_node_id_to_payload
State 10: Loads an AMD frame with the full Node ID, marks the node permitted, and updates the alias mapping to permitted status.