PER Firmware
Loading...
Searching...
No Matches
diagnostics.c File Reference

Common logger for basic CPU and FreeRTOS task profiling data. More...

#include "diagnostics.h"
#include <string.h>
#include "rtos/rtos.h"
Include dependency graph for diagnostics.c:

Functions

static bool calculate_utilization (uint32_t current_runtime, uint32_t previous_runtime, uint32_t total_delta, float *cpu_usage)
 
static void begin_snapshot (UBaseType_t count)
 
static void calculate_task_utilization (TaskStatus_t *raw_task, diagnostics_task_t *task, uint32_t total_delta)
 
static void save_task_runtimes (UBaseType_t task_count)
 
static diagnostics_task_state_t encode_task_state (eTaskState state)
 
static uint8_t encode_cpu_percent (float percent, bool valid)
 
static uint16_t encode_stack_hwm (uint32_t bytes)
 
static void send_task_diagnostics (const diagnostics_can_fns_t *can_fns, uint8_t task_index)
 
static void send_summary_diagnostics (const diagnostics_can_fns_t *can_fns)
 
static void sample_diagnostics (void)
 
void diagnostics_periodic (const diagnostics_can_fns_t *can_fns)
 Periodically samples task statistics and transmits diagnostics over CAN.
 

Variables

static constexpr uint32_t DIAGNOSTICS_SAMPLE_PERIOD_MS = 1000
 
static constexpr uint8_t DIAGNOSTICS_TICKS_PER_SAMPLE
 
static constexpr uint8_t DIAGNOSTICS_CPU_INVALID = UINT8_MAX
 
static diagnostics_context_t g_diagnostics_context = {0}
 

Detailed Description

Common logger for basic CPU and FreeRTOS task profiling data.

Author
Patrick McNaughton (pmcna.nosp@m.ugh@.nosp@m.purdu.nosp@m.e.ed.nosp@m.u)

Function Documentation

◆ begin_snapshot()

static void begin_snapshot ( UBaseType_t count)
static
Here is the caller graph for this function:

◆ calculate_task_utilization()

static void calculate_task_utilization ( TaskStatus_t * raw_task,
diagnostics_task_t * task,
uint32_t total_delta )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_utilization()

static bool calculate_utilization ( uint32_t current_runtime,
uint32_t previous_runtime,
uint32_t total_delta,
float * cpu_usage )
static
Here is the caller graph for this function:

◆ diagnostics_periodic()

void diagnostics_periodic ( const diagnostics_can_fns_t * can_fns)

Periodically samples task statistics and transmits diagnostics over CAN.

Samples all tasks once per second (every 20 ticks at 50 ms) Sends at most one task (status + name character) per tick and one board summary per cycle.

Parameters
can_fnsCAN send callbacks
Here is the call graph for this function:

◆ encode_cpu_percent()

static uint8_t encode_cpu_percent ( float percent,
bool valid )
static
Here is the caller graph for this function:

◆ encode_stack_hwm()

static uint16_t encode_stack_hwm ( uint32_t bytes)
static
Here is the caller graph for this function:

◆ encode_task_state()

static diagnostics_task_state_t encode_task_state ( eTaskState state)
static
Here is the caller graph for this function:

◆ sample_diagnostics()

static void sample_diagnostics ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_task_runtimes()

static void save_task_runtimes ( UBaseType_t task_count)
static
Here is the caller graph for this function:

◆ send_summary_diagnostics()

static void send_summary_diagnostics ( const diagnostics_can_fns_t * can_fns)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_task_diagnostics()

static void send_task_diagnostics ( const diagnostics_can_fns_t * can_fns,
uint8_t task_index )
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ DIAGNOSTICS_CPU_INVALID

uint8_t DIAGNOSTICS_CPU_INVALID = UINT8_MAX
staticconstexpr

◆ DIAGNOSTICS_SAMPLE_PERIOD_MS

uint32_t DIAGNOSTICS_SAMPLE_PERIOD_MS = 1000
staticconstexpr

◆ DIAGNOSTICS_TICKS_PER_SAMPLE

uint8_t DIAGNOSTICS_TICKS_PER_SAMPLE
staticconstexpr
Initial value:
=
static constexpr uint32_t DIAGNOSTICS_SAMPLE_PERIOD_MS
Definition diagnostics.c:13
#define DIAGNOSTICS_TICK_PERIOD_MS
Definition diagnostics.h:19

◆ g_diagnostics_context

diagnostics_context_t g_diagnostics_context = {0}
static