|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Message handlers for processing received CAN frames into OpenLCB messages. More...
Go to the source code of this file.
Data Structures | |
| struct | interface_can_rx_message_handler_t |
| Dependency-injection interface for the CAN receive message handlers. More... | |
Functions | |
| void | CanRxMessageHandler_initialize (const interface_can_rx_message_handler_t *interface_can_frame_message_handler) |
| Registers the dependency-injection interface for this module. | |
| void | CanRxMessageHandler_first_frame (can_msg_t *can_msg, uint8_t offset, payload_type_enum data_type) |
| Handles the first frame of a multi-frame OpenLCB message. | |
| void | CanRxMessageHandler_middle_frame (can_msg_t *can_msg, uint8_t offset) |
| Handles a middle frame of a multi-frame OpenLCB message. | |
| void | CanRxMessageHandler_last_frame (can_msg_t *can_msg, uint8_t offset) |
| Handles the last frame of a multi-frame OpenLCB message. | |
| void | CanRxMessageHandler_single_frame (can_msg_t *can_msg, uint8_t offset, payload_type_enum data_type) |
| Handles a complete single-frame OpenLCB message. | |
| void | CanRxMessageHandler_can_legacy_snip (can_msg_t *can_msg, uint8_t offset, payload_type_enum data_type) |
| Handles legacy SNIP messages that lack standard framing bits. | |
| void | CanRxMessageHandler_stream_frame (can_msg_t *can_msg, uint8_t offset, payload_type_enum data_type) |
| Handles stream protocol CAN frames (placeholder, not yet implemented). | |
| void | CanRxMessageHandler_rid_frame (can_msg_t *can_msg) |
| Handles RID (Reserve ID) CAN control frames. | |
| void | CanRxMessageHandler_amd_frame (can_msg_t *can_msg) |
| Handles AMD (Alias Map Definition) CAN control frames. | |
| void | CanRxMessageHandler_ame_frame (can_msg_t *can_msg) |
| Handles AME (Alias Map Enquiry) CAN control frames. | |
| void | CanRxMessageHandler_amr_frame (can_msg_t *can_msg) |
| Handles AMR (Alias Map Reset) CAN control frames. | |
| void | CanRxMessageHandler_error_info_report_frame (can_msg_t *can_msg) |
| Handles Error Information Report CAN control frames. | |
| void | CanRxMessageHandler_cid_frame (can_msg_t *can_msg) |
| Handles CID (Check ID) CAN control frames (CanFrameTransferS §6.2.5). | |
Message handlers for processing received CAN frames into OpenLCB messages.
Handles multi-frame assembly, legacy SNIP, and all CAN control frames (CID, RID, AMD, AME, AMR, error reports). Invoked by the CAN Rx state machine.
|
extern |
Registers the dependency-injection interface for this module.
| interface_can_frame_message_handler | Pointer to a populated interface_can_rx_message_handler_t. Must remain valid for the lifetime of the application. All function pointers must be non-NULL. |
Registers the dependency-injection interface for this module.
|
extern |
Handles the first frame of a multi-frame OpenLCB message.
Allocates an OpenLCB buffer, initializes it with source/dest/MTI from the CAN header, copies the first payload chunk, and adds it to the buffer list for continued assembly. Sends a rejection if a duplicate first frame is detected or if buffer allocation fails.
| can_msg | Received CAN frame. |
| offset | Byte offset where OpenLCB data begins (2 if addressed, 0 if global). |
| data_type | Buffer type to allocate (BASIC, DATAGRAM, SNIP, STREAM). |
|
extern |
Handles a middle frame of a multi-frame OpenLCB message.
Finds the in-progress message by source/dest/MTI and appends payload. Sends a rejection if no matching message is found.
| can_msg | Received CAN frame. |
| offset | Byte offset where OpenLCB data begins. |
|
extern |
Handles the last frame of a multi-frame OpenLCB message.
Appends final payload, marks message complete, removes from buffer list, and pushes to the OpenLCB FIFO. Sends a rejection if no matching in-progress message is found.
| can_msg | Received CAN frame. |
| offset | Byte offset where OpenLCB data begins. |
|
extern |
Handles a complete single-frame OpenLCB message.
Allocates a buffer, copies all payload data, and pushes directly to the OpenLCB FIFO. Silently drops if allocation fails.
| can_msg | Received CAN frame. |
| offset | Byte offset where OpenLCB data begins. |
| data_type | Buffer type to allocate (typically BASIC). |
|
extern |
Handles legacy SNIP messages that lack standard framing bits.
Accumulates frames and counts NULL terminators to detect completion. A complete SNIP message contains exactly 6 NULLs.
| can_msg | Received CAN frame. |
| offset | Byte offset where SNIP data begins. |
| data_type | Must be SNIP. |
Handles legacy SNIP messages that lack standard framing bits.
Algorithm:
* @param can_msg Received CAN frame containing SNIP data. * @param offset Byte offset where SNIP data begins. * @param data_type Must be SNIP. *
|
extern |
Handles stream protocol CAN frames (placeholder, not yet implemented).
| can_msg | Received CAN frame. |
| offset | Byte offset where stream data begins. |
| data_type | Must be STREAM. |
Handles stream protocol CAN frames (placeholder, not yet implemented).
|
extern |
Handles RID (Reserve ID) CAN control frames.
Checks for a duplicate alias condition and flags it if found.
| can_msg | Received RID frame. |
Handles RID (Reserve ID) CAN control frames.
|
extern |
Handles AMD (Alias Map Definition) CAN control frames.
Checks for a duplicate alias condition and flags it if found.
| can_msg | Received AMD frame (6-byte NodeID in payload). |
Performs two actions:
* @param can_msg Received AMD frame (6-byte NodeID in payload). *
|
extern |
Handles AME (Alias Map Enquiry) CAN control frames.
Responds with AMD frames for all our aliases (global query) or for a specific NodeID (targeted query if 6-byte payload present).
| can_msg | Received AME frame. |
Handles AME (Alias Map Enquiry) CAN control frames.
Algorithm:
* @param can_msg Received AME frame. *
|
extern |
Handles AMR (Alias Map Reset) CAN control frames.
Checks for a duplicate alias condition and flags it if found.
| can_msg | Received AMR frame. |
Performs four actions when a remote node releases its alias:
* @param can_msg Received AMR frame. *
|
extern |
Handles Error Information Report CAN control frames.
Checks for a duplicate alias condition and flags it if found.
| can_msg | Received error report frame. |
Handles Error Information Report CAN control frames.
|
extern |
Handles CID (Check ID) CAN control frames (CanFrameTransferS §6.2.5).
Per the standard (§6.2.5 Node ID Alias Collision Handling): "If the frame is a Check ID (CID) frame, send a Reserve ID (RID) frame in response." This applies regardless of whether the node is Permitted or still Inhibited. CID is a probe during alias reservation — the correct defence is always RID.
| can_msg | Received CID frame. |
Handles CID (Check ID) CAN control frames (CanFrameTransferS §6.2.5).
Per the standard (§6.2.5 Node ID Alias Collision Handling): "If the frame is a Check ID (CID) frame, send a Reserve ID (RID) frame
in response." The correct defence is always RID, regardless of whether the node is Permitted or still Inhibited. This differs from non-CID frames (RID/AMD/AMR) which indicate an active alias collision and are handled by the internal _check_for_duplicate_alias() helper.
* @param can_msg Received CID frame. *
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License