|
Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
|
Linux POSIX example application demonstrating RteFramework. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <signal.h>#include "rte/status/rte_status.h"#include "rte/types/rte_types.h"#include "rte/buffer/rte_buffer.h"#include "rte/string/rte_string.h"#include "rte/log/rte_log.h"#include "rte/timer/rte_timer.h"#include "rte/safestate/rte_safestate.h"Go to the source code of this file.
Data Structures | |
| struct | app_context_t |
Macros | |
| #define | APP_NAME "railway-message-processor" |
| #define | APP_VERSION "1.0.0" |
| #define | MESSAGE_BUFFER_SIZE 256U |
| #define | LOG_LINE_MAX 128U |
Enumerations | |
| enum | app_state_t { STATE_INIT , STATE_RUNNING , STATE_ERROR , STATE_SHUTDOWN } |
Functions | |
| static void | log_line (rte_log_level_t level, const char *line) |
| Logs one already-formatted line at the given level. | |
| static rte_status_t | app_init (void) |
| Initialize the application context. | |
| static rte_status_t | process_message (const uint8_t *msg, size_t len) |
| Process a single message (simulated). | |
| static void | heartbeat_callback (rte_timer_handle_t handle, void *user_context) |
| Timer callback - generates periodic heartbeats. | |
| static rte_status_t | simulate_train_message (void) |
| Simulate receiving a message from train. | |
| static void | signal_handler (int sig) |
| Signal handler for graceful shutdown. | |
| static rte_status_t | transition_to_state (app_state_t new_state) |
| Safe state transition. | |
| int | main (int argc, char *argv[]) |
Variables | |
| static app_context_t | g_app |
Linux POSIX example application demonstrating RteFramework.
This example shows a simple railway message processor running on Linux with POSIX OAL. It demonstrates:
Use case: Simple train communication handler
No timer/log OSAdapter is registered in this minimal example (a real integration wires one per ADR-005 - see safeAPIRBC2oo2's src/posix_osadapter/ for a full POSIX OSAdapter), so rte_log_write() is a documented no-op here (REQ-OAL-LOG-001: a missing OSAdapter never blocks or fails the caller) and the timer callback is invoked directly rather than through a real rte_timer_create()/_start() - see the main loop below.
Definition in file main.c.
|
static |
Logs one already-formatted line at the given level.
rte_log_write() takes a fixed message string, deliberately no varargs (MISRA C:2012 Rule 17.1 - see its own header) - callers below build the line with snprintf() into a fixed-size buffer first, at the call site, rather than through a variadic wrapper here, to keep that same no-varargs discipline visible in this example rather than reintroducing it one layer down.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |