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_sibling_state.h File Reference

The A/B sibling's last site-state frame (PEER_MSG_KIND_SITE_STATE), kept raw and handed to Platform_RTE's rte_site_role through its sibling source (REQ-SITEROLE-016, ADR-040 step 5b). Pure, no I/O (the ab_gp_standby_policy pattern): the peer-link readers store the frame, the service takes it. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "rte/redundancy/site_role/rte_site_role.h"
#include "../../common/common_config.h"
Include dependency graph for ab_gp_sibling_state.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ab_gp_sibling_state_t

Functions

void ab_gp_sibling_state_reset (ab_gp_sibling_state_t *st)
 Resets the state to "no frame seen" (all zero).
bool ab_gp_sibling_state_store (ab_gp_sibling_state_t *st, const uint8_t *payload, size_t size)
 Stores a received site-state frame payload: the rule of on_peer_frame_received() (the payload must carry at least the whole frame). A later store before a take replaces the earlier bytes.
bool ab_gp_sibling_state_take (ab_gp_sibling_state_t *st, rte_site_role_sibling_t *out)
 The rte_site_role_sibling_source_fn contract: hands out the frame stored since the previous take.

Detailed Description

The A/B sibling's last site-state frame (PEER_MSG_KIND_SITE_STATE), kept raw and handed to Platform_RTE's rte_site_role through its sibling source (REQ-SITEROLE-016, ADR-040 step 5b). Pure, no I/O (the ab_gp_standby_policy pattern): the peer-link readers store the frame, the service takes it.

GP no longer decodes the frame itself: rte_site_role polls ab_gp_sibling_state_take() once per rte_site_role_execute(), derives the sibling's online / ready / reachable facts and runs the A/B agreement check (REQ-SITEROLE-014); GP only reacts to the verdict (ab_gp_channel_crosscompare_check_site_state()). The frame is not stamped with a cycle here: the service stamps the cycle of the poll that delivered it, so a frame read on the checkpoint path (poll_for_checkpoint_frame()) counts for reachability like one read by the per-cycle peer pump.

Wire layout (RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE bytes): is_online(1) | single_mode(1) | ready_for_online(1).

Definition in file ab_gp_sibling_state.h.

Function Documentation

◆ ab_gp_sibling_state_reset()

void ab_gp_sibling_state_reset ( ab_gp_sibling_state_t * st)

Resets the state to "no frame seen" (all zero).

Parameters
stthe state; NULL is ignored

Definition at line 7 of file ab_gp_sibling_state.c.

◆ ab_gp_sibling_state_store()

bool ab_gp_sibling_state_store ( ab_gp_sibling_state_t * st,
const uint8_t * payload,
size_t size )

Stores a received site-state frame payload: the rule of on_peer_frame_received() (the payload must carry at least the whole frame). A later store before a take replaces the earlier bytes.

Parameters
stthe state
payloadthe frame payload (the bytes after the message kind)
sizenumber of bytes available in payload
Returns
true when size is at least RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE and the first RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE bytes were copied (known and fresh set); false otherwise (NULL argument or a short payload: the state is left unchanged)

Definition at line 22 of file ab_gp_sibling_state.c.

◆ ab_gp_sibling_state_take()

bool ab_gp_sibling_state_take ( ab_gp_sibling_state_t * st,
rte_site_role_sibling_t * out )

The rte_site_role_sibling_source_fn contract: hands out the frame stored since the previous take.

Parameters
stthe state
outreceives known = true, online = (byte 0 != 0), single_mode = (byte 1 == RTE_EXAMPLE_SINGLE_MODE_FLAG_SINGLE), ready = (byte 2 != 0) when the result is true; left untouched otherwise
Returns
true when a fresh frame was handed out (fresh is cleared, known stays); false when nothing fresh is held or an argument is NULL

Definition at line 41 of file ab_gp_sibling_state.c.