OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
Loading...
Searching...
No Matches
interface_can_rx_message_handler_t Struct Reference

Dependency-injection interface for the CAN receive message handlers. More...

Data Fields

can_msg_t *(* can_buffer_store_allocate_buffer )(void)
 REQUIRED. Allocate a CAN buffer (for outgoing control replies). Typical: CanBufferStore_allocate_buffer.
 
openlcb_msg_t *(* openlcb_buffer_store_allocate_buffer )(payload_type_enum payload_type)
 REQUIRED. Allocate an OpenLCB buffer for message assembly. Typical: OpenLcbBufferStore_allocate_buffer.
 
alias_mapping_t *(* alias_mapping_find_mapping_by_alias )(uint16_t alias)
 REQUIRED. Find an alias_mapping_t by 12-bit alias. Typical: AliasMappings_find_mapping_by_alias.
 
alias_mapping_t *(* alias_mapping_find_mapping_by_node_id )(node_id_t node_id)
 REQUIRED. Find an alias_mapping_t by 48-bit node_id_t. Typical: AliasMappings_find_mapping_by_node_id.
 
alias_mapping_info_t *(* alias_mapping_get_alias_mapping_info )(void)
 REQUIRED. Return pointer to the full alias_mapping_info_t table. Typical: AliasMappings_get_alias_mapping_info.
 
void(* alias_mapping_set_has_duplicate_alias_flag )(void)
 REQUIRED. Set the global duplicate-alias flag. Typical: AliasMappings_set_has_duplicate_alias_flag.
 
uint8_t(* get_current_tick )(void)
 Returns the current global 100ms tick. Used to stamp incoming buffers. Optional.
 
listener_alias_entry_t *(* listener_register )(node_id_t node_id)
 OPTIONAL. Register a listener Node ID in the alias table.
 
void(* listener_set_alias )(node_id_t node_id, uint16_t alias)
 OPTIONAL. Store a resolved alias for a registered listener.
 
void(* listener_clear_alias_by_alias )(uint16_t alias)
 OPTIONAL. Clear a listener entry by alias (AMR cleanup).
 
void(* listener_flush_aliases )(void)
 OPTIONAL. Flush all cached listener aliases (global AME).
 

Detailed Description

Dependency-injection interface for the CAN receive message handlers.

Provides buffer allocation and alias-mapping callbacks needed to assemble incoming CAN frames into OpenLCB messages and to respond to CAN control frames (CID, AME, etc.). The first 7 pointers are REQUIRED. The listener_* pointers are OPTIONAL (NULL = feature not linked in).

See also
CanRxMessageHandler_initialize

Field Documentation

◆ can_buffer_store_allocate_buffer

can_msg_t *(* can_buffer_store_allocate_buffer) (void)

REQUIRED. Allocate a CAN buffer (for outgoing control replies). Typical: CanBufferStore_allocate_buffer.

◆ openlcb_buffer_store_allocate_buffer

openlcb_msg_t *(* openlcb_buffer_store_allocate_buffer) (payload_type_enum payload_type)

REQUIRED. Allocate an OpenLCB buffer for message assembly. Typical: OpenLcbBufferStore_allocate_buffer.

◆ alias_mapping_find_mapping_by_alias

alias_mapping_t *(* alias_mapping_find_mapping_by_alias) (uint16_t alias)

REQUIRED. Find an alias_mapping_t by 12-bit alias. Typical: AliasMappings_find_mapping_by_alias.

◆ alias_mapping_find_mapping_by_node_id

alias_mapping_t *(* alias_mapping_find_mapping_by_node_id) (node_id_t node_id)

REQUIRED. Find an alias_mapping_t by 48-bit node_id_t. Typical: AliasMappings_find_mapping_by_node_id.

◆ alias_mapping_get_alias_mapping_info

alias_mapping_info_t *(* alias_mapping_get_alias_mapping_info) (void)

REQUIRED. Return pointer to the full alias_mapping_info_t table. Typical: AliasMappings_get_alias_mapping_info.

◆ alias_mapping_set_has_duplicate_alias_flag

void(* alias_mapping_set_has_duplicate_alias_flag) (void)

REQUIRED. Set the global duplicate-alias flag. Typical: AliasMappings_set_has_duplicate_alias_flag.

◆ get_current_tick

uint8_t(* get_current_tick) (void)

Returns the current global 100ms tick. Used to stamp incoming buffers. Optional.

◆ listener_register

listener_alias_entry_t *(* listener_register) (node_id_t node_id)

OPTIONAL. Register a listener Node ID in the alias table.

Called when a Train Listener Attach command is detected. NULL = listener alias feature not linked in.

Note
Typical: ListenerAliasTable_register.

◆ listener_set_alias

void(* listener_set_alias) (node_id_t node_id, uint16_t alias)

OPTIONAL. Store a resolved alias for a registered listener.

Called when an AMD frame arrives. No-op if the node_id is not a registered listener. NULL = feature not linked in.

Note
Typical: ListenerAliasTable_set_alias.

◆ listener_clear_alias_by_alias

void(* listener_clear_alias_by_alias) (uint16_t alias)

OPTIONAL. Clear a listener entry by alias (AMR cleanup).

Called when an AMR frame arrives so future TX-path lookups return alias == 0 instead of a stale alias. NULL = feature not linked in.

Note
Typical: ListenerAliasTable_clear_alias_by_alias.

◆ listener_flush_aliases

void(* listener_flush_aliases) (void)

OPTIONAL. Flush all cached listener aliases (global AME).

Called when a global AME (empty payload) is received per CanFrameTransferS Section 6.2.3. Zeros all alias fields but preserves registered node_ids. The AMD replies triggered by the global AME will re-populate aliases via set_alias. NULL = feature not linked in.

Note
Typical: ListenerAliasTable_flush_aliases.

The documentation for this struct was generated from the following file:

Copyright (c) 2026 Jim Kueneman all rights reserved. See the License