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

Record queues from the producing tasks to the LogTask. More...

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

Go to the source code of this file.

Macros

#define LOG_Q_IMU_SIZE   4096u
 ~1.2 s of ImuTask records: covers a sector erase
 
#define LOG_Q_BATT_SIZE   512u
 

Enumerations

enum  { LOG_SRC_IMU = 0 , LOG_SRC_BATT = 1 , LOG_SRC_COUNT }
 

Functions

uint8_t log_q_active (void)
 
int log_q_put (uint8_t src, uint8_t type, const void *payload, uint8_t len)
 0 = queued
 
void log_q_reset (void)
 
void log_q_set_active (uint8_t on)
 
uint32_t log_q_get (uint8_t src, uint8_t *type, void *payload, uint8_t cap)
 next record of 'src': returns payload length + 1, 0 if empty
 
uint16_t log_q_take_drops (uint8_t src)
 

Detailed Description

Record queues from the producing tasks to the LogTask.

One lock-free single-producer single-consumer byte ring per producing task (ImuTask, BattTask). A record goes in whole or not at all; a full ring counts a drop, reported later in the log as LR_DROP. Producers call log_q_put() only while log_q_active() is 1 (a log is open), so nothing is queued when the log is off.

Host-testable.

Definition in file log_queue.h.

Macro Definition Documentation

◆ LOG_Q_IMU_SIZE

#define LOG_Q_IMU_SIZE   4096u

~1.2 s of ImuTask records: covers a sector erase

Definition at line 20 of file log_queue.h.

◆ LOG_Q_BATT_SIZE

#define LOG_Q_BATT_SIZE   512u

Definition at line 21 of file log_queue.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LOG_SRC_IMU 
LOG_SRC_BATT 
LOG_SRC_COUNT 

Definition at line 18 of file log_queue.h.

Function Documentation

◆ log_q_active()

uint8_t log_q_active ( void  )

Definition at line 24 of file log_queue.c.

References s_active.

Referenced by log_records(), logf_att(), logf_est(), logf_event(), logf_flight(), logf_power(), and logf_vert().

Here is the caller graph for this function:

◆ log_q_put()

int log_q_put ( uint8_t  src,
uint8_t  type,
const void *  payload,
uint8_t  len 
)

0 = queued

Definition at line 33 of file log_queue.c.

References b, ring_t::buf, ring_t::drops, ring_t::head, LOG_SRC_COUNT, n, s_r, ring_t::size, SPSC_BARRIER, ring_t::tail, and used.

Referenced by logf_att(), logf_est(), logf_event(), logf_flight(), logf_power(), and logf_vert().

Here is the caller graph for this function:

◆ log_q_reset()

void log_q_reset ( void  )

Definition at line 27 of file log_queue.c.

References ring_t::drops, ring_t::drops_seen, ring_t::head, LOG_SRC_COUNT, s_active, s_r, and ring_t::tail.

Referenced by log_task_init().

Here is the caller graph for this function:

◆ log_q_set_active()

void log_q_set_active ( uint8_t  on)

Definition at line 25 of file log_queue.c.

References on, and s_active.

Referenced by recording().

Here is the caller graph for this function:

◆ log_q_get()

uint32_t log_q_get ( uint8_t  src,
uint8_t *  type,
void *  payload,
uint8_t  cap 
)

next record of 'src': returns payload length + 1, 0 if empty

Definition at line 52 of file log_queue.c.

References b, ring_t::buf, cap, ring_t::head, LOG_SRC_COUNT, s_r, ring_t::size, SPSC_BARRIER, and ring_t::tail.

Referenced by drain(), and log_task_step().

Here is the caller graph for this function:

◆ log_q_take_drops()

uint16_t log_q_take_drops ( uint8_t  src)

Definition at line 73 of file log_queue.c.

References ring_t::drops, ring_t::drops_seen, LOG_SRC_COUNT, n, and s_r.

Referenced by drain(), and log_task_step().

Here is the caller graph for this function: