29#include "rte/oal/log/rte_log.h"
30#include "rte/oal/timer/rte_timer.h"
70 if (ctx == NULL || data == NULL || data_size !=
sizeof(rte_vital_message_t))
72 return RTE_STATUS_INVALID_PARAM;
82 rte_mem_copy(&frame[1], data, data_size);
85 ctx->
is_role_a ?
"B" :
"A",
"CHECKPOINT_REQUEST",
86 (status == RTE_STATUS_OK) ?
"sent" : rte_status_to_string(status), NULL);
101 rte_timestamp_ms_t start_ms = 0U;
102 rte_timestamp_ms_t now_ms = 0U;
105 (void)rte_timer_now(&start_ms);
108 rte_duration_ms_t elapsed;
109 rte_duration_ms_t remaining;
110 rte_duration_ms_t poll_ms;
113 (void)rte_timer_now(&now_ms);
114 elapsed = (rte_duration_ms_t)(now_ms - start_ms);
115 if (elapsed >= (rte_duration_ms_t)timeout_ms)
117 return RTE_STATUS_TIMEOUT;
119 remaining = (rte_duration_ms_t)timeout_ms - elapsed;
120 poll_ms = (remaining > 20U) ? 20U : remaining;
127 status = rte_channel_service_read(&ctx->
com.
peer_channel, in_bytes,
sizeof(in_bytes), poll_ms);
128 if (status == RTE_STATUS_OK)
133 rte_mem_copy(data, &in_bytes[1], data_size);
138 rte_mem_copy(&reply_frame[1], &in_bytes[1],
sizeof(rte_vital_message_t));
141 return RTE_STATUS_OK;
166 else if (status != RTE_STATUS_TIMEOUT)
177 if (ctx == NULL || data == NULL || data_size !=
sizeof(rte_vital_message_t))
179 return RTE_STATUS_INVALID_PARAM;
192 return RTE_STATUS_OK;
198 return RTE_STATUS_OK;
213 return RTE_STATUS_OK;
static rte_status_t poll_for_checkpoint_frame(ab_gp_channel_context_t *ctx, void *data, size_t data_size, uint32_t timeout_ms)
Step 3: last-ditch live poll for whatever remains of this round's budget.
static bool ab_gp_channel_checkpoint_peer_recent(const ab_gp_channel_context_t *ctx)
True if the peer exchanged a checkpoint frame with us within the last RTE_EXAMPLE_AB_CHECKPOINT_LOOKB...
rte_status_t ab_gp_channel_checkpoint_backend_send(void *channel, const void *data, size_t data_size)
rte_channel_send_fn for the checkpoint transport: wraps the given rte_vital_message_t in a PEER_MSG_K...
static void ab_gp_channel_checkpoint_note_peer_frame(ab_gp_channel_context_t *ctx)
Records that a CHECKPOINT_REQUEST/REPLY was just seen from the peer, for the lookback check in ab_gp_...
rte_status_t ab_gp_channel_checkpoint_backend_recv(void *channel, void *data, size_t data_size, uint32_t timeout_ms)
rte_channel_recv_fn for the checkpoint transport: waits (bounded by timeout_ms) for a PEER_MSG_KIND_C...
rte_channel_t OSAdapter for the built-in AppManager checkpoint (ADR-019 addendum, rewired onto rte_vo...
void ab_gp_channel_negotiate_service_link(ab_gp_channel_context_t *ctx)
Fast internal-cycle service of the negotiation link (warm/hot standby only).
void ab_gp_channel_negotiate_on_startup_ts_frame(ab_gp_channel_context_t *ctx, const uint8_t *payload, size_t size)
Handles a PEER_MSG_KIND_STARTUP_TS frame that arrives after ab_gp_channel_negotiate_init() returned (...
This channel's own West<->East inter-site negotiation link - see ab_gp_channel.c's file header for ho...
Modular type definitions for AB channel components (Com, Train, DB, Redundancy).
#define PEER_WIRE_FRAME_SIZE
#define PEER_MSG_KIND_KM114_DIGEST
#define PEER_MSG_KIND_CHECKPOINT_REQUEST
#define PEER_MSG_KIND_STARTUP_TS
#define PEER_MSG_KIND_CHECKPOINT_REPLY
#define AB_GP_DEFERRED_PEER_FRAMES
Capacity of ab_gp_channel_context_t::deferred_peer_frames.
#define PEER_MSG_KIND_SITE_STATE
#define PEER_MSG_KIND_SAF_RB
Declares ab_gp_channel_sleep_ms() - see ab_gp_channel_types.h's own doc on why this tiny helper gets ...
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 ca...
The A/B sibling's last site-state frame (PEER_MSG_KIND_SITE_STATE), kept raw and handed to Platform_R...
#define RTE_EXAMPLE_AB_CHECKPOINT_LOOKBACK_CYCLES
#define RTE_EXAMPLE_LINK_TIMEOUT_MS
const char * site_config_name(rte_example_site_t site)
Central application context owned by composition root (main.c).
uint8_t deferred_peer_frames[AB_GP_DEFERRED_PEER_FRAMES][PEER_WIRE_FRAME_SIZE]
ab_gp_sibling_state_t peer_site_state
uint32_t last_peer_checkpoint_cycle
uint8_t last_sent_checkpoint_arrival[sizeof(rte_vital_message_t)]
bool has_cached_checkpoint_request
bool has_last_sent_checkpoint_arrival
uint8_t cached_checkpoint_reply[sizeof(rte_vital_message_t)]
uint8_t deferred_peer_count
uint8_t cached_checkpoint_request[sizeof(rte_vital_message_t)]
bool has_cached_checkpoint_reply
rte_channel_service_t peer_channel