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

Wire chunking for RBC_UTIL_TOPIC_KM114_FILE publishes: Gateway relays one opaque Subset-114 off-line KMC file's raw bytes to A/B, split across as many UTIL frames as needed. Gateway never interprets these bytes - see rbc_util_frame.h's own doc on this topic and Platform_Protocol_KM114/CLAUDE.md's "Consumption design" note. More...

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

Go to the source code of this file.

Macros

#define RBC_UTIL_KM114_RELAY_HEADER_SIZE   4U
#define RBC_UTIL_KM114_RELAY_CHUNK_MAX   (RBC_UTIL_PAYLOAD_MAX - RBC_UTIL_KM114_RELAY_HEADER_SIZE)
#define RBC_UTIL_KM114_RELAY_MAX_FRAGS   2U
#define RBC_UTIL_KM114_RELAY_FILE_MAX   (RBC_UTIL_KM114_RELAY_CHUNK_MAX * RBC_UTIL_KM114_RELAY_MAX_FRAGS)

Functions

static size_t rbc_util_km114_relay_encode_chunk (uint8_t *out, uint16_t total_len, uint8_t frag_index, uint8_t frag_count, const uint8_t *chunk, size_t chunk_len)
 Encodes one chunk of a file relay transfer into a RBC_UTIL_TOPIC_KM114_FILE publish payload.
static bool rbc_util_km114_relay_decode_chunk (const uint8_t *payload, uint8_t payload_len, uint16_t *out_total_len, uint8_t *out_frag_index, uint8_t *out_frag_count, const uint8_t **out_chunk, uint8_t *out_chunk_len)
 Decodes one chunk's header out of a received RBC_UTIL_TOPIC_KM114_FILE publish payload (payload_len bytes at payload - NOT NUL-terminated ASCII, use payload_len, not strlen()).

Detailed Description

Wire chunking for RBC_UTIL_TOPIC_KM114_FILE publishes: Gateway relays one opaque Subset-114 off-line KMC file's raw bytes to A/B, split across as many UTIL frames as needed. Gateway never interprets these bytes - see rbc_util_frame.h's own doc on this topic and Platform_Protocol_KM114/CLAUDE.md's "Consumption design" note.

RBC_UTIL_MSG_PUBLISH payload layout (RBC_UTIL_PAYLOAD_MAX = 250 bytes total): [0..1] total_len uint16 little-endian - the full file's byte length (identical on every chunk of the same transfer, so a chunk arriving alone is still self-describing). [2] frag_index uint8 - 0-based. [3] frag_count uint8 - total chunk count for this transfer. [4..] chunk bytes up to RBC_UTIL_KM114_RELAY_CHUNK_MAX raw bytes (NOT ASCII - may contain any byte value, including 0x00; callers must use the decoded frame's own payload_len, never strlen()).

Pure types + static-inline codec, no I/O - same posture as rbc_util_frame.h/ rbc_util_jru_payload.h. RBC_UTIL_KM114_RELAY_FILE_MAX (492 bytes, two chunks) comfortably covers every Subset-114 message type this workspace's Platform_Protocol_KM114 implements, including a RESPONSE_NOTIF with the largest permitted text field (KM114_MAX_TEXT, 255 octets) - see that product's include/km114/km114.h.

Definition in file rbc_util_km114_relay.h.

Macro Definition Documentation

◆ RBC_UTIL_KM114_RELAY_HEADER_SIZE

#define RBC_UTIL_KM114_RELAY_HEADER_SIZE   4U

Definition at line 38 of file rbc_util_km114_relay.h.

◆ RBC_UTIL_KM114_RELAY_CHUNK_MAX

#define RBC_UTIL_KM114_RELAY_CHUNK_MAX   (RBC_UTIL_PAYLOAD_MAX - RBC_UTIL_KM114_RELAY_HEADER_SIZE)

Definition at line 39 of file rbc_util_km114_relay.h.

◆ RBC_UTIL_KM114_RELAY_MAX_FRAGS

#define RBC_UTIL_KM114_RELAY_MAX_FRAGS   2U

Definition at line 40 of file rbc_util_km114_relay.h.

◆ RBC_UTIL_KM114_RELAY_FILE_MAX

#define RBC_UTIL_KM114_RELAY_FILE_MAX   (RBC_UTIL_KM114_RELAY_CHUNK_MAX * RBC_UTIL_KM114_RELAY_MAX_FRAGS)

Definition at line 41 of file rbc_util_km114_relay.h.

Function Documentation

◆ rbc_util_km114_relay_encode_chunk()

size_t rbc_util_km114_relay_encode_chunk ( uint8_t * out,
uint16_t total_len,
uint8_t frag_index,
uint8_t frag_count,
const uint8_t * chunk,
size_t chunk_len )
inlinestatic

Encodes one chunk of a file relay transfer into a RBC_UTIL_TOPIC_KM114_FILE publish payload.

Parameters
outDestination, at least RBC_UTIL_PAYLOAD_MAX bytes.
total_lenFull file length (same value on every chunk of this transfer).
frag_index0-based chunk index.
frag_countTotal chunk count.
chunkThis chunk's raw bytes.
chunk_lenLength of chunk; must be <= RBC_UTIL_KM114_RELAY_CHUNK_MAX.
Returns
Total payload length to pass as rbc_util_frame_encode()'s own payload_len, or 0 if chunk_len is out of range.

Definition at line 55 of file rbc_util_km114_relay.h.

◆ rbc_util_km114_relay_decode_chunk()

bool rbc_util_km114_relay_decode_chunk ( const uint8_t * payload,
uint8_t payload_len,
uint16_t * out_total_len,
uint8_t * out_frag_index,
uint8_t * out_frag_count,
const uint8_t ** out_chunk,
uint8_t * out_chunk_len )
inlinestatic

Decodes one chunk's header out of a received RBC_UTIL_TOPIC_KM114_FILE publish payload (payload_len bytes at payload - NOT NUL-terminated ASCII, use payload_len, not strlen()).

Returns
false if payload_len is shorter than the fixed header.

Definition at line 80 of file rbc_util_km114_relay.h.