rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
kst_prog.h
Go to the documentation of this file.
1
72#pragma once
73
74#include <stdatomic.h>
75#include <stdbool.h>
76#include <stddef.h>
77#include <stdint.h>
78
79#include "kst_limits.h"
80#include "kst_link.h"
81#include "kst_plan.h"
82#include "kst_reg.h"
83
84#ifdef __cplusplus
85extern "C" {
86#endif
87
89#define KST_PROG_SUPPLY_MV 5000u
90#define KST_PROG_SUPPLY_MA 1000u
95#define KST_PROG_WAIT_MS 100u
96#define KST_PROG_WAIT_MAX_MS 10000u
98#define KST_PROG_FILE_MAX 400u
103#define KST_PROG_PIN_LAST 47u
104#define KST_PROG_NO_PIN 0xFFu
109#define KST_PROG_START_MS 2000u
116#define KST_PROG_RUN_MS 30000u
124#define KST_PROG_RUN_MAX_MS 120000u
129#define KST_PROG_STORE_MS 3000u
131#define KST_PROG_FETCH_MS 1000u
133#define KST_PROG_FILE_RETRY_MS 5000u
135#define KST_PROG_CARD_MS 5000u
137#define KST_PROG_FILES_MAX 5u
139#define KST_PROG_NAME_MAX 33u
140
152
164typedef unsigned kst_prog_msg_id_t;
165
169enum {
170 KST_PROG_MSG_NONE = 0,
176 KST_PROG_MSG_RESTORED,
177 KST_PROG_MSG_RELEASED,
197 KST_PROG_MSG_NO_CHANGES,
269 KST_PROG_MSG_START = 0x40,
270 KST_PROG_MSG_OUT = 0x50,
271 KST_PROG_MSG_REF = 0x60,
272 KST_PROG_MSG_SES = 0x80,
273 KST_PROG_MSG_END = 0xB0
274};
275
279typedef enum {
280 KST_PROG_INFO = 0,
281 KST_PROG_WARN,
282 KST_PROG_DANGER,
284
288typedef struct {
289 uint8_t id;
290 uint8_t level;
291 uint8_t reg;
292 uint16_t arg;
293 uint32_t seq;
295
302
304typedef enum {
305 KST_PROG_FROM_NONE = 0,
310 KST_PROG_FROM_COUNT
312
314typedef struct {
315 uint8_t from;
316 uint8_t writes;
318 uint8_t stay;
324
332
354
362
366typedef struct {
367 uint8_t op;
368 bool preset;
369 uint32_t id;
371 uint16_t first;
376
380typedef struct {
381 uint32_t id;
382 uint8_t result;
386 /* KST_PROG_CARD_LOAD */
387 uint8_t kind;
388 uint8_t type;
390 uint8_t servo_type;
393 uint8_t named;
394 uint8_t fields;
395 uint8_t field;
397 uint16_t line;
398 uint8_t rule;
401 /* KST_PROG_CARD_LIST */
402 uint8_t count;
403 uint16_t total;
408
419
421typedef struct {
423 uint32_t id;
427
441typedef struct {
442 _Atomic uint32_t pass;
444
457void kst_prog_gate_offer(kst_prog_gate_t *g, uint32_t id);
468bool kst_prog_gate_claim(kst_prog_gate_t *g, uint32_t id);
476bool kst_prog_gate_revoke(kst_prog_gate_t *g, uint32_t id);
477
487
498
500typedef struct {
501 uint32_t now_ms;
503 bool have_image;
504 kst_image_t image;
505 bool have_backup;
506 kst_image_t backup;
507 uint32_t answer_id;
509 uint32_t outcomes;
513 uint16_t out_mv;
514 uint16_t out_ma;
515 uint16_t set_mv;
516 bool stopped;
517 bool armed;
518 bool card;
519 uint8_t card_state;
523 uint8_t target;
532
536typedef struct {
538 bool fed;
539 uint32_t outcomes_seen;
540 uint32_t next_id;
541
542 bool have_servo;
543 bool fp_ok;
546 bool journal;
552 uint8_t journal_pin;
556
557 bool write_enabled;
558 bool written;
560 bool no_file;
562 uint8_t port;
563 uint16_t supply_mv;
564 uint16_t supply_ma;
565 uint16_t caps_mv;
566 uint16_t caps_ma;
567 uint16_t floor_mv;
569 uint16_t pwm_wait_ms;
570
571 uint8_t wait;
572 uint8_t op;
573 uint8_t writes;
574 uint8_t restoring;
576 bool armed;
591 uint32_t wait_ms;
592 uint32_t run_ms;
593 uint32_t fetch_ms;
594 bool fetched;
596 uint32_t wait_id;
606 bool cmd_out;
607 bool cmd_run;
609 bool keep;
615
616 uint8_t card_op;
623 uint8_t load_kind;
624 uint8_t load_named;
625 uint8_t load_fields;
630 uint32_t card_id;
631 uint32_t card_ms;
632 uint32_t late_id;
635 uint8_t files_n;
636 uint16_t files_total;
637 uint16_t files_first;
638 uint16_t card_first;
639 uint32_t files_seq;
641
642 bool soft;
643 kst_image_t soft_img;
644 kst_rules_t soft_rules;
646 uint16_t conf_raw[KST_F_COUNT];
648 uint8_t plan_n;
650
651 bool file_wanted;
652 bool file_busy;
657 uint32_t file_retry_ms;
658 uint8_t file_next;
659 uint8_t file_for;
660
661 /* The limit run (servo_limrun.h): the servo as its first session read
662 * it, kept across its sessions and after it, until the next run. */
663 bool run_hold;
664 bool run_own;
667 kst_image_t run_img;
669
670 kst_prog_msg_t msg;
672} kst_prog_t;
673
680
692
702void kst_prog_feed(kst_prog_t *p, const kst_prog_feed_t *f);
703
713
720
742bool kst_prog_writing(const kst_prog_t *p);
753unsigned kst_prog_write_steps(const kst_prog_t *p);
761bool kst_prog_planning(const kst_prog_t *p);
769
770/* --- what is held --------------------------------------------------------- */
771
778bool kst_prog_have_servo(const kst_prog_t *p);
786bool kst_prog_editable(const kst_prog_t *p);
793const kst_image_t *kst_prog_servo(const kst_prog_t *p);
800const kst_image_t *kst_prog_draft(const kst_prog_t *p);
814uint8_t kst_prog_port(const kst_prog_t *p);
822bool kst_prog_journal(const kst_prog_t *p);
830bool kst_prog_journal_held(const kst_prog_t *p);
873bool kst_prog_backup_other(const kst_prog_t *p);
880uint8_t kst_prog_journal_port(const kst_prog_t *p);
888uint8_t kst_prog_journal_pin(const kst_prog_t *p);
896unsigned kst_prog_journal_arg(const kst_prog_t *p);
904bool kst_prog_in_doubt(const kst_prog_t *p);
912bool kst_prog_first_write(const kst_prog_t *p);
920bool kst_prog_backed_up(const kst_prog_t *p);
927const char *kst_prog_backup_name(const kst_prog_t *p);
938bool kst_prog_no_file(const kst_prog_t *p);
950bool kst_prog_save_first(const kst_prog_t *p);
959bool kst_prog_save_none(const kst_prog_t *p);
960
977unsigned kst_prog_changes(const kst_prog_t *p);
985
986/* --- editing ---------------------------------------------------------------- */
987
1002bool kst_prog_range(const kst_prog_t *p, kst_field_id_t id, uint16_t *lo,
1003 uint16_t *hi);
1004
1058 const kst_image_t *img);
1085
1086/* --- operations: KST_PROG_MSG_NONE when taken, else the message set ------- */
1087
1112void kst_prog_bench_armed(kst_prog_t *p, bool armed);
1137bool kst_prog_holds_port(const kst_prog_t *p);
1148void kst_prog_supply_set(kst_prog_t *p, uint16_t mv, uint16_t ma);
1162void kst_prog_supply_caps(kst_prog_t *p, uint16_t max_mv, uint16_t max_ma);
1178void kst_prog_supply_floor(kst_prog_t *p, uint16_t min_mv);
1185uint16_t kst_prog_supply_mv(const kst_prog_t *p);
1192uint16_t kst_prog_supply_ma(const kst_prog_t *p);
1237bool kst_prog_restore_only(const kst_prog_t *p);
1290 kst_prog_restore_t *out);
1299 const kst_prog_restore_t *plan);
1309/* --- the limit run ----------------------------------------------------------- */
1310
1311/*
1312 * A limit run (servo_limrun.h) programs LEFT ANGLE and RIGHT ANGLE, and
1313 * PULSE LOWER and PULSE UPPER where its SERVO PULSES setting is 1000-2000,
1314 * over many sessions: a session per write. These four are the run's
1315 * fields. The run keeps the servo as its first session read it:
1316 *
1317 * - RESTORE offers it (KST_PROG_FROM_RUN) while the servo read differs
1318 * from it in the run's fields and in no other: an ordinary write of
1319 * those fields, checked as every write is.
1320 * - A later session of the run whose servo differs from it in the run's
1321 * fields at most saves no file before its write: the file of the
1322 * first write holds the servo as the run found it.
1323 *
1324 * The hold is in memory: a start of the panel forgets it.
1325 */
1326
1371const char *kst_prog_run_backup(const kst_prog_t *p);
1380bool kst_prog_run_matches(const kst_prog_t *p);
1381
1404bool kst_prog_wait_set(kst_prog_t *p, uint32_t ms);
1411uint16_t kst_prog_wait_ms(const kst_prog_t *p);
1417void kst_prog_abort(kst_prog_t *p);
1418
1419/* --- servo files ------------------------------------------------------------- */
1420
1432kst_prog_msg_id_t kst_prog_save(kst_prog_t *p, const char *name);
1445kst_prog_msg_id_t kst_prog_files(kst_prog_t *p, unsigned first);
1452unsigned kst_prog_files_first(const kst_prog_t *p);
1465kst_prog_msg_id_t kst_prog_load(kst_prog_t *p, const char *name);
1472bool kst_prog_card_busy(const kst_prog_t *p);
1479uint32_t kst_prog_files_seq(const kst_prog_t *p);
1487const char *kst_prog_file_name(const kst_prog_t *p, unsigned i);
1495unsigned kst_prog_file_type(const kst_prog_t *p, unsigned i);
1504unsigned kst_prog_file_count(const kst_prog_t *p, unsigned *total);
1511const char *kst_prog_preset_name(const kst_prog_t *p);
1518const char *kst_prog_card_name(const kst_prog_t *p);
1535unsigned kst_prog_load_named(const kst_prog_t *p, unsigned *fields);
1551bool kst_prog_soft_is_load(const kst_prog_t *p);
1552
1573
1574/* --- the journal's file ------------------------------------------------------ */
1575
1585size_t kst_prog_file_take(kst_prog_t *p, char *out, size_t n);
1599void kst_prog_file_done(kst_prog_t *p, bool ok);
1610bool kst_prog_file_whole(const char *text, size_t len);
1622bool kst_prog_file_load(kst_prog_t *p, const char *text, size_t len);
1631size_t kst_prog_file_text(const kst_prog_t *p, char *out, size_t n);
1632
1633#ifdef __cplusplus
1634}
1635#endif
KST servo programming protocol: limits on an edited image.
uint64_t kst_rules_t
A set of rules, bit n for rule n.
Definition kst_limits.h:141
KST servo programming protocol: the order of the writes for a change.
const char * kst_prog_backup_name(const kst_prog_t *p)
That file's name; "" while there is none.
Definition kst_prog.c:1711
bool kst_prog_file_load(kst_prog_t *p, const char *text, size_t len)
The file as found at start.
Definition kst_prog_file.c:328
uint16_t kst_prog_supply_mv(const kst_prog_t *p)
The voltage an ENTER asks for, in mV.
Definition kst_prog.c:2077
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 ...
Definition kst_prog.c:2375
const kst_image_t * kst_prog_run_image(const kst_prog_t *p)
The servo the run held, or NULL.
Definition kst_prog.c:2680
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.
Definition kst_prog_card.c:169
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,...
Definition kst_prog.c:2118
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.
Definition kst_prog_card.c:192
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.
Definition kst_prog.c:1400
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.
Definition kst_prog.c:1405
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.
Definition kst_prog.c:1758
kst_prog_msg_id_t kst_prog_write(kst_prog_t *p)
Write the draft.
Definition kst_prog.c:2320
void kst_prog_soft_cancel(kst_prog_t *p)
Drops the waiting soft edit.
Definition kst_prog.c:1947
void kst_prog_discard(kst_prog_t *p)
The draft becomes the servo's image again, and no value counts as confirmed.
Definition kst_prog.c:1958
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 fi...
Definition kst_prog.c:2667
kst_prog_res_t kst_prog_result_class(unsigned result)
The class of result, a kst_ses_t or a LINK_KST_RESULT_ value.
Definition kst_prog.c:998
kst_prog_level_t
The level of a message: information, warning or danger.
Definition kst_prog.h:279
unsigned kst_prog_msg_id_t
What the screen says.
Definition kst_prog.h:164
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.
Definition kst_prog.c:2060
bool kst_prog_card_busy(const kst_prog_t *p)
A save, a list or a load is on its way.
Definition kst_prog_card.c:136
unsigned kst_prog_files_first(const kst_prog_t *p)
The number of the last list's first file among the card's.
Definition kst_prog_card.c:105
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.
Definition kst_prog.c:1706
void kst_prog_supply_floor(kst_prog_t *p, uint16_t min_mv)
The lowest voltage a session runs at, mV; 0 for none.
Definition kst_prog.c:2072
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.
Definition kst_prog.c:1793
void kst_prog_file_done(kst_prog_t *p, bool ok)
How the write of the text kst_prog_file_take() gave went.
Definition kst_prog_file.c:132
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 ...
Definition kst_prog.c:1716
void kst_prog_screen_entry(kst_prog_t *p)
The screen was entered: ENABLE WRITE TO SERVO goes off.
Definition kst_prog.c:1410
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.
Definition kst_prog.c:2734
void kst_prog_forget(kst_prog_t *p)
Discard the journal.
Definition kst_prog.c:2690
const kst_image_t * kst_prog_soft_image(const kst_prog_t *p)
The image the edit that waits would leave.
Definition kst_prog.c:1897
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 fi...
Definition kst_prog.c:402
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,...
Definition kst_prog.c:34
const char * kst_prog_file_name(const kst_prog_t *p, unsigned i)
The names of the last list, i from 0; "" beyond them.
Definition kst_prog_card.c:146
kst_prog_from_t
Where a restore takes its image from.
Definition kst_prog.h:304
@ KST_PROG_FROM_JOURNAL
Definition kst_prog.h:307
@ KST_PROG_FROM_SESSION
Definition kst_prog.h:306
@ KST_PROG_FROM_RUN
Definition kst_prog.h:308
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.
Definition kst_prog.c:1568
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...
Definition kst_prog.c:1752
const char * kst_prog_card_name(const kst_prog_t *p)
The file last saved or asked for.
Definition kst_prog_card.c:174
uint8_t kst_prog_journal_port(const kst_prog_t *p)
The port of the interrupted write, from 0.
Definition kst_prog.c:1685
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),...
Definition kst_prog.c:2066
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.
Definition kst_prog.c:1623
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 interr...
Definition kst_prog.c:1613
void kst_prog_soft_confirm(kst_prog_t *p)
Confirms the waiting soft edit.
Definition kst_prog.c:1931
const kst_image_t * kst_prog_servo(const kst_prog_t *p)
The servo's image as last read.
Definition kst_prog.c:1650
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.
Definition kst_prog_card.c:159
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.
Definition kst_prog_card.c:151
kst_prog_file_kind_t kst_prog_load_kind(const kst_prog_t *p)
What the file last loaded is.
Definition kst_prog_card.c:179
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.
Definition kst_prog.c:1675
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...
Definition kst_prog_file.c:114
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.
Definition kst_prog_file.c:320
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 ou...
Definition kst_prog.c:1695
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.
Definition kst_prog.c:1842
kst_prog_msg_id_t kst_prog_verify(kst_prog_t *p)
Asks for a check of the servo's image.
Definition kst_prog.c:2100
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 wr...
Definition kst_prog.c:862
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,...
Definition kst_prog.c:2031
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 ses...
Definition kst_prog.c:1769
kst_prog_edit_t
What an edit came to.
Definition kst_prog.h:297
@ KST_PROG_EDIT_REFUSED
Definition kst_prog.h:300
@ KST_PROG_EDIT_OK
Definition kst_prog.h:298
@ KST_PROG_EDIT_SOFT
Definition kst_prog.h:299
void kst_prog_abort(kst_prog_t *p)
The operator's cancel.
Definition kst_prog.c:2748
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.
Definition kst_prog.c:1775
kst_prog_cmd_kind_t
The kinds of command the programmer hands to the link module.
Definition kst_prog.h:412
@ KST_PROG_CMD_ABORT
Definition kst_prog.h:414
@ KST_PROG_CMD_START
Definition kst_prog.h:413
@ KST_PROG_CMD_FETCH
Definition kst_prog.h:415
kst_prog_state_t
Where the programmer is.
Definition kst_prog.h:142
@ KST_PROG_NO_PAGE
Definition kst_prog.h:144
@ KST_PROG_SYNC
Definition kst_prog.h:145
@ KST_PROG_WORKING
Definition kst_prog.h:149
@ KST_PROG_PWM
Definition kst_prog.h:146
@ KST_PROG_DOWN
Definition kst_prog.h:143
@ KST_PROG_ENTERING
Definition kst_prog.h:147
@ KST_PROG_PROGRAMMING
Definition kst_prog.h:148
@ KST_PROG_LEAVING
Definition kst_prog.h:150
void kst_prog_gate_offer(kst_prog_gate_t *g, uint32_t id)
The pass of START id is there to be taken.
Definition kst_prog.c:1380
uint16_t kst_prog_wait_ms(const kst_prog_t *p)
The wait before the first PWM pulse.
Definition kst_prog.c:2743
#define KST_PROG_NAME_MAX
A file's name with its terminator.
Definition kst_prog.h:139
kst_prog_card_op_t
What the card's side is asked for.
Definition kst_prog.h:326
@ KST_PROG_CARD_LIST
Definition kst_prog.h:329
@ KST_PROG_CARD_LOAD
Definition kst_prog.h:330
@ KST_PROG_CARD_SAVE
Definition kst_prog.h:328
@ KST_PROG_MSG_JOURNAL_OTHER
Definition kst_prog.h:205
@ KST_PROG_MSG_NEED_TARGET
Definition kst_prog.h:236
@ KST_PROG_MSG_LOAD_REFUSED
Definition kst_prog.h:225
@ KST_PROG_MSG_JOURNAL
Definition kst_prog.h:185
@ KST_PROG_MSG_LOAD_SAME
Definition kst_prog.h:227
@ KST_PROG_MSG_READ
Definition kst_prog.h:171
@ KST_PROG_MSG_CARD_READ
Definition kst_prog.h:210
@ KST_PROG_MSG_LEFT_NO_WAIT
Definition kst_prog.h:242
@ KST_PROG_MSG_NEED_READ
Definition kst_prog.h:199
@ KST_PROG_MSG_UNKNOWN
Definition kst_prog.h:261
@ KST_PROG_MSG_LOAD_VALUE
Definition kst_prog.h:222
@ KST_PROG_MSG_TIMEOUT
Definition kst_prog.h:204
@ KST_PROG_MSG_VERIFIED
Definition kst_prog.h:174
@ KST_PROG_MSG_LOAD_BAD
Definition kst_prog.h:215
@ KST_PROG_MSG_NAME_EXISTS
Definition kst_prog.h:214
@ KST_PROG_MSG_CARD_FULL
Definition kst_prog.h:207
@ KST_PROG_MSG_JOURNAL_DONE
Definition kst_prog.h:192
@ KST_PROG_MSG_LOAD_TYPE
Definition kst_prog.h:219
@ KST_PROG_MSG_NO_FILES
Definition kst_prog.h:211
@ KST_PROG_MSG_FORGOTTEN
Definition kst_prog.h:194
@ KST_PROG_MSG_LOADED
Definition kst_prog.h:231
@ KST_PROG_MSG_LOAD_CHECKSUM
Definition kst_prog.h:217
@ KST_PROG_MSG_NEED_PORT
Definition kst_prog.h:200
@ KST_PROG_MSG_STORE_FAILED
Definition kst_prog.h:182
@ KST_PROG_MSG_RESTORE_REFUSED
Definition kst_prog.h:202
@ KST_PROG_MSG_STOPPED
Definition kst_prog.h:203
@ KST_PROG_MSG_LOADED_EDITED
Definition kst_prog.h:234
@ KST_PROG_MSG_WRITTEN
Definition kst_prog.h:173
@ KST_PROG_MSG_LEFT_DOUBT
Definition kst_prog.h:245
@ KST_PROG_MSG_LEFT
Definition kst_prog.h:178
@ KST_PROG_MSG_CARD_NONE
Definition kst_prog.h:181
@ KST_PROG_MSG_FILE_BAD
Definition kst_prog.h:184
@ KST_PROG_MSG_NEED_ENABLE
Definition kst_prog.h:198
@ KST_PROG_MSG_LOAD_NEWER
Definition kst_prog.h:218
@ KST_PROG_MSG_CARD_WRITE
Definition kst_prog.h:209
@ KST_PROG_MSG_NEED_DISARM
Definition kst_prog.h:250
@ KST_PROG_MSG_READ_ONLY
Definition kst_prog.h:172
@ KST_PROG_MSG_CARD_DENIED
Definition kst_prog.h:266
@ KST_PROG_MSG_EDIT_HARD
Definition kst_prog.h:195
@ KST_PROG_MSG_BACKUP_OTHER
Definition kst_prog.h:253
@ KST_PROG_MSG_SUPPLY_CAPS
Definition kst_prog.h:263
@ KST_PROG_MSG_NO_RESTORE
Definition kst_prog.h:201
@ KST_PROG_MSG_JOURNAL_SAME
Definition kst_prog.h:187
@ KST_PROG_MSG_EDIT_LOCKED
Definition kst_prog.h:196
@ KST_PROG_MSG_SESSION_ENDED
Definition kst_prog.h:256
@ KST_PROG_MSG_VERIFY_DIFF
Definition kst_prog.h:175
@ KST_PROG_MSG_SAVED
Definition kst_prog.h:179
@ KST_PROG_MSG_LOADED_UNTYPED
Definition kst_prog.h:235
@ KST_PROG_MSG_JOURNAL_DIFF
Definition kst_prog.h:193
@ KST_PROG_MSG_NAME_BAD
Definition kst_prog.h:212
@ KST_PROG_MSG_LEAVE_SUPPLY
Definition kst_prog.h:238
@ KST_PROG_MSG_LEAVE_CUT
Definition kst_prog.h:248
@ KST_PROG_MSG_LOAD_SOFT
Definition kst_prog.h:229
kst_prog_state_t kst_prog_state(const kst_prog_t *p)
The programmer state.
Definition kst_prog.c:1598
kst_prog_msg_id_t kst_prog_read(kst_prog_t *p)
Asks for a read of the servo.
Definition kst_prog.c:2087
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.
Definition kst_prog_file.c:85
kst_prog_msg_id_t kst_prog_restore(kst_prog_t *p, const kst_prog_restore_t *plan)
Run the restore prepared.
Definition kst_prog.c:2601
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...
Definition kst_prog.c:1680
kst_prog_file_kind_t
What a file that loads is.
Definition kst_prog.h:356
@ KST_PROG_FILE_VERIFIED
Definition kst_prog.h:357
@ KST_PROG_FILE_UNTYPED
Definition kst_prog.h:359
@ KST_PROG_FILE_EDITED
Definition kst_prog.h:358
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 pl...
Definition kst_prog.c:1618
kst_prog_msg_id_t kst_prog_write_check(kst_prog_t *p)
Whether kst_prog_write() would be sent, without sending it.
Definition kst_prog.c:2285
#define KST_PROG_FILES_MAX
The files a list holds.
Definition kst_prog.h:137
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,...
Definition kst_prog.c:2654
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.
Definition kst_prog.c:2468
void kst_prog_gate_init(kst_prog_gate_t *g)
Sets up a START gate.
Definition kst_prog.c:1375
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().
Definition kst_prog.c:2004
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.
Definition kst_prog.c:2717
kst_prog_msg_id_t kst_prog_load(kst_prog_t *p, const char *name)
Load the file with name into the draft.
Definition kst_prog_card.c:110
bool kst_prog_have_servo(const kst_prog_t *p)
Whether a servo was read.
Definition kst_prog.c:1640
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.
Definition kst_prog.c:1701
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 se...
Definition kst_prog.c:2047
bool kst_prog_soft_is_load(const kst_prog_t *p)
The edit that waits for kst_prog_soft_confirm() is a file.
Definition kst_prog.c:1953
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.
Definition kst_prog.c:1629
uint8_t kst_prog_port(const kst_prog_t *p)
The programming port.
Definition kst_prog.c:1665
kst_prog_res_t
What a result of the session says of a write that ended with it.
Definition kst_prog.h:479
@ KST_PROG_RES_DOUBT
Definition kst_prog.h:485
@ KST_PROG_RES_CLEAN
Definition kst_prog.h:481
@ KST_PROG_RES_OK
Definition kst_prog.h:480
void kst_prog_init(kst_prog_t *p)
Sets up the programmer state.
Definition kst_prog.c:1360
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.
Definition kst_prog.c:1880
const kst_image_t * kst_prog_draft(const kst_prog_t *p)
The draft image being edited.
Definition kst_prog.c:1655
uint32_t kst_prog_files_seq(const kst_prog_t *p)
The sequence number of the file list.
Definition kst_prog_card.c:141
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.
Definition kst_prog.c:2685
kst_prog_msg_id_t kst_prog_enable(kst_prog_t *p, bool on)
The switch.
Definition kst_prog.c:2146
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...
Definition kst_prog.c:2124
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,...
Definition kst_prog_card.c:184
void kst_prog_card_done(kst_prog_t *p, const kst_prog_card_done_t *done)
What the card's side made of it.
Definition kst_prog_card.c:433
kst_prog_msg_id_t kst_prog_release(kst_prog_t *p)
Releases the servo.
Definition kst_prog.c:2356
kst_prog_card_result_t
How it went.
Definition kst_prog.h:334
@ KST_PROG_CARD_CHECKSUM
Definition kst_prog.h:343
@ KST_PROG_CARD_READ_ERR
Definition kst_prog.h:339
@ KST_PROG_CARD_NAME
Definition kst_prog.h:340
@ KST_PROG_CARD_NEWER
Definition kst_prog.h:344
@ KST_PROG_CARD_LIMIT
Definition kst_prog.h:347
@ KST_PROG_CARD_DENIED
Definition kst_prog.h:349
@ KST_PROG_CARD_EXISTS
Definition kst_prog.h:341
@ KST_PROG_CARD_TYPE
Definition kst_prog.h:345
@ KST_PROG_CARD_VALUE
Definition kst_prog.h:346
@ KST_PROG_CARD_BAD
Definition kst_prog.h:342
@ KST_PROG_CARD_FULL
Definition kst_prog.h:337
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.
Definition kst_prog_card.c:64
uint16_t kst_prog_supply_ma(const kst_prog_t *p)
The current limit an ENTER asks for, in mA.
Definition kst_prog.c:2082
void kst_prog_bench_armed(kst_prog_t *p, bool armed)
The bench is armed or asked to arm.
Definition kst_prog.c:2026
unsigned kst_prog_changes(const kst_prog_t *p)
The number of fields the draft differs in.
Definition kst_prog.c:1780
bool kst_prog_run_hold(kst_prog_t *p)
Hold the servo as read now as the run's.
Definition kst_prog.c:2641
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...
Definition kst_prog.c:407
bool kst_prog_write_enabled(const kst_prog_t *p)
Whether the write switch is on.
Definition kst_prog.c:1660
void kst_prog_gate_set(kst_prog_t *p, kst_prog_gate_t *g)
The gate the link's task claims each START at.
Definition kst_prog.c:1370
void kst_prog_feed(kst_prog_t *p, const kst_prog_feed_t *f)
The published state of this frame.
Definition kst_prog.c:1415
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.
Definition kst_prog.c:1645
kst_rules_t kst_prog_rules(const kst_prog_t *p)
The rules the draft breaks as an edit of the servo's image.
Definition kst_prog.c:1785
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.
Definition kst_prog.c:2409
const kst_prog_msg_t * kst_prog_message(const kst_prog_t *p)
The last message.
Definition kst_prog.c:1635
kst_prog_msg_id_t kst_prog_release_check(kst_prog_t *p)
The same for kst_prog_release().
Definition kst_prog.c:2349
void kst_prog_run_drop(kst_prog_t *p)
Nothing held.
Definition kst_prog.c:2672
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.
Definition kst_prog.c:1892
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.
Definition kst_prog.c:1690
bool kst_prog_journal(const kst_prog_t *p)
A write was interrupted and the servo was not compared since.
Definition kst_prog.c:1670
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 t...
Definition kst_prog_card.c:164
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.
Definition kst_prog_card.c:86
KST servo programming protocol: the register image and its fields.
uint64_t kst_field_set_t
A set of fields, bit n for field n.
Definition kst_reg.h:110
kst_field_id_t
Every bit of the 32 registers belongs to exactly one field.
Definition kst_reg.h:61
The 32 registers, by address.
Definition kst_reg.h:47
A plan: the writes that take the servo from start to target.
Definition kst_plan.h:141
The card side's answer to a request.
Definition kst_prog.h:380
uint16_t line
Definition kst_prog.h:397
uint8_t fields
Definition kst_prog.h:394
char name[KST_PROG_NAME_MAX]
Definition kst_prog.h:383
uint8_t field
Definition kst_prog.h:395
uint8_t named
Definition kst_prog.h:393
kst_image_t image
Definition kst_prog.h:399
uint8_t servo_type
Definition kst_prog.h:390
uint16_t total
Definition kst_prog.h:403
uint8_t kind
Definition kst_prog.h:387
uint8_t types[KST_PROG_FILES_MAX]
Definition kst_prog.h:404
kst_field_set_t skipped
Definition kst_prog.h:391
uint8_t result
Definition kst_prog.h:382
uint8_t count
Definition kst_prog.h:402
uint8_t rule
Definition kst_prog.h:398
uint8_t type
Definition kst_prog.h:388
A request to the card side.
Definition kst_prog.h:366
bool preset
Definition kst_prog.h:368
uint8_t op
Definition kst_prog.h:367
uint16_t first
Definition kst_prog.h:371
kst_image_t image
Definition kst_prog.h:373
uint32_t id
Definition kst_prog.h:369
char name[KST_PROG_NAME_MAX]
Definition kst_prog.h:370
One call for the task that owns the link module.
Definition kst_prog.h:421
kst_link_request_t req
Definition kst_prog.h:425
uint32_t id
Definition kst_prog.h:423
What the task that owns the link module publishes, every frame.
Definition kst_prog.h:500
uint32_t answer_id
Definition kst_prog.h:507
bool stopped
Definition kst_prog.h:516
bool card
Definition kst_prog.h:518
uint8_t port_pin_known
Definition kst_prog.h:530
uint8_t target
Definition kst_prog.h:523
uint32_t outcomes
Definition kst_prog.h:509
uint16_t out_ma
Definition kst_prog.h:514
uint16_t set_mv
Definition kst_prog.h:515
bool armed
Definition kst_prog.h:517
kst_link_start_t answer
Definition kst_prog.h:508
bool supply_read
Definition kst_prog.h:511
uint8_t port_pin[LINK_PG_PORTS_MAX]
Definition kst_prog.h:527
kst_link_outcome_t outcome
Definition kst_prog.h:510
uint8_t card_state
Definition kst_prog.h:519
uint16_t out_mv
Definition kst_prog.h:513
The pass a START needs to be carried out.
Definition kst_prog.h:441
_Atomic uint32_t pass
Definition kst_prog.h:442
The last message the programmer says, with its id, level and argument.
Definition kst_prog.h:288
uint32_t seq
Definition kst_prog.h:293
uint16_t arg
Definition kst_prog.h:292
uint8_t id
Definition kst_prog.h:289
uint8_t reg
Definition kst_prog.h:291
uint8_t level
Definition kst_prog.h:290
A restore as kst_prog_restore_plan() prepared it.
Definition kst_prog.h:314
kst_rules_t soft
Definition kst_prog.h:319
bool unchecked
Definition kst_prog.h:322
uint8_t writes
Definition kst_prog.h:316
uint8_t stay
Definition kst_prog.h:318
uint8_t from
Definition kst_prog.h:315
The state of the servo programmer.
Definition kst_prog.h:536
kst_field_set_t held_wrote
Definition kst_prog.h:580
bool fetched
Definition kst_prog.h:594
bool journal
Definition kst_prog.h:546
uint32_t card_ms
Definition kst_prog.h:631
uint16_t files_first
Definition kst_prog.h:637
kst_image_t servo
Definition kst_prog.h:544
uint16_t supply_ma
Definition kst_prog.h:564
uint32_t late_id
Definition kst_prog.h:632
uint32_t wait_ms
Definition kst_prog.h:591
uint8_t wait
Definition kst_prog.h:571
uint32_t wait_id
Definition kst_prog.h:596
bool leave_doubt
Definition kst_prog.h:588
bool run_written
Definition kst_prog.h:666
bool held_no_file
Definition kst_prog.h:561
uint16_t conf_raw[KST_F_COUNT]
Definition kst_prog.h:646
bool armed
Definition kst_prog.h:576
uint16_t caps_mv
Definition kst_prog.h:565
kst_field_set_t wrote_before
Definition kst_prog.h:582
char backup[KST_PROG_NAME_MAX]
Definition kst_prog.h:628
bool need_read
Definition kst_prog.h:549
uint8_t op
Definition kst_prog.h:572
uint8_t plan_n
Definition kst_prog.h:648
kst_image_t keep_draft
Definition kst_prog.h:614
bool run_own
Definition kst_prog.h:664
uint8_t card_op
Definition kst_prog.h:616
char run_backup[KST_PROG_NAME_MAX]
Definition kst_prog.h:668
bool held_over
Definition kst_prog.h:602
bool journal_other
Definition kst_prog.h:548
bool held_journal
Definition kst_prog.h:601
kst_plan_t plan
Definition kst_prog.h:671
uint8_t file_types[KST_PROG_FILES_MAX]
Definition kst_prog.h:622
bool chain_read
Definition kst_prog.h:575
bool cmd_out
Definition kst_prog.h:606
kst_prog_gate_t * gate
Definition kst_prog.h:605
uint16_t floor_mv
Definition kst_prog.h:567
bool cmd_ready
Definition kst_prog.h:597
kst_image_t held_before
Definition kst_prog.h:604
char card_name[KST_PROG_NAME_MAX]
Definition kst_prog.h:626
uint16_t caps_ma
Definition kst_prog.h:566
char preset[KST_PROG_NAME_MAX]
Definition kst_prog.h:627
uint8_t port
Definition kst_prog.h:562
bool card_auto
Definition kst_prog.h:618
uint16_t supply_mv
Definition kst_prog.h:563
bool no_file
Definition kst_prog.h:560
char files[KST_PROG_FILES_MAX][KST_PROG_NAME_MAX]
Definition kst_prog.h:640
kst_image_t journal_img
Definition kst_prog.h:554
bool file_stale
Definition kst_prog.h:653
uint16_t files_total
Definition kst_prog.h:636
uint8_t files_n
Definition kst_prog.h:635
uint32_t fetch_ms
Definition kst_prog.h:593
bool keep_soft_load
Definition kst_prog.h:613
kst_image_t draft
Definition kst_prog.h:545
uint32_t files_seq
Definition kst_prog.h:639
bool journal_open
Definition kst_prog.h:547
uint8_t file_next
Definition kst_prog.h:658
kst_image_t held_target
Definition kst_prog.h:600
kst_field_set_t load_skipped
Definition kst_prog.h:620
bool cmd_run
Definition kst_prog.h:607
kst_image_t journal_target
Definition kst_prog.h:555
kst_link_request_t held
Definition kst_prog.h:599
bool keep
Definition kst_prog.h:609
uint8_t load_named
Definition kst_prog.h:624
bool cmd_fetch
Definition kst_prog.h:595
uint32_t card_id
Number of the card operation on its way; 0 is never used.
Definition kst_prog.h:630
kst_field_set_t soft_skipped
Definition kst_prog.h:621
uint32_t run_ms
Definition kst_prog.h:592
uint8_t file_for
Definition kst_prog.h:659
uint8_t load_kind
Definition kst_prog.h:623
uint8_t journal_port
The programming port the journal's image was read on.
Definition kst_prog.h:551
bool soft_load
Definition kst_prog.h:619
kst_field_set_t conf_set
Definition kst_prog.h:645
kst_image_t late_img
Definition kst_prog.h:634
uint8_t load_fields
Definition kst_prog.h:625
bool file_retry
Definition kst_prog.h:656
uint16_t card_first
Definition kst_prog.h:638
bool wrote_known
Definition kst_prog.h:586
uint8_t writes
Definition kst_prog.h:573
kst_field_set_t wrote
Definition kst_prog.h:577
kst_prog_cmd_t cmd
Definition kst_prog.h:598
uint32_t file_retry_ms
Definition kst_prog.h:657
bool card_ready
Definition kst_prog.h:617
bool keep_soft
Definition kst_prog.h:612
bool backed_up
Definition kst_prog.h:559
uint8_t journal_pin
Definition kst_prog.h:552
uint16_t pwm_wait_ms
Definition kst_prog.h:569
bool written
Definition kst_prog.h:558
uint8_t restoring
Definition kst_prog.h:574