rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
wa_fetch.h
Go to the documentation of this file.
1
51
52#ifndef RCBENCH_WA_FETCH_H
53#define RCBENCH_WA_FETCH_H
54
55#include <stdbool.h>
56#include <stddef.h>
57#include <stdint.h>
58
59#include "fw_image.h"
60#include "fw_release.h"
61#include "fw_upload.h"
62#include "wa_session.h"
63
64#ifdef __cplusplus
65extern "C" {
66#endif
67
69#define WA_FETCH_CHECK_MS 30000u
71#define WA_FETCH_JOIN_MS 30000u
73#define WA_FETCH_DOWNLOAD_MS 180000u
76#define WA_FETCH_OP_MS 10000u
77
78typedef enum {
79 WA_JOB_CHECK = 0,
80 WA_JOB_DOWNLOAD,
81} wa_job_t;
82
88
98
128
144
145typedef struct {
146 wa_job_t job;
148 wa_phase_t phase;
149 wa_got_t got;
154 int status;
155 uint32_t gen;
156 uint32_t start_ms;
157 fw_version_t running;
161 uint32_t done;
162 uint32_t total;
163 uint32_t budget_ms;
164 bool owe_off;
165 bool owe_run;
166} wa_fetch_t;
167
169void wa_fetch_init(wa_fetch_t *f, fw_version_t running);
170
172wa_why_t wa_fetch_gate(bool armed, bool supply, bool run, bool coproc,
173 bool installing);
174
191wa_why_t wa_fetch_start_gate(wa_why_t gate, bool taken, bool task_alive,
192 bool other);
193
201wa_got_t wa_fetch_start(wa_fetch_t *f, wa_job_t job, fw_version_t want,
202 wa_channel_t ch, bool have_net, wa_why_t gate,
203 uint32_t now_ms);
204
210bool wa_fetch_offers(const wa_fetch_t *f, wa_channel_t now);
211
216bool wa_fetch_stale(const wa_fetch_t *f, wa_channel_t now);
217
219bool wa_fetch_busy(const wa_fetch_t *f);
220
227bool wa_fetch_has_found(const wa_fetch_t *f);
228
236void wa_fetch_tick(wa_fetch_t *f, uint32_t now_ms, wa_why_t abort,
237 const wa_t *w);
238
241
246uint32_t wa_fetch_left(const wa_fetch_t *f, uint32_t now_ms);
247
252
254typedef struct {
255 wa_got_t got;
256 wa_why_t why;
257 fw_rel_err_t rel;
258 fw_err_t img;
259 int status;
260 fw_version_t found;
262
263/* What the runner reports, each for job @p gen; a report for another job,
264 * or for one that has ended, is dropped. */
265void wa_fetch_on_phase(wa_fetch_t *f, uint32_t gen, wa_phase_t ph);
266void wa_fetch_on_bytes(wa_fetch_t *f, uint32_t gen, uint32_t done,
267 uint32_t total);
268void wa_fetch_on_end(wa_fetch_t *f, uint32_t gen, const wa_fetch_res_t *r);
269
270/* ---------------------------------------------------------- the runner */
271
279typedef struct {
280 int status;
281 int64_t length;
282 bool chunked;
283 size_t loc_n;
284 bool loc_cut;
286
288typedef struct {
296 bool (*open)(void *ctx, const char *url, uint32_t timeout_ms,
297 bool api, wa_http_head_t *head, char *loc,
298 size_t loc_cap);
302 int32_t (*read)(void *ctx, uint8_t *dst, uint32_t n,
303 uint32_t timeout_ms);
304 void (*close)(void *ctx);
305 void *ctx;
306} wa_http_t;
307
308typedef struct {
309 const wa_http_t *http;
310 uint32_t (*now)(void *ctx);
312 bool (*stopped)(void *ctx);
314 void (*report)(void *ctx, wa_phase_t ph, uint32_t done,
315 uint32_t total);
318 uint8_t *(*alloc)(void *ctx, uint32_t bytes);
319 void *ctx;
320
321 uint32_t start_ms;
322 uint32_t budget_ms;
323 uint32_t slot;
324 fw_version_t running;
327
328 /* Scratch the platform owns, in PSRAM on the panel. */
329 char *url;
330 char *loc;
331 uint8_t *io;
332 uint32_t io_cap;
333 char *sums;
335} wa_run_t;
336
338void wa_run_check(const wa_run_t *r, wa_fetch_res_t *out);
339
345
346#ifdef __cplusplus
347}
348#endif
349
350#endif /* RCBENCH_WA_FETCH_H */
The panel's application image, read from memory: what it is, whether it is whole, and whether it is o...
fw_err_t
Definition fw_image.h:61
What GitHub says about the panel's releases, read strictly.
fw_rel_err_t
Definition fw_release.h:140
Receiving a panel image into memory, as a source hands it over.
An upload into a buffer the caller owns.
Definition fw_upload.h:47
Definition fw_image.h:54
Definition wa_fetch.h:254
Definition wa_fetch.h:145
wa_channel_t channel
Definition wa_fetch.h:147
fw_err_t img
Definition wa_fetch.h:153
fw_version_t found
Definition wa_fetch.h:158
uint32_t done
Definition wa_fetch.h:161
bool owe_off
Definition wa_fetch.h:164
bool owe_run
Definition wa_fetch.h:165
uint32_t budget_ms
Definition wa_fetch.h:163
fw_rel_err_t rel
Definition wa_fetch.h:152
wa_why_t why
Definition wa_fetch.h:150
wa_join_err_t join
Definition wa_fetch.h:151
uint32_t gen
Definition wa_fetch.h:155
int status
Definition wa_fetch.h:154
uint32_t total
Definition wa_fetch.h:162
Definition wa_fetch.h:279
int64_t length
Definition wa_fetch.h:281
int status
Definition wa_fetch.h:280
size_t loc_n
Definition wa_fetch.h:283
bool chunked
Definition wa_fetch.h:282
bool loc_cut
Definition wa_fetch.h:284
Definition wa_fetch.h:288
int32_t(*) read(void *ctx, uint8_t *dst, uint32_t n, uint32_t timeout_ms)
Definition wa_fetch.h:302
bool(*) open(void *ctx, const char *url, uint32_t timeout_ms, bool api, wa_http_head_t *head, char *loc, size_t loc_cap)
Definition wa_fetch.h:296
Definition wa_fetch.h:308
bool(*) stopped(void *ctx)
Definition wa_fetch.h:312
uint32_t slot
Definition wa_fetch.h:323
fw_upload_t * up
Definition wa_fetch.h:334
char * url
Definition wa_fetch.h:329
uint8_t * io
Definition wa_fetch.h:331
bool running_ok
Definition wa_fetch.h:325
uint32_t start_ms
Definition wa_fetch.h:321
wa_channel_t channel
Definition wa_fetch.h:326
void(*) report(void *ctx, wa_phase_t ph, uint32_t done, uint32_t total)
Definition wa_fetch.h:314
char * sums
Definition wa_fetch.h:333
uint32_t budget_ms
Definition wa_fetch.h:322
char * loc
Definition wa_fetch.h:330
A session: what the radio should do, and where it is.
Definition wa_session.h:394
wa_channel_t
Definition wa_fetch.h:84
@ WA_CH_STABLE
Definition wa_fetch.h:85
@ WA_CH_TESTING
Definition wa_fetch.h:86
void wa_fetch_tick(wa_fetch_t *f, uint32_t now_ms, wa_why_t abort, const wa_t *w)
Definition wa_fetch.c:159
void wa_run_check(const wa_run_t *r, wa_fetch_res_t *out)
Definition wa_fetch.c:563
wa_why_t
Definition wa_fetch.h:130
@ WA_WHY_FILES
Definition wa_fetch.h:136
@ WA_WHY_DRAWING
Definition wa_fetch.h:141
@ WA_WHY_COPROC
Definition wa_fetch.h:137
@ WA_WHY_RUN
Definition wa_fetch.h:134
@ WA_WHY_BUSY
Definition wa_fetch.h:140
@ WA_WHY_ARMED
Definition wa_fetch.h:132
@ WA_WHY_SUPPLY
Definition wa_fetch.h:133
@ WA_WHY_INSTALL
Definition wa_fetch.h:138
@ WA_WHY_CANCEL
Definition wa_fetch.h:139
bool wa_fetch_offers(const wa_fetch_t *f, wa_channel_t now)
Definition wa_fetch.c:61
wa_got_t wa_fetch_start(wa_fetch_t *f, wa_job_t job, fw_version_t want, wa_channel_t ch, bool have_net, wa_why_t gate, uint32_t now_ms)
Definition wa_fetch.c:88
void wa_run_download(const wa_run_t *r, fw_version_t v, wa_fetch_res_t *out)
Definition wa_fetch.c:679
bool wa_fetch_has_found(const wa_fetch_t *f)
Whether the last job names a release in wa_fetch_t.found.
Definition wa_fetch.c:236
bool wa_fetch_stale(const wa_fetch_t *f, wa_channel_t now)
Definition wa_fetch.c:55
bool wa_fetch_busy(const wa_fetch_t *f)
Definition wa_fetch.c:50
bool wa_fetch_take_off(wa_fetch_t *f)
Definition wa_fetch.c:190
wa_got_t
Definition wa_fetch.h:100
@ WA_GOT_RADIO
Definition wa_fetch.h:109
@ WA_GOT_STAGED
Definition wa_fetch.h:104
@ WA_GOT_UNVERSIONED
Definition wa_fetch.h:121
@ WA_GOT_TIMEOUT
Definition wa_fetch.h:110
@ WA_GOT_NO_NET
Definition wa_fetch.h:105
@ WA_GOT_NEWER
Definition wa_fetch.h:102
@ WA_GOT_SUMS
Definition wa_fetch.h:114
@ WA_GOT_CURRENT
Definition wa_fetch.h:103
@ WA_GOT_BLOCKED
Definition wa_fetch.h:106
@ WA_GOT_MEMORY
Definition wa_fetch.h:118
@ WA_GOT_UNEXPECTED
Definition wa_fetch.h:113
@ WA_GOT_PAST_LINE
Definition wa_fetch.h:123
@ WA_GOT_IMAGE
Definition wa_fetch.h:117
@ WA_GOT_HASH
Definition wa_fetch.h:116
@ WA_GOT_CONNECT
Definition wa_fetch.h:111
@ WA_GOT_ABORTED
Definition wa_fetch.h:107
@ WA_GOT_JOIN
Definition wa_fetch.h:108
@ WA_GOT_REFUSED
Definition wa_fetch.h:112
@ WA_GOT_LIMIT
Definition wa_fetch.h:119
@ WA_GOT_NONE
Definition wa_fetch.h:101
wa_phase_t
Definition wa_fetch.h:89
@ WA_PH_ASKING
Definition wa_fetch.h:92
@ WA_PH_ENDED
Definition wa_fetch.h:96
@ WA_PH_CHECKING
Definition wa_fetch.h:95
@ WA_PH_SUMS
Definition wa_fetch.h:93
@ WA_PH_JOINING
Definition wa_fetch.h:91
@ WA_PH_IMAGE
Definition wa_fetch.h:94
@ WA_PH_IDLE
Definition wa_fetch.h:90
uint32_t wa_fetch_left(const wa_fetch_t *f, uint32_t now_ms)
Definition wa_fetch.c:120
void wa_fetch_init(wa_fetch_t *f, fw_version_t running)
Definition wa_fetch.c:17
wa_why_t wa_fetch_start_gate(wa_why_t gate, bool taken, bool task_alive, bool other)
The gate a job's start takes, past the bench's own.
Definition wa_fetch.c:41
void wa_fetch_abort(wa_fetch_t *f, wa_why_t why)
Definition wa_fetch.c:130
wa_why_t wa_fetch_gate(bool armed, bool supply, bool run, bool coproc, bool installing)
Definition wa_fetch.c:23
bool wa_fetch_take_run(wa_fetch_t *f)
Definition wa_fetch.c:197
Wi-Fi access: when the panel's radio runs, under which name, and who the page answers.
wa_join_err_t
Why a join failed.
Definition wa_session.h:385