ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
log_format.h File Reference

On-flash format of the ACwing flight log (format 1). More...

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

Go to the source code of this file.

Data Structures

struct  log_sector_hdr_t
 sector header More...
 
struct  log_info_t
 
struct  log_time_t
 
struct  log_att_t
 
struct  log_vert_t
 
struct  log_flight_t
 
struct  log_event_t
 
struct  log_est_t
 
struct  log_power_t
 
struct  log_drop_t
 

Macros

#define LOG_FORMAT   1u
 
#define LOG_MAGIC   0x474C4341u
 "ACLG"
 
#define LOG_SECTOR   4096u
 
#define LOG_PAGE   256u
 
#define LOG_HDR_SIZE   20u
 
#define LOG_REC_OVERHEAD   3u
 type, len, crc8
 
#define LOG_REC_MAX   64u
 largest payload
 

Enumerations

enum  {
  LR_INFO = 0x01 , LR_TIME = 0x02 , LR_ATT = 0x10 , LR_VERT = 0x11 ,
  LR_FLIGHT = 0x12 , LR_EVENT = 0x13 , LR_EST = 0x14 , LR_POWER = 0x20 ,
  LR_DROP = 0x7F
}
 

Functions

uint8_t log_crc8 (const uint8_t *p, uint32_t n)
 
uint16_t log_crc16 (const uint8_t *p, uint32_t n)
 

Detailed Description

On-flash format of the ACwing flight log (format 1).

The log flash (W25Q128JV, 16 MB, 4 KB sectors) is a ring of sectors. A log (one per arming, or one per power-on with logMode = always) is a run of consecutive sectors; when the flash is full the oldest sectors are erased and reused, so the oldest log may lose its beginning ("truncated").

Every sector starts with a 20-byte header, then records until the end of the sector or the first 0xFF byte (erased flash). A record never crosses a sector boundary:

[type u8][len u8][payload: len bytes][crc8 over type, len, payload]

CRC-8: poly 0x07, init 0x00 (CRC-8/SMBUS). A reader that finds a bad CRC skips to the next sector. All values little-endian, packed.

The PC decoders (02 - Tools) follow this file: change both together and bump LOG_FORMAT. A NEW record type does not need a new format: readers skip the types they do not know (LR_TIME was added that way, firmware 0.6).

Definition in file log_format.h.

Macro Definition Documentation

◆ LOG_FORMAT

#define LOG_FORMAT   1u

Definition at line 28 of file log_format.h.

◆ LOG_MAGIC

#define LOG_MAGIC   0x474C4341u

"ACLG"

Definition at line 29 of file log_format.h.

◆ LOG_SECTOR

#define LOG_SECTOR   4096u

Definition at line 30 of file log_format.h.

◆ LOG_PAGE

#define LOG_PAGE   256u

Definition at line 31 of file log_format.h.

◆ LOG_HDR_SIZE

#define LOG_HDR_SIZE   20u

Definition at line 32 of file log_format.h.

◆ LOG_REC_OVERHEAD

#define LOG_REC_OVERHEAD   3u

type, len, crc8

Definition at line 33 of file log_format.h.

◆ LOG_REC_MAX

#define LOG_REC_MAX   64u

largest payload

Definition at line 34 of file log_format.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LR_INFO 

first record of a log

LR_TIME 

wall clock: after LR_INFO, and when it is set

LR_ATT 

attitude and IMU, 50 Hz

LR_VERT 

vertical estimate and loop, 50 Hz

LR_FLIGHT 

flight core state, 10 Hz

LR_EVENT 

every EVENT of the flight core

LR_EST 

estimator health, 10 Hz

LR_POWER 

battery, 10 Hz (BattTask)

LR_DROP 

records lost because a queue was full

Definition at line 50 of file log_format.h.

Function Documentation

◆ log_crc8()

uint8_t log_crc8 ( const uint8_t *  p,
uint32_t  n 
)

Definition at line 28 of file log_store.c.

References n.

Referenced by log_append().

Here is the caller graph for this function:

◆ log_crc16()

uint16_t log_crc16 ( const uint8_t *  p,
uint32_t  n 
)

Definition at line 38 of file log_store.c.

References n.

Referenced by hdr_ok(), and start_sector().

Here is the caller graph for this function: