rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
arming.h
Go to the documentation of this file.
1
37
38#pragma once
39
40#include <stdbool.h>
41#include <stdint.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
51#define ARMING_TOUCH_DEAD_MS 500u
52
63#define ARMING_LINE_WAIT_MS 200u
64
89
91typedef enum {
92 ARMING_ACT_NONE = 0,
101
102typedef struct {
103 bool armed;
104 bool stopped;
115 uint32_t stops;
122 uint32_t pressed;
134 bool arming;
139 uint8_t roles;
145 uint32_t settle_ms;
154 uint32_t line_wait_ms;
167 bool handshake_bounded;
168 uint32_t last_touch_ms;
169 bool in_run;
170 uint32_t run_start_ms;
172 uint32_t run_seconds;
173} arming_t;
174
184void arming_init(arming_t *a, uint32_t now_ms, uint32_t settle_ms);
185
200void arming_set_line_wait(arming_t *a, uint32_t wait_ms);
201
209bool arming_line_wanted(const arming_t *a, uint32_t now_ms);
210
220void arming_line_report(arming_t *a, bool trusted);
221
233
240void arming_touch_seen(arming_t *a, uint32_t now_ms);
241
249bool arming_touch_dead(const arming_t *a, uint32_t now_ms);
250
259bool arming_stopped(const arming_t *a);
260
270uint32_t arming_stop_count(const arming_t *a);
271
278
286uint32_t arming_pressed_count(const arming_t *a);
287
301void arming_touch_poll(arming_t *a, uint32_t now_ms);
302
310void arming_stop(arming_t *a);
311
313#define ARMING_ROLES_ALL 0xFFu
314
322void arming_request_arm(arming_t *a, uint32_t now_ms);
323
340void arming_request_arm_roles(arming_t *a, uint32_t now_ms, uint8_t roles);
341
348uint8_t arming_roles(const arming_t *a);
349
356
365void arming_refused(arming_t *a);
366
397bool arming_handshake_open(arming_t *a, uint32_t now_ms, bool cleared);
398
415bool arming_write_failed(arming_t *a, bool answered);
416
437
462
517
549 const arming_hs_facts_t *f,
550 uint32_t now_ms);
551
564bool arming_stop_unserved(const arming_t *a, uint32_t *served);
565
572
597 bool bank_armed);
598
610bool arming_link_needed(const arming_t *a, bool bank_armed);
611
627bool arming_link_lost(arming_t *a, bool bank_armed);
628
643bool arming_link_found(arming_t *a, bool bank_armed);
644
652arming_action_t arming_step(arming_t *a, uint32_t now_ms);
653
661bool arming_heartbeat(const arming_t *a, uint32_t now_ms);
662
669uint32_t arming_run_seconds(const arming_t *a);
670
671#ifdef __cplusplus
672}
673#endif
void arming_touch_poll(arming_t *a, uint32_t now_ms)
Sample the touch controller's health, and act on the edge where it dies.
Definition arming.c:312
void arming_request_arm(arming_t *a, uint32_t now_ms)
The operator asked to arm every role: arming_request_arm_roles() with ARMING_ROLES_ALL.
Definition arming.c:114
uint32_t arming_pressed_count(const arming_t *a)
How many of the stops were pressed (arming_stop_pressed()); never more than arming_stop_count() has c...
Definition arming.c:109
bool arming_stop_unserved(const arming_t *a, uint32_t *served)
Whether a stop has been applied that the caller has not let go for yet: true once for every change of...
Definition arming.c:269
void arming_line_report(arming_t *a, bool trusted)
What the far end said: trusted when its monitor believes the line.
Definition arming.c:56
bool arming_link_needed(const arming_t *a, bool bank_armed)
Whether a link going quiet now would be a stop: this end's bank is armed (bank_armed),...
Definition arming.c:289
void arming_touch_seen(arming_t *a, uint32_t now_ms)
The touch controller answered.
Definition arming.c:63
uint32_t arming_run_seconds(const arming_t *a)
Seconds of the current run, or of the last one once it has ended.
Definition arming.c:456
void arming_request_arm_roles(arming_t *a, uint32_t now_ms, uint8_t roles)
The operator asked to arm the outputs of roles, a non-zero set of the caller's role bits; 0 is ignore...
Definition arming.c:124
void arming_stop_pressed(arming_t *a)
A STOP an operator pressed: arming_stop(), counted as pressed too.
Definition arming.c:100
bool arming_touch_dead(const arming_t *a, uint32_t now_ms)
True once touch has been silent for ARMING_TOUCH_DEAD_MS.
Definition arming.c:70
uint8_t arming_roles(const arming_t *a)
The roles of the arm in force or waiting: 0 before any request.
Definition arming.c:119
bool arming_write_failed(arming_t *a, bool answered)
The CLEAR or the frame that arms did not come back acknowledged.
Definition arming.c:194
bool arming_link_found(arming_t *a, bool bank_armed)
A far end started answering.
Definition arming.c:303
void arming_init(arming_t *a, uint32_t now_ms, uint32_t settle_ms)
settle_ms is how long the heartbeat is given to become trustworthy before an arm is written: HEARTBEA...
Definition arming.c:10
bool arming_line_wanted(const arming_t *a, uint32_t now_ms)
Whether the caller is to ask the far end about the line in this pass.
Definition arming.c:42
void arming_set_line_wait(arming_t *a, uint32_t wait_ms)
Make an arm wait for the far end's word on the line, for at most wait_ms past the settle....
Definition arming.c:20
void arming_stop(arming_t *a)
STOP.
Definition arming.c:78
bool arming_handshake_open(arming_t *a, uint32_t now_ms, bool cleared)
Whether the arm arming_step() handed out may still write its next frame, asked before CLEAR (cleared ...
Definition arming.c:176
arming_quiet_t arming_exchange_unanswered(arming_t *a, bool link_up, bool bank_armed)
An exchange with the far end ended with no answer: it waited out its timeout, or its frame did not re...
Definition arming.c:279
bool arming_link_lost(arming_t *a, bool bank_armed)
The far end stopped answering.
Definition arming.c:294
void arming_line_nobody(arming_t *a)
There is no far end to ask in this pass: the next arming_step() lets the settle alone decide,...
Definition arming.c:49
void arming_refused(arming_t *a)
The IOmcu refused the arm.
Definition arming.c:158
uint32_t arming_stop_count(const arming_t *a)
How many stops have been applied.
Definition arming.c:95
arming_hs_t arming_handshake_step(arming_t *a, arming_hs_at_t at, const arming_hs_facts_t *f, uint32_t now_ms)
The next step of writing the arm arming_step() handed out, at at with what the panel learned in f.
Definition arming.c:207
void arming_stop_from_far_end(arming_t *a)
The IOmcu disarmed us: a NACK on a control write, or a failsafe.
Definition arming.c:166
bool arming_stopped(const arming_t *a)
Whether the stop latch is set: a STOP, a dead touch, or the far end.
Definition arming.c:90
bool arming_heartbeat(const arming_t *a, uint32_t now_ms)
Whether the heartbeat may edge.
Definition arming.c:448
arming_action_t arming_step(arming_t *a, uint32_t now_ms)
Advance, and say what the link owes the IOmcu.
Definition arming.c:355
void arming_request_disarm(arming_t *a)
The operator asked to disarm.
Definition arming.c:149
arming_hs_t
What the panel does next with the arm, after arming_handshake_step().
Definition arming.h:466
@ ARMING_HS_SERVO_RATE
The surfaces' rate is not known; the same as ARMING_HS_SERVO_HELD.
Definition arming.h:493
@ ARMING_HS_GO
Go on: at ARMING_HS_HANDED prepare, at ARMING_HS_PREPARED write CLEAR, at ARMING_HS_CLEARED write the...
Definition arming.h:471
@ ARMING_HS_WITHDRAWN
A stop or a disarm landed while CLEAR was on the wire: given up as arming_refused() gives one up.
Definition arming.h:515
@ ARMING_HS_CLOSED
Past the arm's deadline: given up as arming_handshake_open() gives it up, before CLEAR as a refusal a...
Definition arming.h:508
@ ARMING_HS_LOCAL
No link: arm this end's bank for arming_roles(), nothing written.
Definition arming.h:475
@ ARMING_HS_PROG
The servo programmer holds the port: given up as arming_refused() gives one up, nothing written.
Definition arming.h:480
@ ARMING_HS_ENDPOINTS
The throttle's pulse endpoints are not in force at the far end.
Definition arming.h:503
@ ARMING_HS_SERVO_HELD
A servo release the far end has not taken: the arm fails as a write that did not go through,...
Definition arming.h:489
arming_quiet_t
What an exchange with the far end that ended unanswered means; see arming_exchange_unanswered().
Definition arming.h:69
@ ARMING_QUIET_LINK_DOWN
The link is gone.
Definition arming.h:81
@ ARMING_QUIET_NOTHING
The link was already down: a probe nobody answered.
Definition arming.h:75
@ ARMING_QUIET_STOP
The link is gone under an armed bench or a waiting arm: a stop is latched as well,...
Definition arming.h:87
arming_action_t
What the caller must put on the link, if anything, after a step.
Definition arming.h:91
@ ARMING_ACT_GIVE_UP
The far end did not come to trust the line within the bound: the arm is given up, nothing is written,...
Definition arming.h:99
@ ARMING_ACT_DISARM
Definition arming.h:93
@ ARMING_ACT_ARM
Definition arming.h:94
arming_hs_at_t
Where the panel is in writing the arm arming_step() handed out with ARMING_ACT_ARM; see arming_handsh...
Definition arming.h:421
@ ARMING_HS_CLEARED
CLEAR came back acknowledged.
Definition arming.h:431
@ ARMING_HS_PREPARED
The command is zero and the surfaces are asked to centre.
Definition arming.h:425
@ ARMING_HS_ARMED
The frame that arms came back acknowledged: the far end is armed.
Definition arming.h:435
@ ARMING_HS_HANDED
Just handed out: nothing done for it yet.
Definition arming.h:423
What the panel learned for the arm since the last point.
Definition arming.h:439
bool endpoints_blocked
The throttle's pulse endpoints are not known to be in force at the far end: owed (an edit,...
Definition arming.h:460
bool release_owed
Definition arming.h:443
bool link_up
Definition arming.h:440
bool port_taken
Definition arming.h:441
bool disarm_asked
Definition arming.h:451
bool rate_settled
The rate the surfaces run at is known.
Definition arming.h:450
Definition arming.h:102
bool disarm_pending
A disarm owed to something the policy saw between steps.
Definition arming.h:133
uint32_t settle_ms
Definition arming.h:145
uint32_t settle_until_ms
Definition arming.h:146
bool line_nobody
Definition arming.h:156
bool in_run
Definition arming.h:169
uint32_t pressed
Of those, the ones an operator pressed: counted in the same call as the stop, so a reader that sees a...
Definition arming.h:122
uint32_t run_seconds
Definition arming.h:172
uint32_t stops
How many times the bench has been stopped, by any means: a STOP, the far end, or touch that stopped a...
Definition arming.h:115
bool arming
Definition arming.h:134
bool stopped
Definition arming.h:104
bool touch_was_dead
Definition arming.h:123
uint32_t handshake_until_ms
The deadline of the arm arming_step() last handed out, kept for the handshake that writes it: settle ...
Definition arming.h:166
uint32_t line_wait_ms
How long past the settle an arm waits for the far end to report the line trusted; 0 when there is no ...
Definition arming.h:154
uint32_t run_start_ms
Definition arming.h:170
bool switching
A request for other roles found the bench armed: the next step disarms before the arm for them.
Definition arming.h:144
bool line_trusted
Definition arming.h:155
uint8_t roles
The roles of the arm in force or waiting, the caller's bits; see arming_request_arm_roles().
Definition arming.h:139