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

Wire payload for RBC_UTIL_TOPIC_JRU_LOG publishes: A/B forwarding one local log event to Gateway, for Gateway to hand to Platform_Protocol_JRU's rte_osadapter_log_t. More...

#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "rte/oal/log/rte_log.h"
#include "rbc_util_frame.h"
Include dependency graph for rbc_util_jru_payload.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static void rbc_util_jru_payload_encode (char *out, size_t out_size, rte_log_level_t level, const char *tag, const char *message)
 Encodes one forwarded log event into a JRU_LOG publish payload.
static bool rbc_util_jru_payload_decode (const char *payload, rte_log_level_t *out_level, char *tag_out, size_t tag_out_size, char *msg_out, size_t msg_out_size)
 Decodes a JRU_LOG publish payload back into its fields.

Detailed Description

Wire payload for RBC_UTIL_TOPIC_JRU_LOG publishes: A/B forwarding one local log event to Gateway, for Gateway to hand to Platform_Protocol_JRU's rte_osadapter_log_t.

The RBC_UTIL_MSG_PUBLISH payload (rbc_util_frame.h, RBC_UTIL_PAYLOAD_MAX = 250 bytes) carries this ASCII encoding: "<level_digit>|<tag>|<message>". A pipe delimiter rather than rte_log_write_event()'s own "Key=Value" convention because the forwarded message text is free-form (it may itself legitimately contain '=' or spaces) and only needs to survive as the LAST field, not be individually re-parsed - level is one digit (0-3, rte_log_level_t's own range) and tag is assumed delimiter-free (every call site in this codebase uses a short UPPER_CASE identifier, never one containing '|').

Pure types + static-inline codec, no I/O - same posture as rbc_util_frame.h. Consumed by C99 (AB side, the forwarding OSAdapter) and C++ (Gateway's status service).

Definition in file rbc_util_jru_payload.h.

Function Documentation

◆ rbc_util_jru_payload_encode()

void rbc_util_jru_payload_encode ( char * out,
size_t out_size,
rte_log_level_t level,
const char * tag,
const char * message )
inlinestatic

Encodes one forwarded log event into a JRU_LOG publish payload.

Parameters
outDestination, at least RBC_UTIL_PAYLOAD_MAX + 1 bytes (NUL-terminated).
out_sizeSize of out.
levelOriginal severity.
tagOriginal tag, or NULL/empty for none.
messageOriginal message. Truncated (not rejected) if the encoded line would not fit.

Definition at line 41 of file rbc_util_jru_payload.h.

◆ rbc_util_jru_payload_decode()

bool rbc_util_jru_payload_decode ( const char * payload,
rte_log_level_t * out_level,
char * tag_out,
size_t tag_out_size,
char * msg_out,
size_t msg_out_size )
inlinestatic

Decodes a JRU_LOG publish payload back into its fields.

Parameters
payloadNUL-terminated payload as decoded by rbc_util_frame_decode().
out_levelDestination for the severity (RTE_LOG_LEVEL_INFO if the digit is missing or out of range - a defensive default, never a decode failure).
tag_outDestination buffer for the tag.
tag_out_sizeSize of tag_out.
msg_outDestination buffer for the message (everything after the second '|').
msg_out_sizeSize of msg_out.
Returns
false only if payload has fewer than two '|' delimiters (malformed frame); the caller should drop it. Every field is still NUL-terminated on a false return.

Definition at line 61 of file rbc_util_jru_payload.h.