RTE RBC 2oo2 Reference Application 0.1.0 build 0006685
SIL 4 2oo2 Dual-Site Fault-Tolerant ERTMS Radio Block Centre Reference Architecture
Loading...
Searching...
No Matches
ab_gp_channel.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "rte/app/appmanager/rte_appmanager.h"
#include "rte/utils/status/rte_status.h"
#include "../../common/site_config.h"
#include "../../common/rbc_wire_types.h"
#include "ab_gp_channel_types.h"
Include dependency graph for ab_gp_channel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct ab_gp_channel_context_s * ab_gp_channel_handle_t
 Opaque handle over this component's own static per-process context.

Functions

rte_status_t ab_gp_channel_open_link (bool is_role_a, rte_example_site_t site, ab_gp_channel_handle_t *out_handle)
 Opens this process's own A<->B peer channel and C relay channels.
void ab_gp_channel_close_link (ab_gp_channel_handle_t handle)
 Full teardown of a channel opened by ab_gp_channel_open_link().
rte_status_t ab_gp_channel_train_codec_setup (ab_gp_channel_handle_t handle)
 GP-internal registration for train codec.
rte_status_t ab_gp_channel_ga_setup (ab_gp_channel_handle_t handle)
 GA registration for ma_logic_adaptation / il / ctc.
void ab_gp_channel_relay_queues_setup (ab_gp_channel_handle_t handle)
 Initializes relay queues (no-op in single-threaded channel_service).
rte_status_t ab_gp_channel_negotiate_setup (ab_gp_channel_handle_t handle)
 Opens inter-site negotiation link and runs startup tie-break.
rte_status_t ab_gp_channel_checkpoint_setup (ab_gp_channel_handle_t handle)
 Wires AppManager checkpoint mechanism onto peer channel.
rte_status_t ab_gp_channel_dual_setup (ab_gp_channel_handle_t handle)
 Wires dual-transfer liveness watchdog.
rte_status_t ab_gp_channel_watchdog_setup (ab_gp_channel_handle_t handle)
 Arms general health watchdog.
rte_status_t ab_gp_channel_crosscompare_setup (ab_gp_channel_handle_t handle)
 Creates cross-comparator on an already-open channel.
rte_status_t ab_gp_channel_cycle_timer_setup (ab_gp_channel_handle_t handle)
 Creates and starts periodic cycle timer.
const rte_appmanager_checkpoint_config_t * ab_gp_channel_checkpoint_config (ab_gp_channel_handle_t handle)
 Accessor for checkpoint config.
rte_status_t ab_gp_channel_init (void *context)
 rte_appmanager_operations_t::init hook.
rte_status_t ab_gp_channel_shutdown (void *context)
 rte_appmanager_operations_t::shutdown hook.
rte_status_t ab_gp_channel_wait_cycle_tick (ab_gp_channel_handle_t handle)
 Waits for the periodic cycle timer tick, advances cycle, and refreshes watchdog/checkpoint state.
uint32_t ab_gp_channel_poll_relays (ab_gp_channel_handle_t handle, ab_gp_com_envelope_cb cb, void *user_ctx)
 Polls all C relay channels non-blockingly and invokes cb for every received envelope.
void ab_gp_channel_poll_peer (ab_gp_channel_handle_t handle, ab_gp_com_peer_frame_cb cb, void *user_ctx)
 Polls the A<->B peer channel non-blockingly and invokes cb for every received frame.
void ab_gp_channel_poll_crosscompare (ab_gp_channel_handle_t handle, ab_gp_com_peer_frame_cb cb, void *user_ctx)
 Polls the dedicated A<->B cross-compare channel non-blockingly and invokes cb for every received frame.
rte_status_t ab_gp_channel_send_relay (ab_gp_channel_handle_t handle, rte_example_relay_kind_t kind, uint8_t index, const uint8_t *bytes, size_t size)
 Sends an envelope over a specific C relay channel.
rte_status_t ab_gp_channel_send_peer (ab_gp_channel_handle_t handle, const uint8_t *bytes, size_t size)
 Sends a frame over the A<->B peer channel.
ab_gp_saf_train_t * ab_gp_channel_saf_train (ab_gp_channel_handle_t handle)
 This channel's train-link SaF termination (ab_gp_saf_train.h), or NULL for a NULL handle.
rte_status_t ab_gp_channel_saf_train_setup (ab_gp_channel_handle_t handle)
 Reads RTE_SAFECOMM_TRAIN_RBC_ID and sets up the train-link SaF termination: unset leaves it off (plain ERTMS frames, the behaviour before it existed); set to this RBC's ETCS identity (1..0xFFFFFF, decimal or 0x hex) turns it on.
rte_status_t ab_gp_channel_send_crosscompare (ab_gp_channel_handle_t handle, uint8_t kind, const uint8_t *payload, size_t size)
 Sends a frame over the dedicated A<->B cross-compare channel.
void ab_gp_channel_raise_ctc_alarm (ab_gp_channel_handle_t handle, rbc_alarm_severity_t severity, uint32_t code, const char *log_message)
 Raises a severity-leveled operational alarm: logs it locally (rte_log_write_event(), same structured Site/Cycle/Source/ Destination/Type/Info convention as every other event this codebase logs) AND forwards it to CTC (RBC_MSG_CTC_ALARM, see that kind's own doc in rbc_wire_types.h), so a human dispatcher sees it too, not just this process's own log.

Typedef Documentation

◆ ab_gp_channel_handle_t

typedef struct ab_gp_channel_context_s* ab_gp_channel_handle_t

Opaque handle over this component's own static per-process context.

Definition at line 18 of file ab_gp_channel.h.

Function Documentation

◆ ab_gp_channel_open_link()

rte_status_t ab_gp_channel_open_link ( bool is_role_a,
rte_example_site_t site,
ab_gp_channel_handle_t * out_handle )

Opens this process's own A<->B peer channel and C relay channels.

Definition at line 583 of file ab_gp_channel.c.

◆ ab_gp_channel_close_link()

void ab_gp_channel_close_link ( ab_gp_channel_handle_t handle)

Full teardown of a channel opened by ab_gp_channel_open_link().

Definition at line 664 of file ab_gp_channel.c.

◆ ab_gp_channel_train_codec_setup()

rte_status_t ab_gp_channel_train_codec_setup ( ab_gp_channel_handle_t handle)

GP-internal registration for train codec.

Definition at line 788 of file ab_gp_channel.c.

◆ ab_gp_channel_ga_setup()

rte_status_t ab_gp_channel_ga_setup ( ab_gp_channel_handle_t handle)

GA registration for ma_logic_adaptation / il / ctc.

Definition at line 804 of file ab_gp_channel.c.

◆ ab_gp_channel_relay_queues_setup()

void ab_gp_channel_relay_queues_setup ( ab_gp_channel_handle_t handle)

Initializes relay queues (no-op in single-threaded channel_service).

Definition at line 818 of file ab_gp_channel.c.

◆ ab_gp_channel_negotiate_setup()

rte_status_t ab_gp_channel_negotiate_setup ( ab_gp_channel_handle_t handle)

Opens inter-site negotiation link and runs startup tie-break.

Definition at line 823 of file ab_gp_channel.c.

◆ ab_gp_channel_checkpoint_setup()

rte_status_t ab_gp_channel_checkpoint_setup ( ab_gp_channel_handle_t handle)

Wires AppManager checkpoint mechanism onto peer channel.

Definition at line 672 of file ab_gp_channel.c.

◆ ab_gp_channel_dual_setup()

rte_status_t ab_gp_channel_dual_setup ( ab_gp_channel_handle_t handle)

Wires dual-transfer liveness watchdog.

Definition at line 737 of file ab_gp_channel.c.

◆ ab_gp_channel_watchdog_setup()

rte_status_t ab_gp_channel_watchdog_setup ( ab_gp_channel_handle_t handle)

Arms general health watchdog.

Definition at line 838 of file ab_gp_channel.c.

◆ ab_gp_channel_crosscompare_setup()

rte_status_t ab_gp_channel_crosscompare_setup ( ab_gp_channel_handle_t handle)

Creates cross-comparator on an already-open channel.

Definition at line 759 of file ab_gp_channel.c.

◆ ab_gp_channel_cycle_timer_setup()

rte_status_t ab_gp_channel_cycle_timer_setup ( ab_gp_channel_handle_t handle)

Creates and starts periodic cycle timer.

Definition at line 880 of file ab_gp_channel.c.

◆ ab_gp_channel_checkpoint_config()

const rte_appmanager_checkpoint_config_t * ab_gp_channel_checkpoint_config ( ab_gp_channel_handle_t handle)

Accessor for checkpoint config.

Definition at line 752 of file ab_gp_channel.c.

◆ ab_gp_channel_init()

rte_status_t ab_gp_channel_init ( void * context)

rte_appmanager_operations_t::init hook.

Definition at line 770 of file ab_gp_channel.c.

◆ ab_gp_channel_shutdown()

rte_status_t ab_gp_channel_shutdown ( void * context)

rte_appmanager_operations_t::shutdown hook.

Definition at line 1343 of file ab_gp_channel.c.

◆ ab_gp_channel_wait_cycle_tick()

rte_status_t ab_gp_channel_wait_cycle_tick ( ab_gp_channel_handle_t handle)

Waits for the periodic cycle timer tick, advances cycle, and refreshes watchdog/checkpoint state.

Definition at line 919 of file ab_gp_channel.c.

◆ ab_gp_channel_poll_relays()

uint32_t ab_gp_channel_poll_relays ( ab_gp_channel_handle_t handle,
ab_gp_com_envelope_cb cb,
void * user_ctx )

Polls all C relay channels non-blockingly and invokes cb for every received envelope.

Returns
Count of envelopes drained across all relay channels this cycle.

Definition at line 1029 of file ab_gp_channel.c.

◆ ab_gp_channel_poll_peer()

void ab_gp_channel_poll_peer ( ab_gp_channel_handle_t handle,
ab_gp_com_peer_frame_cb cb,
void * user_ctx )

Polls the A<->B peer channel non-blockingly and invokes cb for every received frame.

Definition at line 1116 of file ab_gp_channel.c.

◆ ab_gp_channel_poll_crosscompare()

void ab_gp_channel_poll_crosscompare ( ab_gp_channel_handle_t handle,
ab_gp_com_peer_frame_cb cb,
void * user_ctx )

Polls the dedicated A<->B cross-compare channel non-blockingly and invokes cb for every received frame.

Definition at line 1135 of file ab_gp_channel.c.

◆ ab_gp_channel_send_relay()

rte_status_t ab_gp_channel_send_relay ( ab_gp_channel_handle_t handle,
rte_example_relay_kind_t kind,
uint8_t index,
const uint8_t * bytes,
size_t size )

Sends an envelope over a specific C relay channel.

Definition at line 1171 of file ab_gp_channel.c.

◆ ab_gp_channel_send_peer()

rte_status_t ab_gp_channel_send_peer ( ab_gp_channel_handle_t handle,
const uint8_t * bytes,
size_t size )

Sends a frame over the A<->B peer channel.

Definition at line 1221 of file ab_gp_channel.c.

◆ ab_gp_channel_saf_train()

ab_gp_saf_train_t * ab_gp_channel_saf_train ( ab_gp_channel_handle_t handle)

This channel's train-link SaF termination (ab_gp_saf_train.h), or NULL for a NULL handle.

Definition at line 1233 of file ab_gp_channel.c.

◆ ab_gp_channel_saf_train_setup()

rte_status_t ab_gp_channel_saf_train_setup ( ab_gp_channel_handle_t handle)

Reads RTE_SAFECOMM_TRAIN_RBC_ID and sets up the train-link SaF termination: unset leaves it off (plain ERTMS frames, the behaviour before it existed); set to this RBC's ETCS identity (1..0xFFFFFF, decimal or 0x hex) turns it on.

Returns
RTE_STATUS_OK, or RTE_STATUS_INVALID_PARAM for a value that is set but not a valid identity - the caller treats that as a fatal startup error rather than silently running the link unprotected.

Definition at line 1240 of file ab_gp_channel.c.

◆ ab_gp_channel_send_crosscompare()

rte_status_t ab_gp_channel_send_crosscompare ( ab_gp_channel_handle_t handle,
uint8_t kind,
const uint8_t * payload,
size_t size )

Sends a frame over the dedicated A<->B cross-compare channel.

Definition at line 1154 of file ab_gp_channel.c.

◆ ab_gp_channel_raise_ctc_alarm()

void ab_gp_channel_raise_ctc_alarm ( ab_gp_channel_handle_t handle,
rbc_alarm_severity_t severity,
uint32_t code,
const char * log_message )

Raises a severity-leveled operational alarm: logs it locally (rte_log_write_event(), same structured Site/Cycle/Source/ Destination/Type/Info convention as every other event this codebase logs) AND forwards it to CTC (RBC_MSG_CTC_ALARM, see that kind's own doc in rbc_wire_types.h), so a human dispatcher sees it too, not just this process's own log.

Sends immediately (bypasses the ADR-034 checkpoint-gated stage queue, ab_gp_channel_stage.h) - callers reacting to an already-decided fault (about to shut down/reboot) must call this BEFORE ab_gp_channel_shutdown() closes the CTC relay socket, or the alarm never leaves the process. Best-effort: a failed send is logged locally (via rte_log_write_event() above) but does not fail the caller's own fault-reaction sequence - see this function's own .c comment for why blocking a reboot on a diagnostic send would be exactly backwards.

Parameters
handleA valid, already-open channel handle.
severityAlarm severity.
codeCaller-defined numeric reason/fault code (e.g. a rte_safestate_reason_t or RTE_EXAMPLE_REASON_* value) - carried on the wire as-is.
log_messageHuman-readable text for the LOCAL log line only (not carried on the wire - see rbc_wire_types.h's own doc on why RBC_MSG_CTC_ALARM stays coded, not free-text, matching every other kind in this enum). May be NULL.

Definition at line 1290 of file ab_gp_channel.c.