|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The folders of the panel's SD (Secure Digital) card, and the files in them with a fixed name. More...
#include <stddef.h>Go to the source code of this file.
Macros | |
| #define | CARD_ROOT "" |
| The card's root. | |
| #define | CARD_BENCH "BENCH" |
| The bench's own folder. | |
| #define | CARD_AUTO_LOGS "BENCH/LOGS" |
| The automatic logs: a log of each ARMED run and each supply run; the default of AUTO LOG FOLDER. | |
| #define | CARD_USER "USER" |
| The user's folder. | |
| #define | CARD_USER_LOGS "USER/LOGS" |
| The files of the tests a user starts: AUTOMATIC TEST and LIMIT RUN; the default of USER LOG FOLDER. | |
| #define | CARD_ESC_CONF "BENCH/ESC/CONF" |
| ESC profile overrides, <id>.json. | |
| #define | CARD_KST_CONF "BENCH/KST/CONF" |
| KST and Chaservo servo files, their backups and the write record. | |
| #define | CARD_HITEC_CONF "BENCH/HITEC/CONF" |
| The Hitec programmer's files. | |
| #define | CARD_FAULT_LOG "BENCH/RCBENCH.LOG" |
| The fault log: a line every 5s while the link to the IOmcu is down. | |
| #define | CARD_FAULT_OLD "BENCH/RCBENCH.OLD" |
| The fault log as it was when it reached FAULT_LOG_CAP (fault_log.h). | |
| #define | CARD_FAULT_TMP "BENCH/RCBENCH.TMP" |
| RCBENCH.OLD moved aside while the full fault log takes its name. | |
| #define | CARD_DIR_MAX 24 |
| Room for a folder path and its terminator: two folders of 8 characters and the "/" between them are 17, and the room is the settings store's string, SETTINGS_TEXT_MAX (24). | |
| #define | CARD_FOLDER_NAME_MAX 8 |
| The longest folder name a log folder takes, and how deep it goes. | |
| #define | CARD_FOLDER_DEPTH_MAX 2 |
| The most folders a log folder path holds. | |
Typedefs | |
| typedef card_dir_t(*) | card_make_fn(void *ctx, const char *level) |
Make the one folder level, a path from the root, whose parent is there. | |
Enumerations | |
| enum | card_dir_t { CARD_DIR_OK = 0 , CARD_DIR_ARG , CARD_DIR_FILE , CARD_DIR_DENIED , CARD_DIR_FAILED } |
| What making a folder came to. More... | |
| enum | card_folder_t { CARD_FOLDER_OK = 0 , CARD_FOLDER_ARG , CARD_FOLDER_EMPTY , CARD_FOLDER_LONG , CARD_FOLDER_DEEP , CARD_FOLDER_CHAR , CARD_FOLDER_RESERVED , CARD_FOLDER_BENCH } |
| What card_folder_check() says of a log folder. More... | |
Functions | |
| card_dir_t | card_make_dirs (const char *dir, card_make_fn make, void *ctx) |
Make folder dir one level at a time, the shortest first: for "BENCH/KST/CONF", "BENCH", then "BENCH/KST", then "BENCH/KST/CONF". | |
| card_folder_t | card_folder_check (const char *in, char *out, size_t n) |
Whether in names a folder the logs can be written to: 1 or 2 folders separated by "/", each 1 to 8 characters of A-Z, 0-9, "_" and "-", lower case taken as upper case. | |
| const char * | card_folder_use (const char *text, const char *fallback, char *out, size_t n) |
The folder a log is written to: text in upper case when card_folder_check() takes it, fallback otherwise. | |
The folders of the panel's SD (Secure Digital) card, and the files in them with a fixed name.
Every path the panel spells on the card is here.
/BENCH/ what the bench writes or reads for itself LOGS/ automatic logs: SERVOnnn, MOTORnnn, SUPPLnnn (AUTO LOG FOLDER, the default) ESC/CONF/ ESC (electronic speed controller) profiles KST/CONF/ KST and Chaservo servo files HITEC/CONF/ Hitec servo files RCBENCH.LOG the fault log, at most 1MiB RCBENCH.OLD the fault log before the last 1MiB /USER/ LOGS/ user-started tests: ATESTnnn, LIMITnnn (USER LOG FOLDER, the default) / run logs of firmware 0.21.0 and older
Every folder name is upper case, 1 to 8 characters of A-Z, 0-9, "_" and "-", without an extension: a FAT (File Allocation Table) 8.3 short name, the same on every computer. A path is relative to the card's root, its folders separated by "/", with no "/" at either end; "" is the root.
The two log folders are settings (SETUP > SD CARD): any folder card_folder_check() takes, the defaults CARD_AUTO_LOGS and CARD_USER_LOGS. The other places are fixed.
The panel reads and writes these places only. Folders of firmware 0.21 and older, /ESC and /KST, and its /RCBENCH.LOG are neither read nor moved: their files are moved on a computer. CARD_HITEC_CONF is reserved for the Hitec programmer's files; nothing reads it yet.
A folder is made the first time something is written there, one level at a time (card_make_dirs()).
Pure C, no ESP-IDF (Espressif Internet-of-Things Development Framework).
SPDX-License-Identifier: MIT
| typedef card_dir_t(*) card_make_fn(void *ctx, const char *level) |
Make the one folder level, a path from the root, whose parent is there.
A folder that is there already is CARD_DIR_OK.
| ctx | Context the caller passed to card_make_dirs(). |
| level | The folder path to make, from the card's root. |
| enum card_dir_t |
What making a folder came to.
| enum card_folder_t |
What card_folder_check() says of a log folder.
| card_folder_t card_folder_check | ( | const char * | in, |
| char * | out, | ||
| size_t | n ) |
Whether in names a folder the logs can be written to: 1 or 2 folders separated by "/", each 1 to 8 characters of A-Z, 0-9, "_" and "-", lower case taken as upper case.
A device name is refused in either place, and so is a folder the bench keeps its own files in. Both log folders may be one folder. The first fault from the left is the answer.
On CARD_FOLDER_OK, out (when not NULL) takes the path in upper case; at most 17 characters and the terminator. Otherwise out is left as it was.
| in | The folder path to check. |
| out | Receives the path in upper case when accepted, or NULL. |
| n | Size of out, bytes. |
| const char * card_folder_use | ( | const char * | text, |
| const char * | fallback, | ||
| char * | out, | ||
| size_t | n ) |
The folder a log is written to: text in upper case when card_folder_check() takes it, fallback otherwise.
Written into out, CARD_DIR_MAX bytes or more, and returned. A stored folder that no longer passes the check is never written to.
| text | The stored folder path. |
| fallback | The folder to use when text does not pass. |
| out | Receives the chosen folder path. |
| n | Size of out, bytes. |
out, holding the chosen folder path. | card_dir_t card_make_dirs | ( | const char * | dir, |
| card_make_fn | make, | ||
| void * | ctx ) |
Make folder dir one level at a time, the shortest first: for "BENCH/KST/CONF", "BENCH", then "BENCH/KST", then "BENCH/KST/CONF".
The first level that is not a folder afterwards ends it, and its answer is the result. CARD_ROOT makes nothing and is CARD_DIR_OK.
| dir | The folder path, from the card's root. |
| make | Makes one level. |
| ctx | Context passed to make. |