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

The card's side of the servo programmer's files. More...

#include "kst_card.h"
#include <string.h>
#include "kst_file.h"
#include "kst_limits.h"

Functions

static uint8_t type_no (kst_type_t type)
 The servo type as the number the screen prints.
unsigned kst_card_type (const kst_image_t *img)
 The servo type of an image as a number the screen prints behind a "V": 6 or 8.
static uint8_t store_result (kst_store_t r, bool save)
 A result of the store as kst_prog.h names it.
static void base_of (const char *file, char *out)
 The base name of a file name the store lists.
static void save (const kst_store_io_t *io, const kst_prog_card_req_t *req, kst_prog_card_done_t *done)
 Carries out a save request.
static uint8_t type_of (const kst_store_io_t *io, const char *name)
 The servo type the file name states; 0 for none and for a file that does not read as a servo file.
static void list (const kst_store_io_t *io, const kst_prog_card_req_t *req, kst_prog_card_done_t *done)
 Carries out a list request.
static unsigned lowest (kst_rules_t set)
 The lowest rule in a set of rules.
static void load (const kst_store_io_t *io, const kst_prog_card_req_t *req, kst_prog_card_done_t *done)
 Carries out a load request.
void kst_card_run (const kst_store_io_t *io, const kst_prog_card_req_t *req, kst_prog_card_done_t *done)
 Carry out req on the card behind io and write the answer to done.

Variables

static char s_text [KST_FILE_MAX]
static kst_file_t s_file
static kst_file_load_t s_load
static kst_store_entry_t s_list [KST_CARD_LIST_MAX]

Detailed Description

The card's side of the servo programmer's files.

See kst_card.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ base_of()

void base_of ( const char * file,
char * out )
static

The base name of a file name the store lists.

Parameters
fileThe file name the store lists.
outReceives the base name, at most KST_PROG_NAME_MAX - 1 characters.

◆ kst_card_run()

void kst_card_run ( const kst_store_io_t * io,
const kst_prog_card_req_t * req,
kst_prog_card_done_t * done )

Carry out req on the card behind io and write the answer to done.

Every request gets an answer.

KST_PROG_CARD_SAVE writes the text of req->image to a new file: named by kst_store_preset() for a preset save, else req->name. No file is replaced.

KST_PROG_CARD_LIST gives the base names of up to KST_PROG_FILES_MAX files from req->first on in the order of kst_store_list(), the latest proposed name first among the proposed ones, each with the servo type its text states, and the next preset name. done->total is the number of servo files in the directory, 65535 for that many or more.

KST_PROG_CARD_LOAD reads the file of req->name and holds it against req->image with kst_file_load(): done->image is the servo's image with the editable fields of the file.

Parameters
ioThe store the request is carried out on.
reqThe request.
doneReceives the answer.

◆ kst_card_type()

unsigned kst_card_type ( const kst_image_t * img)

The servo type of an image as a number the screen prints behind a "V": 6 or 8.

0 for NULL.

Parameters
imgThe image to read.
Returns
6 or 8; 0 for NULL.

◆ list()

void list ( const kst_store_io_t * io,
const kst_prog_card_req_t * req,
kst_prog_card_done_t * done )
static

Carries out a list request.

Parameters
ioThe card store.
reqThe request.
doneReceives the answer.

◆ load()

void load ( const kst_store_io_t * io,
const kst_prog_card_req_t * req,
kst_prog_card_done_t * done )
static

Carries out a load request.

Parameters
ioThe card store.
reqThe request.
doneReceives the answer.

◆ lowest()

unsigned lowest ( kst_rules_t set)
static

The lowest rule in a set of rules.

Parameters
setThe set of rules, one bit each.
Returns
The index of the lowest rule set, or KST_RULE_COUNT for none.

◆ save()

void save ( const kst_store_io_t * io,
const kst_prog_card_req_t * req,
kst_prog_card_done_t * done )
static

Carries out a save request.

Parameters
ioThe card store.
reqThe request.
doneReceives the answer.

◆ store_result()

uint8_t store_result ( kst_store_t r,
bool save )
static

A result of the store as kst_prog.h names it.

Parameters
rThe store result.
savetrue for a save, false for a list or a load.
Returns
The card result, as kst_prog_card_result_t.

◆ type_no()

uint8_t type_no ( kst_type_t type)
static

The servo type as the number the screen prints.

Parameters
typeThe servo type.
Returns
6 or 8; 0 for any other type.

◆ type_of()

uint8_t type_of ( const kst_store_io_t * io,
const char * name )
static

The servo type the file name states; 0 for none and for a file that does not read as a servo file.

Parameters
ioThe card store.
nameThe file name.
Returns
The type number, or 0 for none or for a file that is not a servo file.