|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The profiles the bench offers: built in, with the card's in front. More...
Data Structures | |
| struct | slot_t |
| One card profile held by the registry. More... | |
Functions | |
| static const esc_profile_t * | builtin_find (const char *id) |
| Find a built-in profile by id. | |
| static slot_t * | over_find (const char *id) |
| Find a card profile by id. | |
| bool | esc_brand_same (const char *a, const char *b) |
Whether a and b name one maker: the letters A to Z folded, every other byte itself, as the list groups them. | |
| static size_t | maker_models_with (const esc_profile_t *p) |
The models p's maker would list with p in place of the profile of its id. | |
| static bool | refuse (void *block, const char **why, const char *text) |
| Refuse a card profile: free its block and set the reason. | |
| bool | esc_profiles_override (const esc_profile_t *p, void *block) |
| Add a parsed profile from the card. | |
| bool | esc_profiles_override_why (const esc_profile_t *p, void *block, const char **why) |
esc_profiles_override(), with why it refused in why (a static string; may be NULL): "no profile", "more than 32 on the card", or "its maker would list more than 512 models" – the maker's models across every profile, built in and from the card, with this one in place of any it replaces, makers compared with the letters A to Z folded. | |
| void | esc_profiles_clear_overrides (void) |
| Drop every card profile; the built-in ones remain. | |
| size_t | esc_profiles_override_count (void) |
| Card profiles held, for a status line. | |
| size_t | esc_profiles_count (void) |
| Every profile the bench offers: the built-in ones with card files in their place, then card profiles with new ids. | |
| const esc_profile_t * | esc_profiles_at (size_t i) |
The profile at index i of the list the bench offers. | |
| const esc_profile_t * | esc_profiles_find (const char *id) |
| NULL when no profile has this id. | |
| bool | esc_profiles_is_override (const esc_profile_t *p) |
Whether the profile at p came from the card. | |
| bool | esc_profile_file_is (const char *file_name, const char *id) |
Whether file_name is the name the profile id belongs in: the id with ".json" after it, letters compared without regard to case, since a card written on another computer may change them. | |
| static unsigned char | fold (unsigned char c) |
| Fold an ASCII capital letter to lower case. | |
| static unsigned char | joined_at (const char *a, size_t na, const char *b, size_t i) |
Byte i of a, a space and b read as one text of n bytes; b NULL is a alone. | |
| static bool | match_joined (const char *a, const char *b, const char *pattern) |
| The wildcard match, with a "*" implied at either end. | |
| bool | esc_text_matches (const char *text, const char *pattern) |
Whether pattern is found in text. | |
| bool | esc_profile_matches (const esc_profile_t *p, const char *pattern) |
Whether pattern (as esc_text_matches()) is found in the profile's manufacturer and name read as one text, "brand family", or in its manufacturer and one of its models' names, "brand model": a family such as "JAZZ / MINIJAZZ" names its sizes only in its models ("JAZZ 55
LV"). | |
| bool | esc_item_applies (const esc_profile_t *p, unsigned item, int model) |
Whether item item of p is on model model: an item without applies_to is on every model; one with it only on the models it names. | |
| bool | esc_model_matches (const esc_profile_t *p, unsigned model, const char *pattern) |
Whether pattern finds model model of p: in the maker and the family read as one text, which every model of the family shares, or in the maker and the model's own name, as esc_profile_matches() reads them. | |
| unsigned | esc_profile_manual_count (const esc_profile_t *p, esc_manual_when_t when) |
How many of the profile's manual steps are due at when. | |
Variables | |
| static slot_t | s_over [ESC_PROFILE_MAX_OVERRIDES] |
| Card profiles, in the order the card was read. | |
| static size_t | s_over_n |
| Number of card profiles held in s_over. | |
The profiles the bench offers: built in, with the card's in front.
See esc_profile.h.
A card profile with a built-in id takes that profile's place in the list, so an operator who corrects a default on the card sees one entry, not two. A card profile with a new id follows the built-in ones in the order the card was read.
Not thread-safe: the panel fills it once at start-up, before anything reads it.
SPDX-License-Identifier: MIT
|
static |
Find a built-in profile by id.
| id | The profile id. |
| bool esc_brand_same | ( | const char * | a, |
| const char * | b ) |
Whether a and b name one maker: the letters A to Z folded, every other byte itself, as the list groups them.
| a | A maker name, or NULL. |
| b | A maker name, or NULL. |
| bool esc_item_applies | ( | const esc_profile_t * | p, |
| unsigned | item, | ||
| int | model ) |
Whether item item of p is on model model: an item without applies_to is on every model; one with it only on the models it names.
For -1 – the family, no model picked – only an item on every model, as the one item the ESC is sure to have.
| p | The profile. |
| item | Index into the profile's items. |
| model | Index into the profile's models, or -1 for none picked. |
| bool esc_model_matches | ( | const esc_profile_t * | p, |
| unsigned | model, | ||
| const char * | pattern ) |
Whether pattern finds model model of p: in the maker and the family read as one text, which every model of the family shares, or in the maker and the model's own name, as esc_profile_matches() reads them.
| p | The profile. |
| model | Index into the profile's models. |
| pattern | The pattern, with "*" as a wildcard. |
| bool esc_profile_file_is | ( | const char * | file_name, |
| const char * | id ) |
Whether file_name is the name the profile id belongs in: the id with ".json" after it, letters compared without regard to case, since a card written on another computer may change them.
A card file whose name and id differ is refused, as tools/gen_esc_profiles.py refuses one in the repository: a renamed copy would otherwise replace a profile its name does not mention.
| file_name | The file name as found on the card. |
| id | The profile id to compare against. |
| unsigned esc_profile_manual_count | ( | const esc_profile_t * | p, |
| esc_manual_when_t | when ) |
How many of the profile's manual steps are due at when.
| p | The profile. |
| when | The point in a run to count for. |
when. | bool esc_profile_matches | ( | const esc_profile_t * | p, |
| const char * | pattern ) |
Whether pattern (as esc_text_matches()) is found in the profile's manufacturer and name read as one text, "brand family", or in its manufacturer and one of its models' names, "brand model": a family such as "JAZZ / MINIJAZZ" names its sizes only in its models ("JAZZ 55
LV").
| p | The profile to search. |
| pattern | The pattern, with "*" as a wildcard. |
| const esc_profile_t * esc_profiles_at | ( | size_t | i | ) |
The profile at index i of the list the bench offers.
| i | Index into the list, from 0. |
i, or NULL when i is past the last profile. | size_t esc_profiles_count | ( | void | ) |
Every profile the bench offers: the built-in ones with card files in their place, then card profiles with new ids.
| const esc_profile_t * esc_profiles_find | ( | const char * | id | ) |
NULL when no profile has this id.
| id | The profile id. |
id is NULL or no profile has it. | bool esc_profiles_is_override | ( | const esc_profile_t * | p | ) |
Whether the profile at p came from the card.
| p | The profile. |
p is one of the card profiles. | bool esc_profiles_override | ( | const esc_profile_t * | p, |
| void * | block ) |
Add a parsed profile from the card.
Ownership of block passes to the registry. A second file with the same id replaces the first.
| p | The parsed profile. |
| block | The malloc() block that holds p. |
block is freed then too | size_t esc_profiles_override_count | ( | void | ) |
Card profiles held, for a status line.
| bool esc_profiles_override_why | ( | const esc_profile_t * | p, |
| void * | block, | ||
| const char ** | why ) |
esc_profiles_override(), with why it refused in why (a static string; may be NULL): "no profile", "more than 32 on the card", or "its maker would list more than 512 models" – the maker's models across every profile, built in and from the card, with this one in place of any it replaces, makers compared with the letters A to Z folded.
| p | The parsed profile. |
| block | The malloc() block that holds p; freed when the profile is refused. |
| why | Receives a static reason string when refused, or NULL. |
p is registered, false when it is refused. | bool esc_text_matches | ( | const char * | text, |
| const char * | pattern ) |
Whether pattern is found in text.
Letters A to Z match without regard to case; every other byte matches itself, so "Ü" does not match "ü". "*" stands for any run of characters, none included, and the pattern is found anywhere in the text: "sky*v2" is in "Skywalker V2". An empty pattern, or one of "*" only, is found in every text. A NULL pattern counts as empty and a NULL text as "".
| text | The text to search. |
| pattern | The pattern, with "*" as a wildcard. |
|
static |
Fold an ASCII capital letter to lower case.
| c | The byte. |
|
static |
Byte i of a, a space and b read as one text of n bytes; b NULL is a alone.
No copy is made, since a card profile's strings have no length limit short of the file's.
| a | The first text. |
| na | Length of a, bytes. |
| b | The second text, or NULL. |
| i | Position in the joined text. |
i.
|
static |
The models p's maker would list with p in place of the profile of its id.
| p | The profile, as it would be registered. |
|
static |
The wildcard match, with a "*" implied at either end.
On a mismatch the last "*" takes one byte more and the rest of the pattern is tried again from there: at most text times pattern comparisons, no recursion. A multi-byte character cannot match from its middle, because a UTF-8 lead byte never equals a continuation byte.
| a | The first text. |
| b | The second text, joined to a with a space; NULL for none. |
| pattern | The pattern, with "*" as a wildcard; NULL counts as "". |
|
static |
Find a card profile by id.
| id | The profile id. |
|
static |
Refuse a card profile: free its block and set the reason.
| block | The malloc() block that holds the profile, freed here. |
| why | Receives text when not NULL. |
| text | The static reason string. |