|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Train Control Protocol message handler implementation (Layer 1) More...
Functions | |
| void | ProtocolTrainHandler_initialize (const interface_protocol_train_handler_t *interface) |
| Stores the callback interface. Call once at startup. | |
| void | ProtocolTrainHandler_handle_train_command (openlcb_statemachine_info_t *statemachine_info) |
| Dispatches an incoming Train Control command by sub-command byte. | |
| void | ProtocolTrainHandler_handle_train_reply (openlcb_statemachine_info_t *statemachine_info) |
| Dispatches an incoming Train Control reply by sub-command byte. | |
| void | ProtocolTrainHandler_handle_emergency_event (openlcb_statemachine_info_t *statemachine_info, event_id_t event_id) |
| Handles a global or addressed emergency event for a train node. | |
Train Control Protocol message handler implementation (Layer 1)
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.
Handles incoming MTI_TRAIN_PROTOCOL commands and MTI_TRAIN_REPLY replies. Automatically updates train_state, builds protocol replies, forwards consist commands to listeners, and fires optional notifier callbacks.
| void ProtocolTrainHandler_initialize | ( | const interface_protocol_train_handler_t * | interface | ) |
Stores the callback interface. Call once at startup.
Initializes the Train Control Protocol handler.
* @param interface Populated callback table (may be NULL). *
| void ProtocolTrainHandler_handle_train_command | ( | openlcb_statemachine_info_t * | statemachine_info | ) |
Dispatches an incoming Train Control command by sub-command byte.
Handles an incoming Train Control Protocol command (MTI_TRAIN_PROTOCOL).
Masks the P bit (bit 7) from the instruction byte before dispatch so that forwarded commands (P=1) are processed identically to direct commands (P=0). After local processing of speed, function, or emergency stop commands, initiates listener forwarding enumeration if listeners are attached and the command is not itself a forwarded command (P=0).
* @param statemachine_info Pointer to openlcb_statemachine_info_t context. *
| void ProtocolTrainHandler_handle_train_reply | ( | openlcb_statemachine_info_t * | statemachine_info | ) |
Dispatches an incoming Train Control reply by sub-command byte.
Handles an incoming Train Control Protocol reply (MTI_TRAIN_REPLY).
* @param statemachine_info Pointer to openlcb_statemachine_info_t context. *
| void ProtocolTrainHandler_handle_emergency_event | ( | openlcb_statemachine_info_t * | statemachine_info, |
| event_id_t | event_id ) |
Handles a global or addressed emergency event for a train node.
Sets or clears emergency flags based on the well-known Event ID and fires the appropriate notifier callback.
* @param statemachine_info Pointer to openlcb_statemachine_info_t context. * @param event_id Well-known event_id_t for the emergency condition. *
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License