|
Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
|
Example: Voted Channel with Dual Transport (Shared Memory + TCP/IP). More...
#include <stdint.h>#include <stdbool.h>#include <string.h>#include <stdio.h>#include <stdlib.h>#include "rte/channel_link/rte_channel.h"#include "rte/voter/rte_voter.h"#include "rte/status/rte_status.h"Go to the source code of this file.
Data Structures | |
| struct | shm_queue_t |
| struct | tcp_channel_t |
| struct | multi_transport_channel_t |
| struct | train_command_t |
Macros | |
| #define | CHANNEL_COUNT 2U |
Enumerations | |
| enum | channel_type_t { CHANNEL_TYPE_SHARED_MEMORY , CHANNEL_TYPE_TCP } |
| Opaque channel type that hides whether it's SHM or TCP. More... | |
Functions | |
| static rte_status_t | shm_send (shm_queue_t *q, const void *data, size_t size) |
| static rte_status_t | shm_recv (shm_queue_t *q, void *data, size_t size) |
| static rte_status_t | tcp_send (tcp_channel_t *ch, const void *data, size_t size) |
| static rte_status_t | tcp_recv (tcp_channel_t *ch, void *data, size_t size) |
| static rte_status_t | channel_backend_send (void *channel_handle, const void *data, size_t size) |
| OSAdapter send callback for rte_channel (dispatches to transport). | |
| static rte_status_t | channel_backend_recv (void *channel_handle, void *data, size_t size, uint32_t timeout_ms __attribute__((unused))) |
| OSAdapter receive callback for rte_channel (dispatches to transport). | |
| static rte_status_t | example_setup_dual_redundancy (rte_channel_t channels[CHANNEL_COUNT], rte_voter_t *voter) |
| Example: Initialize dual-transport channels plus a 2oo2 voter. | |
| static rte_status_t | send_train_command (rte_voter_t *voter, const train_command_t *cmd) |
| Send a train command to every registered channel (atomic broadcast). | |
| static rte_status_t | receive_train_command (rte_voter_t *voter, train_command_t *cmd_out) |
| Receive a train command via the voter (with 2oo2 voting). | |
| static void | monitor_channel_health (rte_channel_t channels[CHANNEL_COUNT], rte_voter_t *voter) |
| Monitor channel health and detect faults. | |
| int | main (void) |
| Main example. | |
Variables | |
| static shm_queue_t | shm_queue_0 = {0} |
| static tcp_channel_t | tcp_ch_0 = {.socket = 0, .connected = true} |
| static multi_transport_channel_t | g_channel_0 |
| static multi_transport_channel_t | g_channel_1 |
Example: Voted Channel with Dual Transport (Shared Memory + TCP/IP).
Demonstrates how to:
This pattern enables:
ADR-025 split what used to be a single "vital channel" type (one transport handle + built-in N-way voting) into rte_channel (one link) plus rte_voter (voting across N registered links). This example registers one rte_channel_t per transport into one rte_voter_t configured for RTE_VOTING_2OO2.
Compile: gcc -std=c99 -Wall -Wextra -o vital_dual_transport \ vital_channel_dual_transport.c \ -I../include -L../build -lrte_channels -lrte_oal \ -lrte_core
Definition in file vital_channel_dual_transport.c.
| #define CHANNEL_COUNT 2U |
Definition at line 241 of file vital_channel_dual_transport.c.
| enum channel_type_t |
Opaque channel type that hides whether it's SHM or TCP.
This allows each rte_channel_t to wrap ANY transport. The callback functions dispatch based on channel type.
Definition at line 151 of file vital_channel_dual_transport.c.
|
static |
Definition at line 54 of file vital_channel_dual_transport.c.
|
static |
Definition at line 71 of file vital_channel_dual_transport.c.
|
static |
Definition at line 101 of file vital_channel_dual_transport.c.
|
static |
Definition at line 121 of file vital_channel_dual_transport.c.
|
static |
OSAdapter send callback for rte_channel (dispatches to transport).
Called by rte_channel_send() for one link. The callback hides the specific transport implementation.
Definition at line 180 of file vital_channel_dual_transport.c.
|
static |
OSAdapter receive callback for rte_channel (dispatches to transport).
Called by rte_channel_receive() for one link. The callback hides the specific transport implementation.
Definition at line 206 of file vital_channel_dual_transport.c.
|
static |
Example: Initialize dual-transport channels plus a 2oo2 voter.
Configuration:
Definition at line 251 of file vital_channel_dual_transport.c.
|
static |
Send a train command to every registered channel (atomic broadcast).
Definition at line 300 of file vital_channel_dual_transport.c.
|
static |
Receive a train command via the voter (with 2oo2 voting).
Definition at line 321 of file vital_channel_dual_transport.c.
|
static |
Monitor channel health and detect faults.
Definition at line 345 of file vital_channel_dual_transport.c.
| int main | ( | void | ) |
Main example.
Definition at line 378 of file vital_channel_dual_transport.c.
|
static |
Definition at line 52 of file vital_channel_dual_transport.c.
|
static |
Definition at line 99 of file vital_channel_dual_transport.c.
|
static |
Definition at line 164 of file vital_channel_dual_transport.c.
|
static |
Definition at line 169 of file vital_channel_dual_transport.c.