rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
busfault_screen.h
1/*
2 * The screen a bad CAN (Controller Area Network) bus gets at start-up.
3 *
4 * The panel runs the echo self-test once, before the bench is usable, and
5 * shows this instead of the menu when the test does not pass. It exists
6 * because the fault it reports is not visible from any other screen: a bus
7 * that does not carry frames looks exactly like an IOmcu that is not
8 * there, and both look like a bench that simply shows no numbers.
9 *
10 * What it puts on the panel is the verdict, the counts behind it, and the
11 * things to check in the order that costs least to check. An operator with
12 * no console and no meter can act on it.
13 *
14 * Leaving it takes a two-second hold, the ARM gesture: this is the one screen
15 * that says the bench cannot be trusted, and an acknowledgement given by
16 * brushing the panel is not one.
17 *
18 * SPDX-License-Identifier: MIT
19 */
20
21#ifndef RCBENCH_BUSFAULT_SCREEN_H
22#define RCBENCH_BUSFAULT_SCREEN_H
23
24#include <stdbool.h>
25#include <stdint.h>
26
27#include "can_selftest.h"
28#include "ui_screen.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
35typedef enum {
37 BUSFAULT_SELFTEST = 0,
44 BUSFAULT_LINK_LOST,
45} busfault_kind_t;
46
54typedef enum {
55 BUSFAULT_BUS_UNKNOWN = 0,
56 BUSFAULT_BUS_RUNNING,
57 BUSFAULT_BUS_RECOVERING,
58 BUSFAULT_BUS_STOPPED,
59 BUSFAULT_BUS_OFF,
60} busfault_bus_t;
61
69typedef struct {
70 busfault_kind_t kind;
71 can_selftest_verdict_t verdict;
72
73 uint32_t sent;
74 uint32_t echoed;
75 uint32_t corrupt;
76 uint32_t lost;
77
78 uint32_t tx_errors;
79 uint32_t rx_errors;
80 uint32_t bus_errors;
81 bool bus_off;
82
83 /* --- BUSFAULT_LINK_LOST only ------------------------------------- */
84 busfault_bus_t bus;
85 uint32_t down_s;
86 uint32_t recoveries;
87 uint32_t polls;
88 uint32_t timeouts;
89
91 bool remote_up;
92 uint8_t remote_tx_errors;
93 uint8_t remote_rx_errors;
94 uint8_t remote_flags;
95 uint16_t remote_overflows;
97
100
103
110bool busfault_screen_take_ack(void);
111
112void busfault_screen_invalidate(void);
113
118const char *busfault_verdict_text(can_selftest_verdict_t v);
119
120const ui_screen_t *busfault_screen(void);
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif /* RCBENCH_BUSFAULT_SCREEN_H */
void busfault_screen_set(const busfault_report_t *r)
Definition busfault_screen.c:142
bool busfault_screen_take_ack(void)
Definition busfault_screen.c:162
const busfault_report_t * busfault_screen_report(void)
Definition busfault_screen.c:157
const char * busfault_verdict_text(can_selftest_verdict_t v)
Definition busfault_screen.c:296
Definition busfault_screen.h:69
uint32_t down_s
Definition busfault_screen.h:85
uint32_t polls
Definition busfault_screen.h:87
uint32_t recoveries
Definition busfault_screen.h:86
bool have_remote
Definition busfault_screen.h:90
busfault_bus_t bus
Definition busfault_screen.h:84
bool remote_up
Definition busfault_screen.h:91
uint32_t tx_errors
Definition busfault_screen.h:78
uint32_t timeouts
Definition busfault_screen.h:88
Definition ui_screen.h:68
Screen router.