OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
Loading...
Searching...
No Matches
protocol_config_mem_read_handler.c File Reference

Configuration memory read handler implementation. More...

Functions

void ProtocolConfigMemReadHandler_initialize (const interface_protocol_config_mem_read_handler_t *interface_protocol_config_mem_read_handler)
 Stores the callback interface. Call once at startup.
 
void ProtocolConfigMemReadHandler_read_request_config_definition_info (openlcb_statemachine_info_t *statemachine_info, config_mem_read_request_info_t *config_mem_read_request_info)
 Read from CDI (0xFF): copy bytes from node->parameters->cdi[].
 
void ProtocolConfigMemReadHandler_read_request_train_function_definition_info (openlcb_statemachine_info_t *statemachine_info, config_mem_read_request_info_t *config_mem_read_request_info)
 Read from Train FDI (0xFA): copy bytes from node->parameters->fdi[].
 
void ProtocolConfigMemReadHandler_read_request_train_function_config_memory (openlcb_statemachine_info_t *statemachine_info, config_mem_read_request_info_t *config_mem_read_request_info)
 Read from Train Fn Config (0xF9): map flat byte address to functions[].
 
void ProtocolConfigMemReadHandler_read_request_config_mem (openlcb_statemachine_info_t *statemachine_info, config_mem_read_request_info_t *config_mem_read_request_info)
 Read from Config space (0xFD) via config_memory_read callback.
 
void ProtocolConfigMemReadHandler_read_request_acdi_manufacturer (openlcb_statemachine_info_t *statemachine_info, config_mem_read_request_info_t *config_mem_read_request_info)
 Read from ACDI-Mfg (0xFC): dispatch to SNIP loaders by address.
 
void ProtocolConfigMemReadHandler_read_request_acdi_user (openlcb_statemachine_info_t *statemachine_info, config_mem_read_request_info_t *config_mem_read_request_info)
 Read from ACDI-User (0xFB): dispatch to SNIP loaders by address.
 
void ProtocolConfigMemReadHandler_read_space_config_description_info (openlcb_statemachine_info_t *statemachine_info)
 Dispatch CDI (0xFF) read to two-phase handler.
 
void ProtocolConfigMemReadHandler_read_space_all (openlcb_statemachine_info_t *statemachine_info)
 Dispatch All (0xFE) read to two-phase handler.
 
void ProtocolConfigMemReadHandler_read_space_config_memory (openlcb_statemachine_info_t *statemachine_info)
 Dispatch Config (0xFD) read to two-phase handler.
 
void ProtocolConfigMemReadHandler_read_space_acdi_manufacturer (openlcb_statemachine_info_t *statemachine_info)
 Dispatch ACDI-Mfg (0xFC) read to two-phase handler.
 
void ProtocolConfigMemReadHandler_read_space_acdi_user (openlcb_statemachine_info_t *statemachine_info)
 Dispatch ACDI-User (0xFB) read to two-phase handler.
 
void ProtocolConfigMemReadHandler_read_space_train_function_definition_info (openlcb_statemachine_info_t *statemachine_info)
 Dispatch Train FDI (0xFA) read to two-phase handler.
 
void ProtocolConfigMemReadHandler_read_space_train_function_config_memory (openlcb_statemachine_info_t *statemachine_info)
 Dispatch Train Fn Config (0xF9) read to two-phase handler.
 
void ProtocolConfigMemReadHandler_read_message (openlcb_statemachine_info_t *statemachine_info, uint8_t space, uint8_t return_msg_ok, uint8_t return_msg_fail)
 Generic read message handler. Placeholder.
 
void ProtocolConfigMemReadHandler_read_reply_ok_message (openlcb_statemachine_info_t *statemachine_info, uint8_t space)
 Generic read reply OK handler. Placeholder.
 
void ProtocolConfigMemReadHandler_read_reply_reject_message (openlcb_statemachine_info_t *statemachine_info, uint8_t space)
 Generic read reply reject handler. Placeholder.
 

Detailed Description

Configuration memory read handler implementation.

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.

Two-phase dispatch for read commands across all standard address spaces (CDI, All, Config, ACDI-Mfg, ACDI-User, Train FDI, Train Fn Config). Sends Datagram Received OK with reply-pending, reads from config memory, and returns the data in a reply datagram.

Author
Jim Kueneman
Date
9 Mar 2026
See also
protocol_config_mem_read_handler.h
MemoryConfigurationS.pdf

Function Documentation

◆ ProtocolConfigMemReadHandler_initialize()

void ProtocolConfigMemReadHandler_initialize ( const interface_protocol_config_mem_read_handler_t * interface_protocol_config_mem_read_handler)

Stores the callback interface. Call once at startup.

* @param interface_protocol_config_mem_read_handler  Populated table.
* 
Warning
Structure must remain valid for application lifetime.

◆ ProtocolConfigMemReadHandler_read_request_config_definition_info()

void ProtocolConfigMemReadHandler_read_request_config_definition_info ( openlcb_statemachine_info_t * statemachine_info,
config_mem_read_request_info_t * config_mem_read_request_info )

Read from CDI (0xFF): copy bytes from node->parameters->cdi[].

Send read request targeting CDI (0xFF) on another node.

◆ ProtocolConfigMemReadHandler_read_request_train_function_definition_info()

void ProtocolConfigMemReadHandler_read_request_train_function_definition_info ( openlcb_statemachine_info_t * statemachine_info,
config_mem_read_request_info_t * config_mem_read_request_info )

Read from Train FDI (0xFA): copy bytes from node->parameters->fdi[].

Send read request targeting Train FDI (0xFA) on another node.

◆ ProtocolConfigMemReadHandler_read_request_train_function_config_memory()

void ProtocolConfigMemReadHandler_read_request_train_function_config_memory ( openlcb_statemachine_info_t * statemachine_info,
config_mem_read_request_info_t * config_mem_read_request_info )

Read from Train Fn Config (0xF9): map flat byte address to functions[].

Send read request targeting Train Fn Config (0xF9) on another node.

Each 16-bit function value occupies 2 bytes big-endian: address/2 = fn_index, address%2 selects high/low byte.

◆ ProtocolConfigMemReadHandler_read_request_config_mem()

void ProtocolConfigMemReadHandler_read_request_config_mem ( openlcb_statemachine_info_t * statemachine_info,
config_mem_read_request_info_t * config_mem_read_request_info )

Read from Config space (0xFD) via config_memory_read callback.

Send read request targeting Config (0xFD) on another node.

Partial reads (fewer bytes than requested) return TRANSFER_ERROR.

◆ ProtocolConfigMemReadHandler_read_request_acdi_manufacturer()

void ProtocolConfigMemReadHandler_read_request_acdi_manufacturer ( openlcb_statemachine_info_t * statemachine_info,
config_mem_read_request_info_t * config_mem_read_request_info )

Read from ACDI-Mfg (0xFC): dispatch to SNIP loaders by address.

Send read request targeting ACDI-Mfg (0xFC) on another node.

◆ ProtocolConfigMemReadHandler_read_request_acdi_user()

void ProtocolConfigMemReadHandler_read_request_acdi_user ( openlcb_statemachine_info_t * statemachine_info,
config_mem_read_request_info_t * config_mem_read_request_info )

Read from ACDI-User (0xFB): dispatch to SNIP loaders by address.

Send read request targeting ACDI-User (0xFB) on another node.

◆ ProtocolConfigMemReadHandler_read_space_config_description_info()

void ProtocolConfigMemReadHandler_read_space_config_description_info ( openlcb_statemachine_info_t * statemachine_info)

Dispatch CDI (0xFF) read to two-phase handler.

Read from CDI space (0xFF).

◆ ProtocolConfigMemReadHandler_read_space_all()

void ProtocolConfigMemReadHandler_read_space_all ( openlcb_statemachine_info_t * statemachine_info)

Dispatch All (0xFE) read to two-phase handler.

Read from All space (0xFE).

◆ ProtocolConfigMemReadHandler_read_space_config_memory()

void ProtocolConfigMemReadHandler_read_space_config_memory ( openlcb_statemachine_info_t * statemachine_info)

Dispatch Config (0xFD) read to two-phase handler.

Read from Config space (0xFD).

◆ ProtocolConfigMemReadHandler_read_space_acdi_manufacturer()

void ProtocolConfigMemReadHandler_read_space_acdi_manufacturer ( openlcb_statemachine_info_t * statemachine_info)

Dispatch ACDI-Mfg (0xFC) read to two-phase handler.

Read from ACDI-Mfg space (0xFC).

◆ ProtocolConfigMemReadHandler_read_space_acdi_user()

void ProtocolConfigMemReadHandler_read_space_acdi_user ( openlcb_statemachine_info_t * statemachine_info)

Dispatch ACDI-User (0xFB) read to two-phase handler.

Read from ACDI-User space (0xFB).

◆ ProtocolConfigMemReadHandler_read_space_train_function_definition_info()

void ProtocolConfigMemReadHandler_read_space_train_function_definition_info ( openlcb_statemachine_info_t * statemachine_info)

Dispatch Train FDI (0xFA) read to two-phase handler.

Read from Train FDI space (0xFA).

◆ ProtocolConfigMemReadHandler_read_space_train_function_config_memory()

void ProtocolConfigMemReadHandler_read_space_train_function_config_memory ( openlcb_statemachine_info_t * statemachine_info)

Dispatch Train Fn Config (0xF9) read to two-phase handler.

Read from Train Fn Config space (0xF9).

◆ ProtocolConfigMemReadHandler_read_message()

void ProtocolConfigMemReadHandler_read_message ( openlcb_statemachine_info_t * statemachine_info,
uint8_t space,
uint8_t return_msg_ok,
uint8_t return_msg_fail )

Generic read message handler. Placeholder.

Parameters
statemachine_infoPointer to openlcb_statemachine_info_t context.
spaceAddress space number.
return_msg_okMTI for success reply.
return_msg_failMTI for failure reply.

◆ ProtocolConfigMemReadHandler_read_reply_ok_message()

void ProtocolConfigMemReadHandler_read_reply_ok_message ( openlcb_statemachine_info_t * statemachine_info,
uint8_t space )

Generic read reply OK handler. Placeholder.

Parameters
statemachine_infoPointer to openlcb_statemachine_info_t context.
spaceAddress space number.

◆ ProtocolConfigMemReadHandler_read_reply_reject_message()

void ProtocolConfigMemReadHandler_read_reply_reject_message ( openlcb_statemachine_info_t * statemachine_info,
uint8_t space )

Generic read reply reject handler. Placeholder.

Parameters
statemachine_infoPointer to openlcb_statemachine_info_t context.
spaceAddress space number.

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