|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
Implementation of the application-level Train Control Protocol module. More...
Functions | |
| void | OpenLcbApplicationTrain_initialize (const interface_openlcb_application_train_t *interface) |
| Initialises the train module and stores the callback interface. | |
| train_state_t * | OpenLcbApplicationTrain_setup (openlcb_node_t *openlcb_node) |
| Allocates a train state slot and assigns it to the node. | |
| train_state_t * | OpenLcbApplicationTrain_get_state (openlcb_node_t *openlcb_node) |
| Returns the train state for a node. | |
| void | OpenLcbApplicationTrain_100ms_timer_tick (uint8_t current_tick) |
| Decrements the heartbeat countdown for all active train nodes. | |
| void | OpenLcbApplicationTrain_send_set_speed (openlcb_node_t *openlcb_node, uint16_t train_alias, node_id_t train_node_id, uint16_t speed) |
| Sends a Set Speed/Direction command to a train node. | |
| void | OpenLcbApplicationTrain_send_set_function (openlcb_node_t *openlcb_node, uint16_t train_alias, node_id_t train_node_id, uint32_t fn_address, uint16_t fn_value) |
| Sends a Set Function command to a train node. | |
| void | OpenLcbApplicationTrain_send_emergency_stop (openlcb_node_t *openlcb_node, uint16_t train_alias, node_id_t train_node_id) |
| Sends an Emergency Stop command to a train node. | |
| void | OpenLcbApplicationTrain_send_query_speeds (openlcb_node_t *openlcb_node, uint16_t train_alias, node_id_t train_node_id) |
| Sends a Query Speeds command to a train node. | |
| void | OpenLcbApplicationTrain_send_query_function (openlcb_node_t *openlcb_node, uint16_t train_alias, node_id_t train_node_id, uint32_t fn_address) |
| Sends a Query Function command to a train node. | |
| void | OpenLcbApplicationTrain_send_assign_controller (openlcb_node_t *openlcb_node, uint16_t train_alias, node_id_t train_node_id) |
| Sends an Assign Controller command to a train node. | |
| void | OpenLcbApplicationTrain_send_release_controller (openlcb_node_t *openlcb_node, uint16_t train_alias, node_id_t train_node_id) |
| Sends a Release Controller command to a train node. | |
| void | OpenLcbApplicationTrain_send_noop (openlcb_node_t *openlcb_node, uint16_t train_alias, node_id_t train_node_id) |
| Sends a NOOP management command to a train node. | |
| void | OpenLcbApplicationTrain_set_dcc_address (openlcb_node_t *openlcb_node, uint16_t dcc_address, bool is_long_address) |
| Sets the DCC address and address type for a train node. | |
| uint16_t | OpenLcbApplicationTrain_get_dcc_address (openlcb_node_t *openlcb_node) |
| Returns the DCC address for a train node. | |
| bool | OpenLcbApplicationTrain_is_long_address (openlcb_node_t *openlcb_node) |
| Returns true if the train node uses long DCC addressing. | |
| void | OpenLcbApplicationTrain_set_speed_steps (openlcb_node_t *openlcb_node, uint8_t speed_steps) |
| Sets the speed-step mode for a train node. | |
| uint8_t | OpenLcbApplicationTrain_get_speed_steps (openlcb_node_t *openlcb_node) |
| Returns the speed-step mode for a train node. | |
Implementation of the application-level Train Control Protocol module.
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.
Manages the train state pool, heartbeat timer, and all throttle-side send helpers for the OpenLCB Train Control Protocol.
| void OpenLcbApplicationTrain_initialize | ( | const interface_openlcb_application_train_t * | interface | ) |
Initialises the train module and stores the callback interface.
Algorithm:
* @param interface Pointer to a interface_openlcb_application_train_t. *
| train_state_t * OpenLcbApplicationTrain_setup | ( | openlcb_node_t * | openlcb_node | ) |
Allocates a train state slot and assigns it to the node.
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t to configure as a train. *
| train_state_t * OpenLcbApplicationTrain_get_state | ( | openlcb_node_t * | openlcb_node | ) |
Returns the train state for a node.
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t. *
| void OpenLcbApplicationTrain_100ms_timer_tick | ( | uint8_t | current_tick | ) |
Decrements the heartbeat countdown for all active train nodes.
Algorithm:
* @param current_tick Current value of the global 100ms tick counter. *
| void OpenLcbApplicationTrain_send_set_speed | ( | openlcb_node_t * | openlcb_node, |
| uint16_t | train_alias, | ||
| node_id_t | train_node_id, | ||
| uint16_t | speed ) |
Sends a Set Speed/Direction command to a train node.
Algorithm:
* @param openlcb_node Pointer to the sending openlcb_node_t. * @param train_alias 12-bit CAN alias of the target train node. * @param train_node_id 48-bit node_id_t of the target train node. * @param speed 16-bit speed/direction in OpenLCB float16 format. *
| void OpenLcbApplicationTrain_send_set_function | ( | openlcb_node_t * | openlcb_node, |
| uint16_t | train_alias, | ||
| node_id_t | train_node_id, | ||
| uint32_t | fn_address, | ||
| uint16_t | fn_value ) |
Sends a Set Function command to a train node.
Algorithm:
* @param openlcb_node Pointer to the sending openlcb_node_t. * @param train_alias 12-bit CAN alias of the target train node. * @param train_node_id 48-bit node_id_t of the target train node. * @param fn_address 24-bit function address. * @param fn_value 16-bit function value. *
| void OpenLcbApplicationTrain_send_emergency_stop | ( | openlcb_node_t * | openlcb_node, |
| uint16_t | train_alias, | ||
| node_id_t | train_node_id ) |
Sends an Emergency Stop command to a train node.
Algorithm:
* @param openlcb_node Pointer to the sending openlcb_node_t. * @param train_alias 12-bit CAN alias of the target train node. * @param train_node_id 48-bit node_id_t of the target train node. *
| void OpenLcbApplicationTrain_send_query_speeds | ( | openlcb_node_t * | openlcb_node, |
| uint16_t | train_alias, | ||
| node_id_t | train_node_id ) |
Sends a Query Speeds command to a train node.
Algorithm:
* @param openlcb_node Pointer to the sending openlcb_node_t. * @param train_alias 12-bit CAN alias of the target train node. * @param train_node_id 48-bit node_id_t of the target train node. *
| void OpenLcbApplicationTrain_send_query_function | ( | openlcb_node_t * | openlcb_node, |
| uint16_t | train_alias, | ||
| node_id_t | train_node_id, | ||
| uint32_t | fn_address ) |
Sends a Query Function command to a train node.
Algorithm:
* @param openlcb_node Pointer to the sending openlcb_node_t. * @param train_alias 12-bit CAN alias of the target train node. * @param train_node_id 48-bit node_id_t of the target train node. * @param fn_address 24-bit function address to query. *
| void OpenLcbApplicationTrain_send_assign_controller | ( | openlcb_node_t * | openlcb_node, |
| uint16_t | train_alias, | ||
| node_id_t | train_node_id ) |
Sends an Assign Controller command to a train node.
Algorithm:
* @param openlcb_node Pointer to the sending (throttle) openlcb_node_t. * @param train_alias 12-bit CAN alias of the target train node. * @param train_node_id 48-bit node_id_t of the target train node. *
| void OpenLcbApplicationTrain_send_release_controller | ( | openlcb_node_t * | openlcb_node, |
| uint16_t | train_alias, | ||
| node_id_t | train_node_id ) |
Sends a Release Controller command to a train node.
Algorithm:
* @param openlcb_node Pointer to the sending (throttle) openlcb_node_t. * @param train_alias 12-bit CAN alias of the target train node. * @param train_node_id 48-bit node_id_t of the target train node. *
| void OpenLcbApplicationTrain_send_noop | ( | openlcb_node_t * | openlcb_node, |
| uint16_t | train_alias, | ||
| node_id_t | train_node_id ) |
Sends a NOOP management command to a train node.
Sends a NOOP (no-operation) management command to a train node.
Algorithm:
* @param openlcb_node Pointer to the sending openlcb_node_t. * @param train_alias 12-bit CAN alias of the target train node. * @param train_node_id 48-bit node_id_t of the target train node. *
| void OpenLcbApplicationTrain_set_dcc_address | ( | openlcb_node_t * | openlcb_node, |
| uint16_t | dcc_address, | ||
| bool | is_long_address ) |
Sets the DCC address and address type for a train node.
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t. * @param dcc_address DCC address value. * @param is_long_address true for long addressing, false for short. *
| uint16_t OpenLcbApplicationTrain_get_dcc_address | ( | openlcb_node_t * | openlcb_node | ) |
Returns the DCC address for a train node.
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t. *
| bool OpenLcbApplicationTrain_is_long_address | ( | openlcb_node_t * | openlcb_node | ) |
Returns true if the train node uses long DCC addressing.
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t. *
| void OpenLcbApplicationTrain_set_speed_steps | ( | openlcb_node_t * | openlcb_node, |
| uint8_t | speed_steps ) |
Sets the speed-step mode for a train node.
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t. * @param speed_steps Speed-step count (14, 28, or 128). *
| uint8_t OpenLcbApplicationTrain_get_speed_steps | ( | openlcb_node_t * | openlcb_node | ) |
Returns the speed-step mode for a train node.
Algorithm:
* @param openlcb_node Pointer to the openlcb_node_t. *
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License