|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Implementation of the CAN receive state machine. More...
Macros | |
| #define | OFFSET_DEST_ID_IN_PAYLOAD 2 |
| CAN payload byte offset when destination alias occupies bytes 0-1. | |
| #define | OFFSET_DEST_ID_IN_IDENTIFIER 0 |
| CAN payload byte offset when destination alias is in the identifier (datagrams). | |
| #define | OFFSET_NO_DEST_ID 0 |
| CAN payload byte offset for global frames with no destination. | |
Functions | |
| void | CanRxStatemachine_initialize (const interface_can_rx_statemachine_t *interface_can_rx_statemachine) |
| Stores the dependency-injection interface pointer. | |
| void | CanRxStatemachine_incoming_can_driver_callback (can_msg_t *can_msg) |
| Primary entry point called by the hardware CAN driver on frame reception. | |
Implementation of the CAN receive state machine.
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.
Classifies incoming CAN frames as OpenLCB messages or CAN control frames, validates destination aliases for addressed traffic, extracts multi-frame framing bits, and dispatches to the appropriate handler via the dependency-injected interface. Called directly from the CAN ISR or receive thread.
| #define OFFSET_DEST_ID_IN_PAYLOAD 2 |
CAN payload byte offset when destination alias occupies bytes 0-1.
| #define OFFSET_DEST_ID_IN_IDENTIFIER 0 |
CAN payload byte offset when destination alias is in the identifier (datagrams).
| #define OFFSET_NO_DEST_ID 0 |
CAN payload byte offset for global frames with no destination.
| void CanRxStatemachine_initialize | ( | const interface_can_rx_statemachine_t * | interface_can_rx_statemachine | ) |
Stores the dependency-injection interface pointer.
Registers the dependency-injection interface for this module.
| void CanRxStatemachine_incoming_can_driver_callback | ( | can_msg_t * | can_msg | ) |
Primary entry point called by the hardware CAN driver on frame reception.
Invokes the optional on_receive callback, then classifies the frame as an OpenLCB message or a CAN control frame and dispatches accordingly.
This function is typically called from an interrupt or receive thread and accesses shared resources (FIFOs, buffer lists). It must NOT be called while the main state machine has resources locked. Recommended approaches:
| can_msg | Pointer to the received CAN frame. Must not be NULL. Must remain valid until this function returns. |
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License