SafeAPI RBC 2oo2 Generic Application
IL/CTC route and train logic for the safeAPIRBC2oo2 reference RBC
Loading...
Searching...
No Matches
ab_ga_il_wire.h File Reference

Dedicated IL <-> RBC message payloads and codec (wire kinds RBC_MSG_IL_ROUTE_CMD / RBC_MSG_IL_STATUS / RBC_MSG_IL_ROUTE_INDICATION - see rbc_wire_types.h). More...

#include <stdbool.h>
#include <stdint.h>
#include "rbc_wire_types.h"
Include dependency graph for ab_ga_il_wire.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ab_ga_il_route_cmd_t
 Decoded RBC_MSG_IL_ROUTE_CMD payload. More...
struct  ab_ga_il_status_msg_t
 Decoded RBC_MSG_IL_STATUS payload. More...
struct  ab_ga_il_route_indication_t
 RBC_MSG_IL_ROUTE_INDICATION payload (RBC -> IL). More...

Functions

bool ab_ga_il_wire_decode_route_cmd (const uint8_t frame[RBC_ENVELOPE_WIRE_SIZE], ab_ga_il_route_cmd_t *out)
 Decodes + fully range-validates an RBC_MSG_IL_ROUTE_CMD frame.
bool ab_ga_il_wire_decode_status (const uint8_t frame[RBC_ENVELOPE_WIRE_SIZE], ab_ga_il_status_msg_t *out)
 Decodes + validates an RBC_MSG_IL_STATUS frame. Same contract.
void ab_ga_il_wire_encode_route_indication (uint8_t frame[RBC_ENVELOPE_WIRE_SIZE], const ab_ga_il_route_indication_t *in)
 Encodes an RBC_MSG_IL_ROUTE_INDICATION frame (zero-fills the whole RBC_ENVELOPE_WIRE_SIZE slot first).

Detailed Description

Dedicated IL <-> RBC message payloads and codec (wire kinds RBC_MSG_IL_ROUTE_CMD / RBC_MSG_IL_STATUS / RBC_MSG_IL_ROUTE_INDICATION - see rbc_wire_types.h).

These do NOT use the shared 96-byte rbc_envelope_t / its 40 fixed-offset fields. Each has its own small packed layout, still shipped inside the fixed RBC_ENVELOPE_WIRE_SIZE relay slot (rest zero-padded) so the C relay framing is unchanged. All multi-byte fields little-endian.

Byte layouts (offset : field):

RBC_MSG_IL_ROUTE_CMD (IL -> RBC), 24 meaningful bytes: 0 : kind (25) 1 : reserved (0) 2 : route_type u8 (rbc_il_route_type_t) 3 : route_status u8 (rbc_il_route_status_t) 4 : degraded_status u8 (rbc_il_degraded_status_t) 5 : release_route_request u8 (0 = No, 1 = Yes) 6 : first_route_in_path u8 (0 = No, 1 = Yes) 7 : reserved (0) 8 : route_id i32 (-1 = unset) 12 : start_signal i32 (-1 = unset) 16 : end_signal i32 (-1 = unset) 20 : reserved (0)

RBC_MSG_IL_STATUS (IL -> RBC), 4 meaningful bytes: 0 : kind (26) 1 : il_status u8 (rbc_il_status_t) 2 : reserved (0, 2 bytes)

RBC_MSG_IL_ROUTE_INDICATION (RBC -> IL), 24 meaningful bytes: 0 : kind (27) 1 : reserved (0) 2 : train_in_route u8 (0/1) 3 : train_has_ma_in_route u8 (0/1) 4 : emergency_in_route u8 (0/1) 5 : emergency_type i8 (rbc_il_emergency_type_t, -1 = none) 6 : route_fsm_state u8 (ab_ga_route_state_t 0..6 - the RBC's acknowledged per-route state) 7 : route_fsm_is_stub u8 (0/1 - state is a not-yet-implemented OS/SH/DEGRADED stub) 8 : route_id i32 (-1 = unset) 12 : start_signal i32 (-1 = unset) 16 : end_signal i32 (-1 = unset) 20 : allocated_train_nid_engine i32 (-1 = none)

The ILRBCSim Python side carries a byte-identical mirror of this - keep the two in lockstep (same precedent as SimCore/rbc_wire.py for the flat scheme).

Definition in file ab_ga_il_wire.h.

Function Documentation

◆ ab_ga_il_wire_decode_route_cmd()

bool ab_ga_il_wire_decode_route_cmd ( const uint8_t frame[RBC_ENVELOPE_WIRE_SIZE],
ab_ga_il_route_cmd_t * out )

Decodes + fully range-validates an RBC_MSG_IL_ROUTE_CMD frame.

Parameters
[in]frameRaw RBC_ENVELOPE_WIRE_SIZE bytes; frame[0] must be RBC_MSG_IL_ROUTE_CMD.
[out]outDecoded payload on success; untouched on failure.
Returns
true only if frame[0] is the right kind AND every field is in range (enums within their declared value sets; identity fields -1 or >= 0; the two flags 0 or 1). false otherwise - a malformed or out-of-range command is rejected, not clamped.

Definition at line 60 of file ab_ga_il_wire.c.

◆ ab_ga_il_wire_decode_status()

bool ab_ga_il_wire_decode_status ( const uint8_t frame[RBC_ENVELOPE_WIRE_SIZE],
ab_ga_il_status_msg_t * out )

Decodes + validates an RBC_MSG_IL_STATUS frame. Same contract.

Definition at line 119 of file ab_ga_il_wire.c.

◆ ab_ga_il_wire_encode_route_indication()

void ab_ga_il_wire_encode_route_indication ( uint8_t frame[RBC_ENVELOPE_WIRE_SIZE],
const ab_ga_il_route_indication_t * in )

Encodes an RBC_MSG_IL_ROUTE_INDICATION frame (zero-fills the whole RBC_ENVELOPE_WIRE_SIZE slot first).

Parameters
[out]frameReceives the full slot.
[in]inPayload to encode. Assumed already valid (RBC-side producer).

Definition at line 139 of file ab_ga_il_wire.c.