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

The programmer for KST and Chaservo servos as the SERVO screen runs it: what is read from a servo, what the operator has changed, and what may be written. More...

#include <stdatomic.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "kst_limits.h"
#include "kst_link.h"
#include "kst_plan.h"
#include "kst_reg.h"

Go to the source code of this file.

Data Structures

struct  kst_prog_msg_t
 The last message the programmer says, with its id, level and argument. More...
struct  kst_prog_restore_t
 A restore as kst_prog_restore_plan() prepared it. More...
struct  kst_prog_card_req_t
 A request to the card side. More...
struct  kst_prog_card_done_t
 The card side's answer to a request. More...
struct  kst_prog_cmd_t
 One call for the task that owns the link module. More...
struct  kst_prog_gate_t
 The pass a START needs to be carried out. More...
struct  kst_prog_feed_t
 What the task that owns the link module publishes, every frame. More...
struct  kst_prog_t
 The state of the servo programmer. More...

Macros

#define KST_PROG_SUPPLY_MV   5000u
 The supply an ENTER asks for until it is set otherwise.
#define KST_PROG_SUPPLY_MA   1000u
#define KST_PROG_WAIT_MS   100u
 The wait between the end of a session and the first PWM pulse: its default and the highest value taken.
#define KST_PROG_WAIT_MAX_MS   10000u
#define KST_PROG_FILE_MAX   400u
 The file text's size, with its terminator.
#define KST_PROG_PIN_LAST   47u
 The highest GPIO of the IOmcu (GP0 to GP47), and the pin that is not known.
#define KST_PROG_NO_PIN   0xFFu
#define KST_PROG_START_MS   2000u
 A command without an answer from the control task for this long is given up.
#define KST_PROG_RUN_MS   30000u
 An operation without an outcome for this long is aborted.
#define KST_PROG_RUN_MAX_MS   120000u
 And one the port reports busy for this long from its start is aborted too.
#define KST_PROG_STORE_MS   3000u
 The file not written for this long: the write to the servo is not sent.
#define KST_PROG_FETCH_MS   1000u
 The time between two fetches of images the port holds.
#define KST_PROG_FILE_RETRY_MS   5000u
 A file the card did not take is written again after this long.
#define KST_PROG_CARD_MS   5000u
 A save, a list or a load without an end for this long has failed.
#define KST_PROG_FILES_MAX   5u
 The files a list holds.
#define KST_PROG_NAME_MAX   33u
 A file's name with its terminator.

Typedefs

typedef unsigned kst_prog_msg_id_t
 What the screen says.

Enumerations

enum  kst_prog_state_t {
  KST_PROG_DOWN = 0 , KST_PROG_NO_PAGE , KST_PROG_SYNC , KST_PROG_PWM ,
  KST_PROG_ENTERING , KST_PROG_PROGRAMMING , KST_PROG_WORKING , KST_PROG_LEAVING
}
 Where the programmer is. More...
enum  {
  KST_PROG_MSG_NONE = 0 , KST_PROG_MSG_READ , KST_PROG_MSG_READ_ONLY , KST_PROG_MSG_WRITTEN ,
  KST_PROG_MSG_VERIFIED , KST_PROG_MSG_VERIFY_DIFF , KST_PROG_MSG_RESTORED , KST_PROG_MSG_RELEASED ,
  KST_PROG_MSG_LEFT , KST_PROG_MSG_SAVED , KST_PROG_MSG_CARD_NONE , KST_PROG_MSG_STORE_FAILED ,
  KST_PROG_MSG_FILE_BAD , KST_PROG_MSG_JOURNAL , KST_PROG_MSG_JOURNAL_SAME , KST_PROG_MSG_JOURNAL_DONE ,
  KST_PROG_MSG_JOURNAL_DIFF , KST_PROG_MSG_FORGOTTEN , KST_PROG_MSG_EDIT_HARD , KST_PROG_MSG_EDIT_LOCKED ,
  KST_PROG_MSG_NO_CHANGES , KST_PROG_MSG_NEED_ENABLE , KST_PROG_MSG_NEED_READ , KST_PROG_MSG_NEED_PORT ,
  KST_PROG_MSG_NO_RESTORE , KST_PROG_MSG_RESTORE_REFUSED , KST_PROG_MSG_STOPPED , KST_PROG_MSG_TIMEOUT ,
  KST_PROG_MSG_JOURNAL_OTHER , KST_PROG_MSG_CARD_FULL , KST_PROG_MSG_CARD_WRITE , KST_PROG_MSG_CARD_READ ,
  KST_PROG_MSG_NO_FILES , KST_PROG_MSG_NAME_BAD , KST_PROG_MSG_NAME_EXISTS , KST_PROG_MSG_LOAD_BAD ,
  KST_PROG_MSG_LOAD_CHECKSUM , KST_PROG_MSG_LOAD_NEWER , KST_PROG_MSG_LOAD_TYPE , KST_PROG_MSG_LOAD_VALUE ,
  KST_PROG_MSG_LOAD_REFUSED , KST_PROG_MSG_LOAD_SAME , KST_PROG_MSG_LOAD_SOFT , KST_PROG_MSG_LOADED ,
  KST_PROG_MSG_LOADED_EDITED , KST_PROG_MSG_LOADED_UNTYPED , KST_PROG_MSG_NEED_TARGET , KST_PROG_MSG_LEAVE_SUPPLY ,
  KST_PROG_MSG_LEFT_NO_WAIT , KST_PROG_MSG_LEFT_DOUBT , KST_PROG_MSG_LEAVE_CUT , KST_PROG_MSG_NEED_DISARM ,
  KST_PROG_MSG_BACKUP_OTHER , KST_PROG_MSG_SESSION_ENDED , KST_PROG_MSG_UNKNOWN , KST_PROG_MSG_SUPPLY_CAPS ,
  KST_PROG_MSG_CARD_DENIED , KST_PROG_MSG_START = 0x40 , KST_PROG_MSG_OUT = 0x50 , KST_PROG_MSG_REF = 0x60 ,
  KST_PROG_MSG_SES = 0x80 , KST_PROG_MSG_END = 0xB0
}
 The message ids of the programmer's screen. More...
enum  kst_prog_level_t { KST_PROG_INFO = 0 , KST_PROG_WARN , KST_PROG_DANGER }
 The level of a message: information, warning or danger.
enum  kst_prog_edit_t { KST_PROG_EDIT_OK = 0 , KST_PROG_EDIT_SOFT , KST_PROG_EDIT_REFUSED }
 What an edit came to. More...
enum  kst_prog_from_t {
  KST_PROG_FROM_NONE = 0 , KST_PROG_FROM_SESSION , KST_PROG_FROM_JOURNAL , KST_PROG_FROM_RUN ,
  KST_PROG_FROM_COUNT
}
 Where a restore takes its image from. More...
enum  kst_prog_card_op_t { KST_PROG_CARD_IDLE = 0 , KST_PROG_CARD_SAVE , KST_PROG_CARD_LIST , KST_PROG_CARD_LOAD }
 What the card's side is asked for. More...
enum  kst_prog_card_result_t {
  KST_PROG_CARD_OK = 0 , KST_PROG_CARD_NO_CARD , KST_PROG_CARD_FULL , KST_PROG_CARD_WRITE_ERR ,
  KST_PROG_CARD_READ_ERR , KST_PROG_CARD_NAME , KST_PROG_CARD_EXISTS , KST_PROG_CARD_BAD ,
  KST_PROG_CARD_CHECKSUM , KST_PROG_CARD_NEWER , KST_PROG_CARD_TYPE , KST_PROG_CARD_VALUE ,
  KST_PROG_CARD_LIMIT , KST_PROG_CARD_DENIED , KST_PROG_CARD_RESULTS
}
 How it went. More...
enum  kst_prog_file_kind_t { KST_PROG_FILE_VERIFIED = 0 , KST_PROG_FILE_EDITED , KST_PROG_FILE_UNTYPED , KST_PROG_FILE_KINDS }
 What a file that loads is. More...
enum  kst_prog_cmd_kind_t { KST_PROG_CMD_START = 0 , KST_PROG_CMD_ABORT , KST_PROG_CMD_FETCH }
 The kinds of command the programmer hands to the link module. More...
enum  kst_prog_res_t { KST_PROG_RES_OK = 0 , KST_PROG_RES_CLEAN , KST_PROG_RES_DOUBT }
 What a result of the session says of a write that ended with it. More...

Functions

void kst_prog_gate_init (kst_prog_gate_t *g)
 Sets up a START gate.
void kst_prog_gate_offer (kst_prog_gate_t *g, uint32_t id)
 The pass of START id is there to be taken.
bool kst_prog_gate_claim (kst_prog_gate_t *g, uint32_t id)
 The link's task, with a START out of its queue: true when the command is to be carried out.
bool kst_prog_gate_revoke (kst_prog_gate_t *g, uint32_t id)
 The model: true when START id is not carried out and never is.
kst_prog_res_t kst_prog_result_class (unsigned result)
 The class of result, a kst_ses_t or a LINK_KST_RESULT_ value.
void kst_prog_init (kst_prog_t *p)
 Sets up the programmer state.
void kst_prog_gate_set (kst_prog_t *p, kst_prog_gate_t *g)
 The gate the link's task claims each START at.
void kst_prog_feed (kst_prog_t *p, const kst_prog_feed_t *f)
 The published state of this frame.
bool kst_prog_take (kst_prog_t *p, kst_prog_cmd_t *out)
 The next command for the task that owns the link module; false for none.
void kst_prog_screen_entry (kst_prog_t *p)
 The screen was entered: ENABLE WRITE TO SERVO goes off.
kst_prog_state_t kst_prog_state (const kst_prog_t *p)
 The programmer state.
link_kst_op_t kst_prog_op (const kst_prog_t *p)
 The operation on its way or running; LINK_KST_OP_NONE for none.
bool kst_prog_writing (const kst_prog_t *p)
 A write, a restore or a release is on its way or runs under this model: the record of it is no interrupted write yet.
unsigned kst_prog_write_steps (const kst_prog_t *p)
 The registers that write writes, as this model planned it; 0 when no write runs or the IOmcu alone plans it (a restore with no checked order, a release).
bool kst_prog_planning (const kst_prog_t *p)
 The IOmcu plans the order of a write's or a restore's writes: no frame goes to the servo yet.
const kst_prog_msg_t * kst_prog_message (const kst_prog_t *p)
 The last message.
bool kst_prog_have_servo (const kst_prog_t *p)
 Whether a servo was read.
bool kst_prog_editable (const kst_prog_t *p)
 A servo was read, its image passes the fingerprint and is not in doubt: it may be edited and written.
const kst_image_t * kst_prog_servo (const kst_prog_t *p)
 The servo's image as last read.
const kst_image_t * kst_prog_draft (const kst_prog_t *p)
 The draft image being edited.
bool kst_prog_write_enabled (const kst_prog_t *p)
 Whether the write switch is on.
uint8_t kst_prog_port (const kst_prog_t *p)
 The programming port.
bool kst_prog_journal (const kst_prog_t *p)
 A write was interrupted and the servo was not compared since.
bool kst_prog_journal_held (const kst_prog_t *p)
 A record of an interrupted write is held, read back or not: the one RESTORE offers the values of.
bool kst_prog_journal_other (const kst_prog_t *p)
 The servo read cannot be the one of the interrupted write: it is on another port, or a register of it holds neither the record's value nor the write's target.
kst_prog_msg_id_t kst_prog_journal_asks (const kst_prog_t *p)
 The servo read holds, register for register, the record's image (KST_PROG_MSG_JOURNAL_SAME) or the write's target (KST_PROG_MSG_JOURNAL_DONE), and the record stands: a second servo with the same settings is not told apart from the one of the write.
bool kst_prog_backup_other (const kst_prog_t *p)
 The servo read is not the one the session's backup was read from: the two differ in a field no write of the session set out to change.
uint8_t kst_prog_journal_port (const kst_prog_t *p)
 The port of the interrupted write, from 0.
uint8_t kst_prog_journal_pin (const kst_prog_t *p)
 The GPIO that port drove at the write, or KST_PROG_NO_PIN: not known, or a record of version 1.
unsigned kst_prog_journal_arg (const kst_prog_t *p)
 The argument of the journal's messages: the port + 1 in bits 0-7, the pin + 1 in bits 8-15, 0 there when the pin is not known.
bool kst_prog_in_doubt (const kst_prog_t *p)
 The servo may hold part of a write: a journal stands, the port asks for a read, an operation timed out, or the session is locked.
bool kst_prog_first_write (const kst_prog_t *p)
 No write was sent since the servo was connected: the next asks for the free horn.
bool kst_prog_backed_up (const kst_prog_t *p)
 A file holds the servo as this session found it: the next write waits for no save.
const char * kst_prog_backup_name (const kst_prog_t *p)
 That file's name; "" while there is none.
bool kst_prog_no_file (const kst_prog_t *p)
 A write of this session started with no card in the slot, and no file holds the servo as the session found it: the session's backup is the one copy.
bool kst_prog_save_first (const kst_prog_t *p)
 The next write saves the servo as the session found it to a file first.
bool kst_prog_save_none (const kst_prog_t *p)
 That write goes without the file: no card is mounted, or the servo may hold other values than the session found and the session's backup, the image the file takes then, is not fetched.
kst_field_set_t kst_prog_changed (const kst_prog_t *p)
 The fields in which the draft differs from the servo, register 01's copy of Max.
unsigned kst_prog_changes (const kst_prog_t *p)
 The number of fields the draft differs in.
kst_rules_t kst_prog_rules (const kst_prog_t *p)
 The rules the draft breaks as an edit of the servo's image.
bool kst_prog_range (const kst_prog_t *p, kst_field_id_t id, uint16_t *lo, uint16_t *hi)
 The raw values of id the hard rules accept in the draft as it is, as the lowest and the highest.
kst_prog_edit_t kst_prog_edit (kst_prog_t *p, kst_field_id_t id, uint16_t raw)
 Set a field of the draft to raw.
kst_prog_edit_t kst_prog_step (kst_prog_t *p, kst_field_id_t id, int dir)
 One raw count up (dir above 0) or down.
kst_rules_t kst_prog_soft_rules (const kst_prog_t *p)
 The soft rules the edit that waits asks a confirmation for; 0 while none waits.
const kst_image_t * kst_prog_soft_base (const kst_prog_t *p)
 The image the soft rules compare with: the backup of the IOmcu's session, the servo as the session first read it.
kst_field_set_t kst_prog_soft_fields (const kst_prog_t *p, const kst_image_t *img)
 The fields of img that differ from the servo and are at fault for a soft rule: the rule goes when the field takes the value of kst_prog_soft_base().
const kst_image_t * kst_prog_soft_image (const kst_prog_t *p)
 The image the edit that waits would leave.
void kst_prog_soft_confirm (kst_prog_t *p)
 Confirms the waiting soft edit.
void kst_prog_soft_cancel (kst_prog_t *p)
 Drops the waiting soft edit.
void kst_prog_discard (kst_prog_t *p)
 The draft becomes the servo's image again, and no value counts as confirmed.
kst_prog_msg_id_t kst_prog_connect (kst_prog_t *p, uint8_t port)
 Take programming port port, from 0, with the supply set by kst_prog_supply_set().
void kst_prog_bench_armed (kst_prog_t *p, bool armed)
 The bench is armed or asked to arm.
bool kst_prog_port_taken (const kst_link_readout_t *rd)
 Whether the bench takes no arm by what the link module reads: an operation is on its way or runs, the port is read and is not in PWM, or the page answers and is not read yet (KST_LINK_SYNC).
bool kst_prog_holds_port (const kst_prog_t *p)
 Whether nothing but the programmer reaches the port: an operation of this model is on its way or a session is open (ENTERING, PROGRAMMING, WORKING, LEAVING), or kst_prog_port_taken() says so of the readout last fed.
void kst_prog_supply_set (kst_prog_t *p, uint16_t mv, uint16_t ma)
 What an ENTER asks of the PD mini: mv and its current limit ma.
void kst_prog_supply_caps (kst_prog_t *p, uint16_t max_mv, uint16_t max_ma)
 The highest voltage and current limit the operator lets the supply give (the SUPPLY screen's limits), 0 for none.
void kst_prog_supply_floor (kst_prog_t *p, uint16_t min_mv)
 The lowest voltage a session runs at, mV; 0 for none.
uint16_t kst_prog_supply_mv (const kst_prog_t *p)
 The voltage an ENTER asks for, in mV.
uint16_t kst_prog_supply_ma (const kst_prog_t *p)
 The current limit an ENTER asks for, in mA.
kst_prog_msg_id_t kst_prog_read (kst_prog_t *p)
 Asks for a read of the servo.
kst_prog_msg_id_t kst_prog_verify (kst_prog_t *p)
 Asks for a check of the servo's image.
kst_prog_msg_id_t kst_prog_enable (kst_prog_t *p, bool on)
 The switch.
kst_prog_msg_id_t kst_prog_enable_check (const kst_prog_t *p)
 What kst_prog_enable() would refuse the switch for, and nothing said; KST_PROG_MSG_NONE where it goes on.
bool kst_prog_restore_only (const kst_prog_t *p)
 The session is locked and its backup is held: the switch is taken with no servo read, and the restore of that backup is the one write that goes.
kst_prog_msg_id_t kst_prog_write_check (kst_prog_t *p)
 Whether kst_prog_write() would be sent, without sending it.
kst_prog_msg_id_t kst_prog_write (kst_prog_t *p)
 Write the draft.
kst_prog_msg_id_t kst_prog_release_check (kst_prog_t *p)
 The same for kst_prog_release().
kst_prog_msg_id_t kst_prog_release (kst_prog_t *p)
 Releases the servo.
bool kst_prog_restore_offered (const kst_prog_t *p, kst_prog_from_t from)
 Whether from holds an image that differs from the servo.
kst_prog_msg_id_t kst_prog_restore_plan (kst_prog_t *p, kst_prog_from_t from, kst_prog_restore_t *out)
 Prepare a restore.
kst_prog_msg_id_t kst_prog_restore (kst_prog_t *p, const kst_prog_restore_t *plan)
 Run the restore prepared.
void kst_prog_forget (kst_prog_t *p)
 Discard the journal.
bool kst_prog_run_hold (kst_prog_t *p)
 Hold the servo as read now as the run's.
void kst_prog_run_written (kst_prog_t *p)
 The run's first write was sent, whether it ended well or not: the file it saved, if any, holds the servo as held.
void kst_prog_run_close (kst_prog_t *p)
 The run is over: the servo stays held for RESTORE, and a later session's first write saves its own file again.
void kst_prog_run_drop (kst_prog_t *p)
 Nothing held.
const kst_image_t * kst_prog_run_image (const kst_prog_t *p)
 The servo the run held, or NULL.
const char * kst_prog_run_backup (const kst_prog_t *p)
 The file of that servo; "" for none: no card, or the first write not ended yet.
bool kst_prog_run_matches (const kst_prog_t *p)
 The servo read differs from the run's in LEFT ANGLE, RIGHT ANGLE, PULSE LOWER and PULSE UPPER at most.
kst_prog_msg_id_t kst_prog_leave (kst_prog_t *p)
 End the session: the port goes back to PWM and the supply stays as it is.
bool kst_prog_wait_set (kst_prog_t *p, uint32_t ms)
 The wait between the end of a session and the first PWM pulse, up to KST_PROG_WAIT_MAX_MS.
uint16_t kst_prog_wait_ms (const kst_prog_t *p)
 The wait before the first PWM pulse.
void kst_prog_abort (kst_prog_t *p)
 The operator's cancel.
kst_prog_msg_id_t kst_prog_save (kst_prog_t *p, const char *name)
 Save the servo's image to a new file with name.
kst_prog_msg_id_t kst_prog_files (kst_prog_t *p, unsigned first)
 Ask for the list of files from file first on, counted from 0: up to KST_PROG_FILES_MAX of them.
unsigned kst_prog_files_first (const kst_prog_t *p)
 The number of the last list's first file among the card's.
kst_prog_msg_id_t kst_prog_load (kst_prog_t *p, const char *name)
 Load the file with name into the draft.
bool kst_prog_card_busy (const kst_prog_t *p)
 A save, a list or a load is on its way.
uint32_t kst_prog_files_seq (const kst_prog_t *p)
 The sequence number of the file list.
const char * kst_prog_file_name (const kst_prog_t *p, unsigned i)
 The names of the last list, i from 0; "" beyond them.
unsigned kst_prog_file_type (const kst_prog_t *p, unsigned i)
 That file's servo type as the card's side gave it; 0 none.
unsigned kst_prog_file_count (const kst_prog_t *p, unsigned *total)
 The entries of the last list and, when total is not NULL, the servo files on the card.
const char * kst_prog_preset_name (const kst_prog_t *p)
 The next preset name as the last list gave it; "" when none is left.
const char * kst_prog_card_name (const kst_prog_t *p)
 The file last saved or asked for.
kst_prog_file_kind_t kst_prog_load_kind (const kst_prog_t *p)
 What the file last loaded is.
unsigned kst_prog_load_named (const kst_prog_t *p, unsigned *fields)
 The fields the file last loaded gives a value for, and through fields, when not NULL, the named fields a file has: 0 where the card's side did not count them.
kst_field_set_t kst_prog_load_skipped (const kst_prog_t *p)
 The fields in which the file in the draft differs from the servo and that are never written; 0 once the servo is read again or the draft is discarded.
bool kst_prog_soft_is_load (const kst_prog_t *p)
 The edit that waits for kst_prog_soft_confirm() is a file.
bool kst_prog_card_take (kst_prog_t *p, kst_prog_card_req_t *out)
 A request for the card's side; false while there is none.
void kst_prog_card_done (kst_prog_t *p, const kst_prog_card_done_t *done)
 What the card's side made of it.
size_t kst_prog_file_take (kst_prog_t *p, char *out, size_t n)
 The file text is to be written: fill out and return its length; 0 while nothing is to be written or n is too small.
void kst_prog_file_done (kst_prog_t *p, bool ok)
 How the write of the text kst_prog_file_take() gave went.
bool kst_prog_file_whole (const char *text, size_t len)
 Whether text is a whole file: its version, its lines and its check value.
bool kst_prog_file_load (kst_prog_t *p, const char *text, size_t len)
 The file as found at start.
size_t kst_prog_file_text (const kst_prog_t *p, char *out, size_t n)
 The text of the state as it is, for a caller that only reads.

Detailed Description

The programmer for KST and Chaservo servos as the SERVO screen runs it: what is read from a servo, what the operator has changed, and what may be written.

The session with the servo runs at the IOmcu and the panel's link module (kst_link.h) carries its operations. This file sits between that module and the screen:

  • It holds the servo's image as last read, a draft the operator edits, the backup the IOmcu's session holds, and the journal of a write.
  • An edit goes through the field table and the limits of protocols/kst: a value that breaks a hard rule is not taken, a value that breaks a soft rule waits for a confirmation. No limit is stated here. The soft rules compare with the servo as the session found it (kst_prog_soft_base()), and a rule confirmed for a value is asked again for a value further from that image.
  • A write is sent with the switch ENABLE WRITE TO SERVO on only. The switch goes off at every entry of the screen, when the link goes, when the IOmcu starts again, at STOP, and with every servo connected.
  • Every answer of kst_link_start(), every outcome kind, every refusal of the port and every result of the session becomes one message (kst_prog_msg_id_t) the screen has a text for.

The journal: before a write the image the servo holds, the port and the GPIO that port drives are recorded, in memory and in the file text (kst_prog_file_text()). A write that ends with the servo verified clears it. A journal that stands after a link loss, a restart or an abort says the servo may hold part of a write; the next read compares the servo with the recorded image.

Servo files: the card keeps images of servos in named files. This file asks for a save, a list and a load (kst_prog_card_take()) and takes what the card's side made of it (kst_prog_card_done()), as images and names: the text of a file, its name's rules and the servo type's rule are the card side's (kst_card.h).

  • A save writes the servo's image as last read, under the name the operator gave. The first write of a session to a servo waits for a save nobody asked for, under a preset name, and is not sent when the card takes no file.
  • A load takes a file of the servo's type only (kst_card.h says what the types are). Its editable fields become the draft, as edits: a hard rule refuses the file, soft rules wait for a confirmation, and nothing is written before the operator writes the draft. A field of another access class that differs stays as the servo holds it and is named (kst_prog_load_skipped()). A file edited by hand is taken the same way and named as one.

The journal's file text, at most KST_PROG_FILE_MAX bytes:

RCBENCH KST 2 journal=<64 hexadecimal digits> the image before a write, when one is recorded target=<64 hexadecimal digits> what that write was to leave port=<1 hexadecimal digit> pin=<2 hexadecimal digits> the GPIO the port drove, FF not known check=<4 hexadecimal digits> CRC-16/CCITT of the bytes before

A text of version 1 ("RCBENCH KST 1", no pin line) is read as one whose pin is not known. A pin above KST_PROG_PIN_LAST reads as not known: the record stands and names its port. The text written is version 2.

Pure C. The caller hands in kst_prog_feed_t every frame and carries out the commands kst_prog_take() gives. One task only.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ KST_PROG_RUN_MAX_MS

#define KST_PROG_RUN_MAX_MS   120000u

And one the port reports busy for this long from its start is aborted too.

A chosen value: the longest wait of the port is the 10000ms of a LEAVE, and the duration of the longest write is not measured.

◆ KST_PROG_RUN_MS

#define KST_PROG_RUN_MS   30000u

An operation without an outcome for this long is aborted.

The time counts from the last feed in which the port reported it busy.

Typedef Documentation

◆ kst_prog_msg_id_t

typedef unsigned kst_prog_msg_id_t

What the screen says.

The four ranges at the end take a code of the link module or the core: KST_PROG_MSG_START + kst_link_start_t, KST_PROG_MSG_OUT + kst_link_outcome_kind_t, KST_PROG_MSG_REF + link_kst_refusal_t and KST_PROG_MSG_SES + the result byte of the outcome (a kst_ses_t or a LINK_KST_RESULT_*). A message is a number and not an enum for that reason: most of its values lie between the names.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

The message ids of the programmer's screen.

Enumerator
KST_PROG_MSG_READ 

all registers read

KST_PROG_MSG_READ_ONLY 

read; the fingerprint fails

KST_PROG_MSG_WRITTEN 

arg values written and verified

KST_PROG_MSG_VERIFIED 

the servo holds what was read

KST_PROG_MSG_VERIFY_DIFF 

arg registers differ

KST_PROG_MSG_LEFT 

the tester has the output again

KST_PROG_MSG_SAVED 

the servo's image is in the file kst_prog_card_name()

KST_PROG_MSG_CARD_NONE 

no card: no file, nothing written

KST_PROG_MSG_STORE_FAILED 

the card took no journal; nothing was written to the servo

KST_PROG_MSG_FILE_BAD 

the journal's file is not readable

KST_PROG_MSG_JOURNAL 

a write was interrupted; read. arg: kst_prog_journal_arg()

KST_PROG_MSG_JOURNAL_SAME 

the servo holds what the record says it held before the write; the record stands and asks whether this is the servo. arg: as for KST_PROG_MSG_JOURNAL

KST_PROG_MSG_JOURNAL_DONE 

the same for the write's target

KST_PROG_MSG_JOURNAL_DIFF 

the servo holds something else

KST_PROG_MSG_FORGOTTEN 

the journal was discarded

KST_PROG_MSG_EDIT_HARD 

arg: the kst_rule_t that refuses

KST_PROG_MSG_EDIT_LOCKED 

the field is not editable

KST_PROG_MSG_NEED_ENABLE 

ENABLE WRITE TO SERVO is off

KST_PROG_MSG_NEED_READ 

read the servo first

KST_PROG_MSG_NEED_PORT 

no servo is connected

KST_PROG_MSG_NO_RESTORE 

the servo holds that image already

KST_PROG_MSG_RESTORE_REFUSED 

arg: the kst_rule_t that refuses

KST_PROG_MSG_STOPPED 

STOP: the operation was aborted

KST_PROG_MSG_TIMEOUT 

no outcome within KST_PROG_RUN_MS

KST_PROG_MSG_JOURNAL_OTHER 

the servo read is not the journal's; arg: as for KST_PROG_MSG_JOURNAL

KST_PROG_MSG_CARD_FULL 

no space on the card, or no preset name is left

KST_PROG_MSG_CARD_WRITE 

the file was not written whole

KST_PROG_MSG_CARD_READ 

the card was not read

KST_PROG_MSG_NO_FILES 

the card holds no servo file

KST_PROG_MSG_NAME_BAD 

the card's side does not take the name

KST_PROG_MSG_NAME_EXISTS 

a file has the name; none is replaced

KST_PROG_MSG_LOAD_BAD 

the file is not whole; arg: its line, 0 none

KST_PROG_MSG_LOAD_CHECKSUM 

the check value does not fit the text

KST_PROG_MSG_LOAD_NEWER 

the file's format is a later one

KST_PROG_MSG_LOAD_TYPE 

the file is of another servo type; arg: the file's type, and above bit 7 the servo's

KST_PROG_MSG_LOAD_VALUE 

a value of the file is not taken; reg: its kst_field_id_t, 0xFF none; arg: its line, 0 none

KST_PROG_MSG_LOAD_REFUSED 

the file breaks a hard rule; arg: the kst_rule_t

KST_PROG_MSG_LOAD_SAME 

the file changes nothing; arg: locked fields that differ and stay

KST_PROG_MSG_LOAD_SOFT 

the file waits for kst_prog_soft_confirm()

KST_PROG_MSG_LOADED 

the draft holds the file; arg: fields it changes, and above bit 7 the locked fields that differ and stay

KST_PROG_MSG_LOADED_EDITED 

the same for a file edited by hand

KST_PROG_MSG_LOADED_UNTYPED 

and for one that names no servo type

KST_PROG_MSG_NEED_TARGET 

the SERVO screen's target is not the programming port

KST_PROG_MSG_LEAVE_SUPPLY 

a PD mini answers and the IOmcu is below link 4.15: the port has no way back to PWM that leaves the supply on

KST_PROG_MSG_LEFT_NO_WAIT 

the port is back in PWM by an IOmcu below link 4.15: no wait was applied

KST_PROG_MSG_LEFT_DOUBT 

the port is back in PWM from a session in doubt, no PD mini answering: no wait was applied

KST_PROG_MSG_LEAVE_CUT 

the wait of a LEAVE was cut: an abort, a disarm or the supply off

KST_PROG_MSG_NEED_DISARM 

the bench is armed or asked to arm: the port is not taken and no frame is sent

KST_PROG_MSG_BACKUP_OTHER 

the servo read is not the one the session's backup was read from: the backup is not restored to it

KST_PROG_MSG_SESSION_ENDED 

the port is in PWM and no command of this model put it there: the supply went off or the IOmcu started again. The session's values are gone

KST_PROG_MSG_UNKNOWN 

a result, a refusal or an outcome the tables do not hold; arg: the byte

KST_PROG_MSG_SUPPLY_CAPS 

the programming voltage or current is above the supply's limits: the port is not taken

KST_PROG_MSG_CARD_DENIED 

the card takes no file: it is write protected, or a file has the name of the directory

◆ kst_prog_card_op_t

What the card's side is asked for.

Enumerator
KST_PROG_CARD_SAVE 

the image into a new file

KST_PROG_CARD_LIST 

the names of the files and the next preset

KST_PROG_CARD_LOAD 

the file with the name, against the servo

◆ kst_prog_card_result_t

How it went.

Enumerator
KST_PROG_CARD_FULL 

no space, or no preset name is left

KST_PROG_CARD_READ_ERR 

the directory or the file does not read

KST_PROG_CARD_NAME 

the name is not one a file may have

KST_PROG_CARD_EXISTS 

a file has the name; nothing written

KST_PROG_CARD_BAD 

the text is not a whole servo file

KST_PROG_CARD_CHECKSUM 

its check value does not fit

KST_PROG_CARD_NEWER 

a format this code does not read

KST_PROG_CARD_TYPE 

the file is from another servo type

KST_PROG_CARD_VALUE 

a value of the file is not taken

KST_PROG_CARD_LIMIT 

the file breaks a hard rule no single line of it is at fault for

KST_PROG_CARD_DENIED 

the card takes no file: it is write protected, or a file has the name of the directory

◆ kst_prog_cmd_kind_t

The kinds of command the programmer hands to the link module.

Enumerator
KST_PROG_CMD_START 

kst_link_start(req)

KST_PROG_CMD_ABORT 

kst_link_abort()

KST_PROG_CMD_FETCH 

kst_link_fetch(): the port holds images this panel does not, after a start of the panel on a held port

◆ kst_prog_edit_t

What an edit came to.

Enumerator
KST_PROG_EDIT_OK 

the draft holds the value

KST_PROG_EDIT_SOFT 

it waits for kst_prog_soft_confirm()

KST_PROG_EDIT_REFUSED 

not taken; kst_prog_message() says why

◆ kst_prog_file_kind_t

What a file that loads is.

Enumerator
KST_PROG_FILE_VERIFIED 

as written, its check value fits

KST_PROG_FILE_EDITED 

no check value; names its type

KST_PROG_FILE_UNTYPED 

no check value and no servo type

◆ kst_prog_from_t

Where a restore takes its image from.

Enumerator
KST_PROG_FROM_SESSION 

the backup of the IOmcu's session

KST_PROG_FROM_JOURNAL 

the image recorded before a write

KST_PROG_FROM_RUN 

the servo before a limit run's first write (kst_prog_run_hold())

◆ kst_prog_res_t

What a result of the session says of a write that ended with it.

Enumerator
KST_PROG_RES_OK 

the write ended as asked

KST_PROG_RES_CLEAN 

with no step counted done the servo holds the image the write started from: no frame went, or every write was undone and read back

KST_PROG_RES_DOUBT 

the servo may hold part of the write

◆ kst_prog_state_t

Where the programmer is.

Enumerator
KST_PROG_DOWN 

no IOmcu answers

KST_PROG_NO_PAGE 

the IOmcu has no such page

KST_PROG_SYNC 

the page has not been read yet

KST_PROG_PWM 

the tester has the output

KST_PROG_ENTERING 

the output leaves PWM

KST_PROG_PROGRAMMING 

the port holds the pin, nothing runs

KST_PROG_WORKING 

an operation runs

KST_PROG_LEAVING 

the servo rail is switched

Function Documentation

◆ kst_prog_abort()

void kst_prog_abort ( kst_prog_t * p)

The operator's cancel.

Parameters
pThe programmer state.

◆ kst_prog_backed_up()

bool kst_prog_backed_up ( const kst_prog_t * p)

A file holds the servo as this session found it: the next write waits for no save.

Parameters
pThe programmer state.
Returns
true when a file holds the servo as the session found it.

◆ kst_prog_backup_name()

const char * kst_prog_backup_name ( const kst_prog_t * p)

That file's name; "" while there is none.

Parameters
pThe programmer state.
Returns
The backup file's name, or an empty string.

◆ kst_prog_backup_other()

bool kst_prog_backup_other ( const kst_prog_t * p)

The servo read is not the one the session's backup was read from: the two differ in a field no write of the session set out to change.

The backup is not offered and not restored until a new session reads its own. Two servos that agree in every such field are not told apart. Never true for a session this model did not see begin, after a link loss or a start of the panel under a session: its writes are not known.

Parameters
pThe programmer state.
Returns
true when the servo read is not the one the session's backup was read from.

◆ kst_prog_bench_armed()

void kst_prog_bench_armed ( kst_prog_t * p,
bool armed )

The bench is armed or asked to arm.

Programming and an armed bench are exclusive: while this is set or the feed reports armed outputs no port is taken and no operation that sends frames starts (KST_PROG_MSG_NEED_DISARM), and the caller takes no arm while a port is held.

Parameters
pThe programmer state.
armedtrue when the bench is armed or asked to arm.

◆ kst_prog_card_busy()

bool kst_prog_card_busy ( const kst_prog_t * p)

A save, a list or a load is on its way.

Parameters
pThe programmer state.
Returns
true while a card operation runs.

◆ kst_prog_card_done()

void kst_prog_card_done ( kst_prog_t * p,
const kst_prog_card_done_t * done )

What the card's side made of it.

An answer to a request that is no longer awaited changes nothing, but for one: the OK of a save given up at KST_PROG_CARD_MS names its file and, for the servo as it was saved, is the session's backup.

Parameters
pThe programmer state.
doneThe answer of the card.

◆ kst_prog_card_name()

const char * kst_prog_card_name ( const kst_prog_t * p)

The file last saved or asked for.

Parameters
pThe programmer state.
Returns
The name.

◆ kst_prog_card_take()

bool kst_prog_card_take ( kst_prog_t * p,
kst_prog_card_req_t * out )

A request for the card's side; false while there is none.

Parameters
pThe programmer state.
outReceives the request.
Returns
true when a request was taken.

◆ kst_prog_changed()

kst_field_set_t kst_prog_changed ( const kst_prog_t * p)

The fields in which the draft differs from the servo, register 01's copy of Max.

Duty left out.

Parameters
pThe programmer state.
Returns
The fields in which the draft differs from the servo.

◆ kst_prog_changes()

unsigned kst_prog_changes ( const kst_prog_t * p)

The number of fields the draft differs in.

Parameters
pThe programmer state.
Returns
The number of changed fields.

◆ kst_prog_connect()

kst_prog_msg_id_t kst_prog_connect ( kst_prog_t * p,
uint8_t port )

Take programming port port, from 0, with the supply set by kst_prog_supply_set().

KST_PROG_MSG_NEED_TARGET while the feed's target is not that port, KST_PROG_MSG_NEED_DISARM on an armed bench.

Parameters
pThe programmer state.
portThe programming port, from 0.
Returns
The message for the connect attempt.

◆ kst_prog_discard()

void kst_prog_discard ( kst_prog_t * p)

The draft becomes the servo's image again, and no value counts as confirmed.

Parameters
pThe programmer state.

◆ kst_prog_draft()

const kst_image_t * kst_prog_draft ( const kst_prog_t * p)

The draft image being edited.

Parameters
pThe programmer state.
Returns
The draft image.

◆ kst_prog_edit()

kst_prog_edit_t kst_prog_edit ( kst_prog_t * p,
kst_field_id_t id,
uint16_t raw )

Set a field of the draft to raw.

Parameters
pThe programmer state.
idThe field.
rawThe raw value to set.
Returns
The result of the edit.

◆ kst_prog_editable()

bool kst_prog_editable ( const kst_prog_t * p)

A servo was read, its image passes the fingerprint and is not in doubt: it may be edited and written.

Parameters
pThe programmer state.
Returns
true when the servo may be edited and written.

◆ kst_prog_enable()

kst_prog_msg_id_t kst_prog_enable ( kst_prog_t * p,
bool on )

The switch.

On is taken with a servo read that passes the fingerprint, and by a locked session that holds its backup.

Parameters
pThe programmer state.
ontrue to switch the write switch on.
Returns
The message for the switch.

◆ kst_prog_enable_check()

kst_prog_msg_id_t kst_prog_enable_check ( const kst_prog_t * p)

What kst_prog_enable() would refuse the switch for, and nothing said; KST_PROG_MSG_NONE where it goes on.

Parameters
pThe programmer state.
Returns
What enable would refuse the switch for, or KST_PROG_MSG_NONE.

◆ kst_prog_feed()

void kst_prog_feed ( kst_prog_t * p,
const kst_prog_feed_t * f )

The published state of this frame.

Outcomes and answers are taken here.

Parameters
pThe programmer state.
fThe inputs of this frame.

◆ kst_prog_file_count()

unsigned kst_prog_file_count ( const kst_prog_t * p,
unsigned * total )

The entries of the last list and, when total is not NULL, the servo files on the card.

Parameters
pThe programmer state.
totalReceives the total number of servo files on the card, or NULL.
Returns
The number of files listed.

◆ kst_prog_file_done()

void kst_prog_file_done ( kst_prog_t * p,
bool ok )

How the write of the text kst_prog_file_take() gave went.

The answer to a write's journal releases that write when the card completed the file and the write's start gate holds as it is now: the port in PROGRAMMING on the write's port, no STOP, the bench not ARMED and ENABLE WRITE TO SERVO on. Otherwise the write ends as one that did not start: nothing goes to the servo, its record is cleared, and the message names the gate that refused it, or KST_PROG_MSG_STORE_FAILED.

Parameters
pThe programmer state.
oktrue when the card completed the file.

◆ kst_prog_file_load()

bool kst_prog_file_load ( kst_prog_t * p,
const char * text,
size_t len )

The file as found at start.

False, with KST_PROG_MSG_FILE_BAD, for a text that is not whole.

Parameters
pThe programmer state.
textThe file text.
lenThe length of the text, in bytes.
Returns
true when the text is a whole valid file.

◆ kst_prog_file_name()

const char * kst_prog_file_name ( const kst_prog_t * p,
unsigned i )

The names of the last list, i from 0; "" beyond them.

Parameters
pThe programmer state.
iThe index in the list.
Returns
The name, or an empty string beyond the list.

◆ kst_prog_file_take()

size_t kst_prog_file_take ( kst_prog_t * p,
char * out,
size_t n )

The file text is to be written: fill out and return its length; 0 while nothing is to be written or n is too small.

Parameters
pThe programmer state.
outReceives the text.
nThe size of out, in bytes.
Returns
The number of bytes written to out; 0 when none is wanted.

◆ kst_prog_file_text()

size_t kst_prog_file_text ( const kst_prog_t * p,
char * out,
size_t n )

The text of the state as it is, for a caller that only reads.

Parameters
pThe programmer state.
outReceives the text.
nThe size of out, in bytes.
Returns
The number of bytes written; 0 when out is too small.

◆ kst_prog_file_type()

unsigned kst_prog_file_type ( const kst_prog_t * p,
unsigned i )

That file's servo type as the card's side gave it; 0 none.

Parameters
pThe programmer state.
iThe index in the list.
Returns
The type, or 0 beyond the list.

◆ kst_prog_file_whole()

bool kst_prog_file_whole ( const char * text,
size_t len )

Whether text is a whole file: its version, its lines and its check value.

Changes nothing and says nothing.

Parameters
textThe file text.
lenThe length of the text, in bytes.
Returns
true when the text parses.

◆ kst_prog_files()

kst_prog_msg_id_t kst_prog_files ( kst_prog_t * p,
unsigned first )

Ask for the list of files from file first on, counted from 0: up to KST_PROG_FILES_MAX of them.

kst_prog_files_seq() moves when it is there. Refused with KST_PROG_MSG_NEED_READ while the servo is in doubt.

Parameters
pThe programmer state.
firstThe index of the first file to list.
Returns
The message id.

◆ kst_prog_files_first()

unsigned kst_prog_files_first ( const kst_prog_t * p)

The number of the last list's first file among the card's.

Parameters
pThe programmer state.
Returns
The index.

◆ kst_prog_files_seq()

uint32_t kst_prog_files_seq ( const kst_prog_t * p)

The sequence number of the file list.

Parameters
pThe programmer state.
Returns
The sequence number, which moves when the list changes.

◆ kst_prog_first_write()

bool kst_prog_first_write ( const kst_prog_t * p)

No write was sent since the servo was connected: the next asks for the free horn.

Parameters
pThe programmer state.
Returns
true when no write was sent since the servo was connected.

◆ kst_prog_forget()

void kst_prog_forget ( kst_prog_t * p)

Discard the journal.

KST_PROG_MSG_START + KST_LINK_START_BUSY, and nothing discarded, while an operation is on its way.

Parameters
pThe programmer state.

◆ kst_prog_gate_claim()

bool kst_prog_gate_claim ( kst_prog_gate_t * g,
uint32_t id )

The link's task, with a START out of its queue: true when the command is to be carried out.

False: it is dropped, with no answer.

Parameters
gThe gate.
idThe START's id.
Returns
true when the command is to be carried out.

◆ kst_prog_gate_init()

void kst_prog_gate_init ( kst_prog_gate_t * g)

Sets up a START gate.

Parameters
gThe gate to set up.

◆ kst_prog_gate_offer()

void kst_prog_gate_offer ( kst_prog_gate_t * g,
uint32_t id )

The pass of START id is there to be taken.

Parameters
gThe gate.
idThe START's id.

◆ kst_prog_gate_revoke()

bool kst_prog_gate_revoke ( kst_prog_gate_t * g,
uint32_t id )

The model: true when START id is not carried out and never is.

Parameters
gThe gate.
idThe START's id.
Returns
true when START id is not carried out and never is.

◆ kst_prog_gate_set()

void kst_prog_gate_set ( kst_prog_t * p,
kst_prog_gate_t * g )

The gate the link's task claims each START at.

With one set, a START nobody answers within KST_PROG_START_MS is revoked and was never carried out. With none set, such a START counts as one that may have run: the servo is read before anything else. kst_prog_init() sets none.

Parameters
pThe programmer state.
gThe gate, or NULL for none.

◆ kst_prog_have_servo()

bool kst_prog_have_servo ( const kst_prog_t * p)

Whether a servo was read.

Parameters
pThe programmer state.
Returns
true when a servo was read.

◆ kst_prog_holds_port()

bool kst_prog_holds_port ( const kst_prog_t * p)

Whether nothing but the programmer reaches the port: an operation of this model is on its way or a session is open (ENTERING, PROGRAMMING, WORKING, LEAVING), or kst_prog_port_taken() says so of the readout last fed.

The tester's target and the port's pulse stay as they are for as long (settings_held(), prog_link_hold()).

Parameters
pThe programmer state.
Returns
true when nothing but the programmer reaches the port.

◆ kst_prog_in_doubt()

bool kst_prog_in_doubt ( const kst_prog_t * p)

The servo may hold part of a write: a journal stands, the port asks for a read, an operation timed out, or the session is locked.

Parameters
pThe programmer state.
Returns
true when the servo may hold part of a write.

◆ kst_prog_init()

void kst_prog_init ( kst_prog_t * p)

Sets up the programmer state.

Parameters
pThe programmer state to set up.

◆ kst_prog_journal()

bool kst_prog_journal ( const kst_prog_t * p)

A write was interrupted and the servo was not compared since.

Parameters
pThe programmer state.
Returns
true while a write was interrupted and the servo was not compared since.

◆ kst_prog_journal_arg()

unsigned kst_prog_journal_arg ( const kst_prog_t * p)

The argument of the journal's messages: the port + 1 in bits 0-7, the pin + 1 in bits 8-15, 0 there when the pin is not known.

Parameters
pThe programmer state.
Returns
The argument of the journal's messages.

◆ kst_prog_journal_asks()

kst_prog_msg_id_t kst_prog_journal_asks ( const kst_prog_t * p)

The servo read holds, register for register, the record's image (KST_PROG_MSG_JOURNAL_SAME) or the write's target (KST_PROG_MSG_JOURNAL_DONE), and the record stands: a second servo with the same settings is not told apart from the one of the write.

Nothing is written to the servo until kst_prog_forget() discards the record. KST_PROG_MSG_NONE otherwise.

Parameters
pThe programmer state.
Returns
The message the journal asks for, or KST_PROG_MSG_NONE.

◆ kst_prog_journal_held()

bool kst_prog_journal_held ( const kst_prog_t * p)

A record of an interrupted write is held, read back or not: the one RESTORE offers the values of.

Parameters
pThe programmer state.
Returns
true when a record of an interrupted write is held.

◆ kst_prog_journal_other()

bool kst_prog_journal_other ( const kst_prog_t * p)

The servo read cannot be the one of the interrupted write: it is on another port, or a register of it holds neither the record's value nor the write's target.

The low register of a field in two registers that the write changes is exempt: a plan may set it to a third value. Nothing is restored to it and nothing is written to it until the journal is discarded.

Parameters
pThe programmer state.
Returns
true when the servo read cannot be the interrupted write's servo.

◆ kst_prog_journal_pin()

uint8_t kst_prog_journal_pin ( const kst_prog_t * p)

The GPIO that port drove at the write, or KST_PROG_NO_PIN: not known, or a record of version 1.

Parameters
pThe programmer state.
Returns
The GPIO that port drove, or KST_PROG_NO_PIN.

◆ kst_prog_journal_port()

uint8_t kst_prog_journal_port ( const kst_prog_t * p)

The port of the interrupted write, from 0.

Parameters
pThe programmer state.
Returns
The port of the interrupted write, from 0.

◆ kst_prog_leave()

kst_prog_msg_id_t kst_prog_leave ( kst_prog_t * p)

End the session: the port goes back to PWM and the supply stays as it is.

The one place a session is ended by the operator. While a PD mini answers the port has no command for it and the answer is KST_PROG_MSG_LEAVE_SUPPLY.

Parameters
pThe programmer state.
Returns
The message id.

◆ kst_prog_load()

kst_prog_msg_id_t kst_prog_load ( kst_prog_t * p,
const char * name )

Load the file with name into the draft.

Taken with a servo read that passes the fingerprint and is not in doubt. A file of another servo type, a file with a value that is not taken, a file that breaks a hard rule and a file that is not whole change nothing. A file that breaks soft rules waits for kst_prog_soft_confirm().

Parameters
pThe programmer state.
nameThe file name.
Returns
The message id.

◆ kst_prog_load_kind()

kst_prog_file_kind_t kst_prog_load_kind ( const kst_prog_t * p)

What the file last loaded is.

Parameters
pThe programmer state.
Returns
The kind, as kst_prog_file_kind_t.

◆ kst_prog_load_named()

unsigned kst_prog_load_named ( const kst_prog_t * p,
unsigned * fields )

The fields the file last loaded gives a value for, and through fields, when not NULL, the named fields a file has: 0 where the card's side did not count them.

Parameters
pThe programmer state.
fieldsReceives the field set, or NULL.
Returns
The number of named fields.

◆ kst_prog_load_skipped()

kst_field_set_t kst_prog_load_skipped ( const kst_prog_t * p)

The fields in which the file in the draft differs from the servo and that are never written; 0 once the servo is read again or the draft is discarded.

Parameters
pThe programmer state.
Returns
The skipped fields.

◆ kst_prog_message()

const kst_prog_msg_t * kst_prog_message ( const kst_prog_t * p)

The last message.

Parameters
pThe programmer state.
Returns
The last message, or NULL.

◆ kst_prog_no_file()

bool kst_prog_no_file ( const kst_prog_t * p)

A write of this session started with no card in the slot, and no file holds the servo as the session found it: the session's backup is the one copy.

Ends with the next file a write saves.

Parameters
pThe programmer state.
Returns
true when the session's backup is the one copy.

◆ kst_prog_op()

link_kst_op_t kst_prog_op ( const kst_prog_t * p)

The operation on its way or running; LINK_KST_OP_NONE for none.

Parameters
pThe programmer state.
Returns
The operation, as link_kst_op_t.

◆ kst_prog_planning()

bool kst_prog_planning ( const kst_prog_t * p)

The IOmcu plans the order of a write's or a restore's writes: no frame goes to the servo yet.

Parameters
pThe programmer state.
Returns
true while the IOmcu plans the order of the writes.

◆ kst_prog_port()

uint8_t kst_prog_port ( const kst_prog_t * p)

The programming port.

Parameters
pThe programmer state.
Returns
The port the session holds, from 0.

◆ kst_prog_port_taken()

bool kst_prog_port_taken ( const kst_link_readout_t * rd)

Whether the bench takes no arm by what the link module reads: an operation is on its way or runs, the port is read and is not in PWM, or the page answers and is not read yet (KST_LINK_SYNC).

False where no page answers: nothing can hold a port there.

Parameters
rdThe link module's readout.
Returns
true when the bench takes no arm by what the link module reads.

◆ kst_prog_preset_name()

const char * kst_prog_preset_name ( const kst_prog_t * p)

The next preset name as the last list gave it; "" when none is left.

Parameters
pThe programmer state.
Returns
The preset name.

◆ kst_prog_range()

bool kst_prog_range ( const kst_prog_t * p,
kst_field_id_t id,
uint16_t * lo,
uint16_t * hi )

The raw values of id the hard rules accept in the draft as it is, as the lowest and the highest.

False when none is accepted, the field is not editable or no servo was read.

Parameters
pThe programmer state.
idThe field.
loReceives the lowest raw value accepted.
hiReceives the highest raw value accepted.
Returns
false when none is accepted, the field is not editable or no servo was read.

◆ kst_prog_read()

kst_prog_msg_id_t kst_prog_read ( kst_prog_t * p)

Asks for a read of the servo.

Parameters
pThe programmer state.
Returns
The message for the read.

◆ kst_prog_release()

kst_prog_msg_id_t kst_prog_release ( kst_prog_t * p)

Releases the servo.

Parameters
pThe programmer state.
Returns
The message for the release.

◆ kst_prog_release_check()

kst_prog_msg_id_t kst_prog_release_check ( kst_prog_t * p)

The same for kst_prog_release().

Parameters
pThe programmer state.
Returns
The message the release would give.

◆ kst_prog_restore()

kst_prog_msg_id_t kst_prog_restore ( kst_prog_t * p,
const kst_prog_restore_t * plan )

Run the restore prepared.

Parameters
pThe programmer state.
planThe plan from kst_prog_restore_plan().
Returns
The message for the restore.

◆ kst_prog_restore_offered()

bool kst_prog_restore_offered ( const kst_prog_t * p,
kst_prog_from_t from )

Whether from holds an image that differs from the servo.

Parameters
pThe programmer state.
fromThe source of the image.
Returns
true when from holds an image that differs from the servo.

◆ kst_prog_restore_only()

bool kst_prog_restore_only ( const kst_prog_t * p)

The session is locked and its backup is held: the switch is taken with no servo read, and the restore of that backup is the one write that goes.

Every other write waits for a read and for the lock to end.

Parameters
pThe programmer state.
Returns
true when the switch is taken with no servo read and only the restore goes.

◆ kst_prog_restore_plan()

kst_prog_msg_id_t kst_prog_restore_plan ( kst_prog_t * p,
kst_prog_from_t from,
kst_prog_restore_t * out )

Prepare a restore.

For KST_PROG_FROM_JOURNAL the draft becomes the servo's image with the editable fields of the source.

Parameters
pThe programmer state.
fromThe source of the image.
outReceives the plan.
Returns
The message for the plan.

◆ kst_prog_result_class()

kst_prog_res_t kst_prog_result_class ( unsigned result)

The class of result, a kst_ses_t or a LINK_KST_RESULT_ value.

A value that is neither is KST_PROG_RES_DOUBT.

Parameters
resultThe result code.
Returns
The class of the result, as kst_prog_res_t.

◆ kst_prog_rules()

kst_rules_t kst_prog_rules ( const kst_prog_t * p)

The rules the draft breaks as an edit of the servo's image.

Parameters
pThe programmer state.
Returns
The rules the draft breaks as an edit of the servo image.

◆ kst_prog_run_backup()

const char * kst_prog_run_backup ( const kst_prog_t * p)

The file of that servo; "" for none: no card, or the first write not ended yet.

Parameters
pThe programmer state.
Returns
The file name the run wrote, or an empty string.

◆ kst_prog_run_close()

void kst_prog_run_close ( kst_prog_t * p)

The run is over: the servo stays held for RESTORE, and a later session's first write saves its own file again.

Parameters
pThe programmer state.

◆ kst_prog_run_drop()

void kst_prog_run_drop ( kst_prog_t * p)

Nothing held.

Parameters
pThe programmer state.

◆ kst_prog_run_hold()

bool kst_prog_run_hold ( kst_prog_t * p)

Hold the servo as read now as the run's.

False, and nothing held, with no servo read.

Parameters
pThe programmer state.
Returns
true when the hold was taken, false with no servo read.

◆ kst_prog_run_image()

const kst_image_t * kst_prog_run_image ( const kst_prog_t * p)

The servo the run held, or NULL.

Parameters
pThe programmer state.
Returns
The held image, or NULL when no run holds one.

◆ kst_prog_run_matches()

bool kst_prog_run_matches ( const kst_prog_t * p)

The servo read differs from the run's in LEFT ANGLE, RIGHT ANGLE, PULSE LOWER and PULSE UPPER at most.

Parameters
pThe programmer state.
Returns
true when the servo differs from the held image only in the run fields.

◆ kst_prog_run_written()

void kst_prog_run_written ( kst_prog_t * p)

The run's first write was sent, whether it ended well or not: the file it saved, if any, holds the servo as held.

Parameters
pThe programmer state.

◆ kst_prog_save()

kst_prog_msg_id_t kst_prog_save ( kst_prog_t * p,
const char * name )

Save the servo's image to a new file with name.

The card's side says whether the name is one a file may have; a file is never replaced.

Parameters
pThe programmer state.
nameThe file name.
Returns
The message id.

◆ kst_prog_save_first()

bool kst_prog_save_first ( const kst_prog_t * p)

The next write saves the servo as the session found it to a file first.

A mounted card that does not take the file ends the write. False while a record of an interrupted write is held: the servo may be half written, and the record holds it as found.

Parameters
pThe programmer state.
Returns
true when the next write saves the servo to a file first.

◆ kst_prog_save_none()

bool kst_prog_save_none ( const kst_prog_t * p)

That write goes without the file: no card is mounted, or the servo may hold other values than the session found and the session's backup, the image the file takes then, is not fetched.

Parameters
pThe programmer state.
Returns
true when that write goes without the file.

◆ kst_prog_screen_entry()

void kst_prog_screen_entry ( kst_prog_t * p)

The screen was entered: ENABLE WRITE TO SERVO goes off.

Parameters
pThe programmer state.

◆ kst_prog_servo()

const kst_image_t * kst_prog_servo ( const kst_prog_t * p)

The servo's image as last read.

Parameters
pThe programmer state.
Returns
The servo's image.

◆ kst_prog_soft_base()

const kst_image_t * kst_prog_soft_base ( const kst_prog_t * p)

The image the soft rules compare with: the backup of the IOmcu's session, the servo as the session first read it.

The servo as last read while that backup is not held or is another servo's (kst_prog_backup_other()).

Parameters
pThe programmer state.
Returns
The image the soft rules compare with.

◆ kst_prog_soft_cancel()

void kst_prog_soft_cancel ( kst_prog_t * p)

Drops the waiting soft edit.

Parameters
pThe programmer state.

◆ kst_prog_soft_confirm()

void kst_prog_soft_confirm ( kst_prog_t * p)

Confirms the waiting soft edit.

Parameters
pThe programmer state.

◆ kst_prog_soft_fields()

kst_field_set_t kst_prog_soft_fields ( const kst_prog_t * p,
const kst_image_t * img )

The fields of img that differ from the servo and are at fault for a soft rule: the rule goes when the field takes the value of kst_prog_soft_base().

Parameters
pThe programmer state.
imgThe image to check.
Returns
The fields of img at fault for a soft rule.

◆ kst_prog_soft_image()

const kst_image_t * kst_prog_soft_image ( const kst_prog_t * p)

The image the edit that waits would leave.

Parameters
pThe programmer state.
Returns
The image the waiting edit would leave.

◆ kst_prog_soft_is_load()

bool kst_prog_soft_is_load ( const kst_prog_t * p)

The edit that waits for kst_prog_soft_confirm() is a file.

Parameters
pThe programmer state.
Returns
true when a soft edit waits and it came from a load.

◆ kst_prog_soft_rules()

kst_rules_t kst_prog_soft_rules ( const kst_prog_t * p)

The soft rules the edit that waits asks a confirmation for; 0 while none waits.

They are the rules it breaks and the draft does not, and the rules of a field it moves further from kst_prog_soft_base() than the value last confirmed for that field, or to its other side. A value the servo holds counts as confirmed.

Parameters
pThe programmer state.
Returns
The soft rules the waiting edit asks a confirmation for, or 0.

◆ kst_prog_state()

kst_prog_state_t kst_prog_state ( const kst_prog_t * p)

The programmer state.

Parameters
pThe programmer state.
Returns
The state, as kst_prog_state_t.

◆ kst_prog_step()

kst_prog_edit_t kst_prog_step ( kst_prog_t * p,
kst_field_id_t id,
int dir )

One raw count up (dir above 0) or down.

Parameters
pThe programmer state.
idThe field.
dirThe direction: above 0 counts up, else down.
Returns
The result of the edit.

◆ kst_prog_supply_caps()

void kst_prog_supply_caps ( kst_prog_t * p,
uint16_t max_mv,
uint16_t max_ma )

The highest voltage and current limit the operator lets the supply give (the SUPPLY screen's limits), 0 for none.

kst_prog_connect() is KST_PROG_MSG_SUPPLY_CAPS and asks nothing while a value of kst_prog_supply_set() is above its limit: a session never runs at values other than the ones shown. None after kst_prog_init().

Parameters
pThe programmer state.
max_mvThe highest voltage the supply may give, in mV, or 0 for none.
max_maThe highest current limit, in mA, or 0 for none.

◆ kst_prog_supply_floor()

void kst_prog_supply_floor ( kst_prog_t * p,
uint16_t min_mv )

The lowest voltage a session runs at, mV; 0 for none.

An ENTER lowers a PD mini output that is on to the session's voltage or leaves it, and never raises it: kst_prog_connect() is KST_PROG_MSG_REF + LINK_KST_REF_SUPPLY_LOW and asks nothing while the feed reads an output that is on (supply_read) and set (set_mv) under min_mv. The port of link version 4.15 refuses the same ENTER by that name; an IOmcu built before the refusal takes it, so the panel holds the floor for every peer. None after kst_prog_init().

Parameters
pThe programmer state.
min_mvThe lowest voltage a session runs at, in mV, or 0 for none.

◆ kst_prog_supply_ma()

uint16_t kst_prog_supply_ma ( const kst_prog_t * p)

The current limit an ENTER asks for, in mA.

Parameters
pThe programmer state.
Returns
The current limit, in mA.

◆ kst_prog_supply_mv()

uint16_t kst_prog_supply_mv ( const kst_prog_t * p)

The voltage an ENTER asks for, in mV.

Parameters
pThe programmer state.
Returns
The voltage, in mV.

◆ kst_prog_supply_set()

void kst_prog_supply_set ( kst_prog_t * p,
uint16_t mv,
uint16_t ma )

What an ENTER asks of the PD mini: mv and its current limit ma.

The port checks the range. KST_PROG_SUPPLY_MV and KST_PROG_SUPPLY_MA after kst_prog_init().

Parameters
pThe programmer state.
mvThe voltage an ENTER asks for, in mV.
maThe current limit an ENTER asks for, in mA.

◆ kst_prog_take()

bool kst_prog_take ( kst_prog_t * p,
kst_prog_cmd_t * out )

The next command for the task that owns the link module; false for none.

Parameters
pThe programmer state.
outReceives the command.
Returns
true when a command is taken.

◆ kst_prog_verify()

kst_prog_msg_id_t kst_prog_verify ( kst_prog_t * p)

Asks for a check of the servo's image.

Parameters
pThe programmer state.
Returns
The message for the check.

◆ kst_prog_wait_ms()

uint16_t kst_prog_wait_ms ( const kst_prog_t * p)

The wait before the first PWM pulse.

Parameters
pThe programmer state.
Returns
The wait, in ms.

◆ kst_prog_wait_set()

bool kst_prog_wait_set ( kst_prog_t * p,
uint32_t ms )

The wait between the end of a session and the first PWM pulse, up to KST_PROG_WAIT_MAX_MS.

False, and nothing set, above it.

Parameters
pThe programmer state.
msThe wait, in ms.
Returns
false when ms is above KST_PROG_WAIT_MAX_MS.

◆ kst_prog_write()

kst_prog_msg_id_t kst_prog_write ( kst_prog_t * p)

Write the draft.

The first write of a session saves the servo's image to a file before it and is not sent without one; the journal goes to its file before every write.

Parameters
pThe programmer state.
Returns
The message for the write.

◆ kst_prog_write_check()

kst_prog_msg_id_t kst_prog_write_check ( kst_prog_t * p)

Whether kst_prog_write() would be sent, without sending it.

Parameters
pThe programmer state.
Returns
The message the write would give.

◆ kst_prog_write_enabled()

bool kst_prog_write_enabled ( const kst_prog_t * p)

Whether the write switch is on.

Parameters
pThe programmer state.
Returns
true when ENABLE WRITE TO SERVO is on.

◆ kst_prog_write_steps()

unsigned kst_prog_write_steps ( const kst_prog_t * p)

The registers that write writes, as this model planned it; 0 when no write runs or the IOmcu alone plans it (a restore with no checked order, a release).

The register under way is not on the link page.

Parameters
pThe programmer state.
Returns
The registers the write writes, or 0.

◆ kst_prog_writing()

bool kst_prog_writing ( const kst_prog_t * p)

A write, a restore or a release is on its way or runs under this model: the record of it is no interrupted write yet.

Parameters
pThe programmer state.
Returns
true while a write, restore or release is on its way or runs.