openaliro
Aliro reader: UWB/CCC core and ESP32-S3/C5/C6 port
Loading...
Searching...
No Matches
flight_recorder.c File Reference

Binary flight-recorder format: framed records (magic, metadata, configuration, events, end) with little-endian integers and truncation handling; read/write operations with overflow detection. More...

#include "flight_recorder.h"
#include <string.h>
Include dependency graph for flight_recorder.c:

Functions

static void p8 (uint8_t *b, size_t *o, uint8_t v)
 Write a 1-byte unsigned integer to buffer at offset o and advance o.
 
static void p16 (uint8_t *b, size_t *o, uint16_t v)
 Write a 2-byte little-endian unsigned integer to buffer at offset o and advance o.
 
static void p32 (uint8_t *b, size_t *o, uint32_t v)
 Write a 4-byte little-endian unsigned integer to buffer at offset o and advance o.
 
static void p64 (uint8_t *b, size_t *o, uint64_t v)
 Write an 8-byte little-endian unsigned integer to buffer at offset o and advance o.
 
static void pbytes (uint8_t *b, size_t *o, const uint8_t *s, size_t n)
 Copy n bytes from s to buffer at offset o and advance o.
 
static uint8_t g8 (const uint8_t *b, size_t *o)
 Read and advance a 1-byte unsigned integer from buffer at offset o.
 
static uint16_t g16 (const uint8_t *b, size_t *o)
 Read and advance a 2-byte little-endian unsigned integer from buffer at offset o.
 
static uint32_t g32 (const uint8_t *b, size_t *o)
 Read and advance a 4-byte little-endian unsigned integer from buffer at offset o.
 
static uint64_t g64 (const uint8_t *b, size_t *o)
 Read and advance an 8-byte little-endian unsigned integer from buffer at offset o.
 
void fr_writer_init (fr_writer_t *w, uint8_t *buf, size_t cap)
 Initialize a flight-recorder writer with an output buffer; write the magic prefix if capacity permits, otherwise latch overflow flag.
 
int fr_write_meta (fr_writer_t *w, uint16_t port, const char *sha)
 Emit a META record containing flight-recorder version, host port, and optional commit SHA; return 0 on success or -1 on buffer overflow.
 
int fr_write_config (fr_writer_t *w, const struct fr_config *c)
 Emit a CONFIG record containing Aliro session parameters and UWB radio configuration; truncate URSK and radio controller data to maximum lengths if needed; return 0 on success or -1 on buffer overflow.
 
int fr_write_ev (fr_writer_t *w, const struct fr_ev *e)
 Emit an EV record containing DW3000 register snapshot and received frame data; truncate frame to maximum length if needed; return 0 on success or -1 on buffer overflow.
 
int fr_write_end (fr_writer_t *w, uint32_t n_events, bool truncated)
 Emit an END record with event count and truncation flag; return 0 on success or -1 on buffer overflow.
 
void fr_reader_init (fr_reader_t *r, const uint8_t *buf, size_t len)
 Initialize a flight-recorder reader to parse a binary buffer; do not validate the magic prefix until the first read.
 
int fr_read_next (fr_reader_t *r, struct fr_record *out)
 Parse one flight-recorder record from the reader buffer; check magic prefix on first call, validate frame format and type; return the record type on success, 0 for clean end-of-buffer, or -1 on malformed input.
 

Detailed Description

Binary flight-recorder format: framed records (magic, metadata, configuration, events, end) with little-endian integers and truncation handling; read/write operations with overflow detection.