|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The fault log, BENCH/RCBENCH.LOG: one line every 5s while the link to the IOmcu is down, written whatever SETUP > SD CARD says. More...
Go to the source code of this file.
Data Structures | |
| struct | fault_log_io_t |
| The card. More... | |
Enumerations | |
| enum | fault_log_t { FAULT_LOG_OK = 0 , FAULT_LOG_ARG , FAULT_LOG_NO_CARD , FAULT_LOG_NO_FOLDER , FAULT_LOG_NO_ROOM , FAULT_LOG_UNREAD , FAULT_LOG_WRITE } |
| What a line came to. More... | |
Functions | |
| fault_log_t | fault_log_note (const fault_log_io_t *io, const char *line, bool *rotated) |
Append line to the fault log, renamed to RCBENCH.OLD first when the line and its line feed would take it past FAULT_LOG_CAP. rotated, when not NULL, says whether that rename happened. | |
The fault log, BENCH/RCBENCH.LOG: one line every 5s while the link to the IOmcu is down, written whatever SETUP > SD CARD says.
The file is held to FAULT_LOG_CAP, 1MiB (1,048,576 bytes). A line that would take it past the cap first renames it to BENCH/RCBENCH.OLD, replacing the old one, and starts a new BENCH/RCBENCH.LOG with that line. The card holds at most 2MiB of fault log; at 208 bytes a line every 5s, one file is about 7 hours of link loss.
A file that ends at the cap exactly is kept: the cap is the most bytes the file holds. A line that does not fit an empty file is refused. When the rename fails the line is not written, so the file never passes the cap, and a file whose size does not read takes no line either.
The old RCBENCH.OLD gives way only once the full file has its name. It is first renamed to BENCH/RCBENCH.TMP; a rename of the full file that fails gives it its name back. A TMP that stands at a line, left by a power cut or by a removal the card refused, is RCBENCH.OLD again when no OLD stands and is removed when one does; until it is gone no line is written.
Each line is appended on its own, opened and closed around it, so a line is on the card before the next fault can happen. BENCH is made the first time (card_make_dirs()).
The card is reached through fault_log_io_t, functions the caller supplies, so the rules run on a host without a card. Pure C, no ESP-IDF (Espressif Internet-of-Things Development Framework).
SPDX-License-Identifier: MIT
| enum fault_log_t |
What a line came to.
| fault_log_t fault_log_note | ( | const fault_log_io_t * | io, |
| const char * | line, | ||
| bool * | rotated ) |
Append line to the fault log, renamed to RCBENCH.OLD first when the line and its line feed would take it past FAULT_LOG_CAP. rotated, when not NULL, says whether that rename happened.
| io | The card functions. |
| line | The line to append, without its line feed. |
| rotated | Receives true when the file was renamed, or NULL. |