rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
servo_report.c File Reference

The automatic servo test's TXT report, line by line. More...

#include "servo_test.h"
#include <math.h>
#include <stdio.h>
#include <string.h>

Data Structures

struct  cursor_t
 Cursor that prints one report line, found by counting. More...

Macros

#define S(id)
 A word or a line format of the report, in the run's language.
#define CELL_MAX_A   99.999f
 The largest magnitude a step table cell prints, A: "-99999" mA is its widest text, 6 cells. No meter reads near it: the INA3221 reads to 32.760A on its smallest shunt.

Functions

static bool here (cursor_t *c)
 Count one line, and tell whether it is the one asked for.
static void limit_a (const cursor_t *c, char *b, size_t n, float a)
 A limit's value, or OFF for 0.
static const char * verdict_word (const cursor_t *c, bool checked, bool measured, bool over)
 The word for one check: NOT CHECKED, NOT MEASURED, FAIL or PASS.
static void ma_text (char *b, size_t n, float a)
 A current in whole mA, or "--" for none.
static void amps (char *b, size_t n, const servo_test_mean_t *m)
 A mean in whole mA, or "--" for none.
static void brownout_ran (const servo_test_t *t, const servo_test_step_t **first, const servo_test_step_t **last)
 The first and the last brown-out voltage that ran to its end; NULL for none.
static bool header_lines (const servo_test_t *t, cursor_t *c)
 The head of the report: title, result, device and firmware, the meter and supply, the readings' rates, the counts, the duration and the rows.
static bool settings_lines (const servo_test_t *t, cursor_t *c)
 The settings lines: the servo, the rate, the danger tag, HV, the ends, the steps, the brown-out walk, the current limit, the timing, the length and the limits.
static bool step_unseen (const servo_test_step_t *s)
 Whether none of a step's counted moves showed movement: the step is not measurable.
static void step_row (const cursor_t *c, const servo_test_step_t *s)
 One step's line of the steps table, 92 cells at most: the columns end where the two heading lines end their words.
static bool step_lines (const servo_test_t *t, cursor_t *c)
 The steps table: two heading lines, one line per characterisation step and, under a step cut short or not measurable, a line that says so; then the column notes and the threshold, arrival and late rules.
static void deg_end (const servo_test_t *t, const servo_test_step_t *s, unsigned end, char *b, char *eb, size_t n)
 A step's mean end angle at end and its error against the commanded one, both on the circle (servo_test_enc_end()), signed, or "--" for none.
static bool encoder_lines (const servo_test_t *t, cursor_t *c)
 The encoder lines: one line per characterisation step with its end angles, then the counts and the rules. Nothing when the encoder is off.
static bool brownout_lines (const servo_test_t *t, cursor_t *c)
 The brown-out lines: the walk's result, then the threshold rule.
static void stall_line (const cursor_t *c, const servo_test_cfg_t *g, bool by_limit)
 STALL AT against the current limit, or against the meter's range.
bool servo_test_stall_note (const servo_test_cfg_t *cfg, char *buf, size_t n)
 The line that says STALL AT cannot be reached in a run of cfg, in the language of cfg->text, into buf: against the current limit where that is the reason, else against the meter's range (servo_test_stall_unreachable()). False, and buf empty, when a reading can pass STALL AT.
static bool limit_lines (const servo_test_t *t, cursor_t *c)
 The limits lines: the idle, hold, travel, stall, late and unseen checks against their limits, and the first brown-out voltage.
static bool unmeasured_lines (const servo_test_t *t, cursor_t *c)
 The unmeasured notes: the heading and the lines that say what the run did not measure.
bool servo_report_line (const servo_test_t *t, unsigned idx, char *buf, size_t n)
 Line idx of the report into buf, in the language of t->cfg.text; false past the last.

Detailed Description

The automatic servo test's TXT report, line by line.

The lines come in sections, in this order: header, settings, steps, encoder, brown-out, limits and unmeasured notes; servo_report_line() picks one line by its index.

Its words are entries of servo_str.c's table, looked up in the language of the table the run was started with (S() below). A report is UTF-8, as the table's strings are.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ S

#define S ( id)
Value:
servo_str_in(c->text, SERVO_STR_##id)
const char * servo_str_in(const char *const *table, servo_str_t id)
Definition servo_str.c:47

A word or a line format of the report, in the run's language.

Function Documentation

◆ amps()

void amps ( char * b,
size_t n,
const servo_test_mean_t * m )
static

A mean in whole mA, or "--" for none.

Parameters
bOut: the mean in whole mA, or "--".
nSize of b, bytes.
mMean to print; no reading gives "--".

◆ brownout_lines()

bool brownout_lines ( const servo_test_t * t,
cursor_t * c )
static

The brown-out lines: the walk's result, then the threshold rule.

Parameters
tRun state.
cCursor.
Returns
true when the line asked for is one of these.

◆ brownout_ran()

void brownout_ran ( const servo_test_t * t,
const servo_test_step_t ** first,
const servo_test_step_t ** last )
static

The first and the last brown-out voltage that ran to its end; NULL for none.

Parameters
tRun state.
firstOut: the first such step, or NULL for none. NULL to skip.
lastOut: the last such step, or NULL for none. NULL to skip.

◆ deg_end()

void deg_end ( const servo_test_t * t,
const servo_test_step_t * s,
unsigned end,
char * b,
char * eb,
size_t n )
static

A step's mean end angle at end and its error against the commanded one, both on the circle (servo_test_enc_end()), signed, or "--" for none.

Parameters
tRun state.
sStep.
end0 for the low end, 1 for the high end.
bOut: the mean angle, degrees, or "--" for none.
ebOut: the error, degrees, or "--" for none.
nSize of b and eb, bytes.

◆ encoder_lines()

bool encoder_lines ( const servo_test_t * t,
cursor_t * c )
static

The encoder lines: one line per characterisation step with its end angles, then the counts and the rules. Nothing when the encoder is off.

Parameters
tRun state.
cCursor.
Returns
true when the line asked for is one of these.

◆ header_lines()

bool header_lines ( const servo_test_t * t,
cursor_t * c )
static

The head of the report: title, result, device and firmware, the meter and supply, the readings' rates, the counts, the duration and the rows.

Parameters
tRun state.
cCursor.
Returns
true when the line asked for is one of the head's lines.

◆ here()

bool here ( cursor_t * c)
static

Count one line, and tell whether it is the one asked for.

Parameters
cCursor. Its count goes up whether or not this is the line.
Returns
true when the line counted is the one asked for.

◆ limit_a()

void limit_a ( const cursor_t * c,
char * b,
size_t n,
float a )
static

A limit's value, or OFF for 0.

Parameters
cCursor; its text gives the language of OFF.
bOut: the text.
nSize of b, bytes.
aLimit, A; 0 or less is OFF.

◆ limit_lines()

bool limit_lines ( const servo_test_t * t,
cursor_t * c )
static

The limits lines: the idle, hold, travel, stall, late and unseen checks against their limits, and the first brown-out voltage.

Parameters
tRun state.
cCursor.
Returns
true when the line asked for is one of these.

◆ ma_text()

void ma_text ( char * b,
size_t n,
float a )
static

A current in whole mA, or "--" for none.

Parameters
bOut: the current in whole mA, at most 6 cells, or "--".
nSize of b, bytes.
aCurrent, A; one not a number or beyond CELL_MAX_A gives "--".

◆ servo_report_line()

bool servo_report_line ( const servo_test_t * t,
unsigned idx,
char * buf,
size_t n )

Line idx of the report into buf, in the language of t->cfg.text; false past the last.

Parameters
tRun state.
idxIndex of the line asked for.
bufOut: the line. NULL is refused.
nSize of buf, bytes; 0 is refused.
Returns
true when line idx exists and was written into buf; false past the last line, or for a NULL argument or n of 0.

◆ servo_test_stall_note()

bool servo_test_stall_note ( const servo_test_cfg_t * cfg,
char * buf,
size_t n )

The line that says STALL AT cannot be reached in a run of cfg, in the language of cfg->text, into buf: against the current limit where that is the reason, else against the meter's range (servo_test_stall_unreachable()). False, and buf empty, when a reading can pass STALL AT.

Parameters
cfgConfiguration of the run.
bufOut: the line.
nSize of buf, bytes.
Returns
true when the note was written; false when a reading can pass STALL AT.

◆ settings_lines()

bool settings_lines ( const servo_test_t * t,
cursor_t * c )
static

The settings lines: the servo, the rate, the danger tag, HV, the ends, the steps, the brown-out walk, the current limit, the timing, the length and the limits.

Parameters
tRun state.
cCursor.
Returns
true when the line asked for is one of the settings lines.

◆ stall_line()

void stall_line ( const cursor_t * c,
const servo_test_cfg_t * g,
bool by_limit )
static

STALL AT against the current limit, or against the meter's range.

Parameters
cCursor; buf receives the line.
gConfiguration of the run.
by_limittrue for the current limit, false for the meter's range.

◆ step_lines()

bool step_lines ( const servo_test_t * t,
cursor_t * c )
static

The steps table: two heading lines, one line per characterisation step and, under a step cut short or not measurable, a line that says so; then the column notes and the threshold, arrival and late rules.

Parameters
tRun state.
cCursor.
Returns
true when the line asked for is one of these.

◆ step_row()

void step_row ( const cursor_t * c,
const servo_test_step_t * s )
static

One step's line of the steps table, 92 cells at most: the columns end where the two heading lines end their words.

Voltages take 5 cells, currents 6 (whole mA, "-99999" the widest, see ma_text()), the travel times 6 and 7 and the counts 5, 4 and 6, one space between columns. A count is at most SERVO_TEST_MOVES_MAX.

Parameters
cCursor; buf receives the line.
sA step that began.

◆ step_unseen()

bool step_unseen ( const servo_test_step_t * s)
static

Whether none of a step's counted moves showed movement: the step is not measurable.

Parameters
sStep.
Returns
true when the step counted moves and every one went unseen.

◆ unmeasured_lines()

bool unmeasured_lines ( const servo_test_t * t,
cursor_t * c )
static

The unmeasured notes: the heading and the lines that say what the run did not measure.

Parameters
tRun state.
cCursor.
Returns
true when the line asked for is one of these.

◆ verdict_word()

const char * verdict_word ( const cursor_t * c,
bool checked,
bool measured,
bool over )
static

The word for one check: NOT CHECKED, NOT MEASURED, FAIL or PASS.

Parameters
cCursor; its text gives the language.
checkedtrue when the check has a limit.
measuredtrue when a value was measured.
overtrue when the value is over the limit.
Returns
the word, from the run's language table.