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

wa_fetch.h says what the jobs do; fw_release.h how strictly answers are read. More...

#include "wa_fetch.h"
#include <string.h>
#include "fw_sha256.h"

Data Structures

struct  sink_t
struct  sums_t

Functions

void wa_fetch_init (wa_fetch_t *f, fw_version_t running)
wa_why_t wa_fetch_gate (bool armed, bool supply, bool run, bool coproc, bool installing)
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.
bool wa_fetch_busy (const wa_fetch_t *f)
bool wa_fetch_stale (const wa_fetch_t *f, wa_channel_t now)
bool wa_fetch_offers (const wa_fetch_t *f, wa_channel_t now)
static uint32_t budget (const wa_fetch_t *f)
static void end (wa_fetch_t *f, wa_got_t got, wa_why_t why)
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)
uint32_t wa_fetch_left (const wa_fetch_t *f, uint32_t now_ms)
void wa_fetch_abort (wa_fetch_t *f, wa_why_t why)
static void session_off (wa_fetch_t *f, const wa_t *w)
void wa_fetch_tick (wa_fetch_t *f, uint32_t now_ms, wa_why_t abort, const wa_t *w)
bool wa_fetch_take_off (wa_fetch_t *f)
bool wa_fetch_take_run (wa_fetch_t *f)
static bool mine (const wa_fetch_t *f, uint32_t gen)
void wa_fetch_on_phase (wa_fetch_t *f, uint32_t gen, wa_phase_t ph)
void wa_fetch_on_bytes (wa_fetch_t *f, uint32_t gen, uint32_t done, uint32_t total)
static bool got_found (wa_got_t got)
 Whether a CHECK's result names the release it found.
bool wa_fetch_has_found (const wa_fetch_t *f)
 Whether the last job names a release in wa_fetch_t.found.
void wa_fetch_on_end (wa_fetch_t *f, uint32_t gen, const wa_fetch_res_t *r)
static uint32_t run_left (const wa_run_t *r)
static uint32_t op_ms (uint32_t left)
static void report (const wa_run_t *r, wa_phase_t ph, uint32_t done, uint32_t total)
static void res (wa_fetch_res_t *out, wa_got_t got, fw_rel_err_t rel)
static void failed (const wa_run_t *r, wa_fetch_res_t *out, wa_got_t got, fw_rel_err_t rel)
static bool fetch (const wa_run_t *r, const sink_t *k, wa_fetch_res_t *out)
static void found (const wa_run_t *r, wa_fetch_res_t *out, fw_version_t v)
 The result of a check that found release v, offered or not.
static bool api_scan (const wa_run_t *r, uint32_t left, wa_fetch_res_t *out, fw_version_t *v, bool *have_line, fw_version_t *line)
 One request of FW_REL_API_URL, its answer read a piece at a time into the scan until it ends.
static void check_api (const wa_run_t *r, uint32_t left, wa_fetch_res_t *out)
 TESTING: the 10 newest releases by date, their highest offered, or in its place the highest of the panel's release line when that one is offered.
void wa_run_check (const wa_run_t *r, wa_fetch_res_t *out)
static bool sums_begin (const wa_run_t *r, void *ctx, uint32_t bytes, wa_fetch_res_t *out)
static void sums_add (const wa_run_t *r, void *ctx, const uint8_t *d, uint32_t n, uint32_t done, uint32_t total)
static bool image_begin (const wa_run_t *r, void *ctx, uint32_t bytes, wa_fetch_res_t *out)
static void image_add (const wa_run_t *r, void *ctx, const uint8_t *d, uint32_t n, uint32_t done, uint32_t total)
void wa_run_download (const wa_run_t *r, fw_version_t v, wa_fetch_res_t *out)

Detailed Description

wa_fetch.h says what the jobs do; fw_release.h how strictly answers are read.

SPDX-License-Identifier: MIT

Function Documentation

◆ api_scan()

bool api_scan ( const wa_run_t * r,
uint32_t left,
wa_fetch_res_t * out,
fw_version_t * v,
bool * have_line,
fw_version_t * line )
static

One request of FW_REL_API_URL, its answer read a piece at a time into the scan until it ends.

The bytes after the 10th release are not read: the connection closes. A chunked answer has no length to hold it to: it is read until the scan ends, its last chunk, or FW_REL_SCAN_MAX bytes.

Parameters
rthe run
leftms of the budget left
outwhy it failed, on false
vthe highest no-draft release, on true
have_lineset on true: a no-draft release of the line was read
linethe highest of them, when have_line
Returns
true when the answer was read and its scan ended with FW_REL_OK

◆ check_api()

void check_api ( const wa_run_t * r,
uint32_t left,
wa_fetch_res_t * out )
static

TESTING: the 10 newest releases by date, their highest offered, or in its place the highest of the panel's release line when that one is offered.

Parameters
rthe run
leftms of the budget left
outthe result

◆ found()

void found ( const wa_run_t * r,
wa_fetch_res_t * out,
fw_version_t v )
static

The result of a check that found release v, offered or not.

One of the panel's release line newer than the running build is NEWER; a newer one past the line is PAST_LINE; an older or equal one is CURRENT; any with a running version that did not parse is UNVERSIONED.

Parameters
rthe run: the running version
outthe result, with v as its found
vthe release the check found

◆ got_found()

bool got_found ( wa_got_t got)
static

Whether a CHECK's result names the release it found.

Parameters
gotthe result
Returns
true for NEWER, CURRENT, UNVERSIONED and PAST_LINE

◆ wa_fetch_abort()

void wa_fetch_abort ( wa_fetch_t * f,
wa_why_t why )

End the job now for why; nothing when none runs.

◆ wa_fetch_busy()

bool wa_fetch_busy ( const wa_fetch_t * f)

Whether a job runs: joining to checking.

◆ wa_fetch_gate()

wa_why_t wa_fetch_gate ( bool armed,
bool supply,
bool run,
bool coproc,
bool installing )

The gate as wa_gate() takes it, plus the panel's own two.

◆ wa_fetch_has_found()

bool wa_fetch_has_found ( const wa_fetch_t * f)

Whether the last job names a release in wa_fetch_t.found.

Parameters
fthe job; NULL reads as none
Returns
true for a DOWNLOAD, and for a CHECK that ended NEWER, CURRENT, UNVERSIONED or PAST_LINE; false otherwise

◆ wa_fetch_init()

void wa_fetch_init ( wa_fetch_t * f,
fw_version_t running )

No job; running is the build that runs.

◆ wa_fetch_left()

uint32_t wa_fetch_left ( const wa_fetch_t * f,
uint32_t now_ms )

ms of the budget left at now_ms for the phase under way; 0 when it is spent or no job runs.

◆ wa_fetch_offers()

bool wa_fetch_offers ( const wa_fetch_t * f,
wa_channel_t now )

Whether the last job is a CHECK that found a release to offer on channel now: ended NEWER, and run on now. A check on the other channel offers nothing: RELEASES changed after it.

◆ wa_fetch_stale()

bool wa_fetch_stale ( const wa_fetch_t * f,
wa_channel_t now )

Whether the last job is a CHECK that ended on another channel than now: its result is not shown, as if no check had run.

◆ wa_fetch_start()

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 )

Start job at now_ms for release want (DOWNLOAD; ignored by CHECK) on channel ch (CHECK; kept by DOWNLOAD too). WA_GOT_NONE and JOINING: the platform starts the radio in WA_MODE_FETCH. Otherwise the job has ended at once: NO_NET without have_net, BLOCKED for gate or for a job already running (why).

◆ wa_fetch_start_gate()

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.

The radio goes off without waiting for the last job's task: a name lookup under way when the radio goes ends only when lwIP gives up on it, up to about 7s per DNS (Domain Name System) server. Until that task has ended no job starts, so it never runs beside the next job's; a session (WI-FI) starts without waiting for it.

Parameters
gatethe bench's gate (wa_fetch_gate()), or WA_WHY_NONE
takenan image is taken for the install
task_alivethe last job's task has not ended
othera session other than WA_MODE_FETCH asks for the radio
Returns
gate when it is set; WA_WHY_BUSY for any of the other three; WA_WHY_NONE otherwise

◆ wa_fetch_take_off()

bool wa_fetch_take_off ( wa_fetch_t * f)

True once after the job ended: the radio goes off.

◆ wa_fetch_take_run()

bool wa_fetch_take_run ( wa_fetch_t * f)

True once after the join: the runner starts.

◆ wa_fetch_tick()

void wa_fetch_tick ( wa_fetch_t * f,
uint32_t now_ms,
wa_why_t abort,
const wa_t * w )

Once a frame, after wa_tick(): abort as the UI loop sees it now (WA_WHY_NONE for none), w the session. Ends the job for an abort, for the session going off under it and for the budget; moves JOINING on once the session has its address. The platform reads owe_off and owe_run after it.

◆ wa_run_check()

void wa_run_check ( const wa_run_t * r,
wa_fetch_res_t * out )

CHECK, from the join on. NEWER, CURRENT, UNVERSIONED, or why not.

◆ wa_run_download()

void wa_run_download ( const wa_run_t * r,
fw_version_t v,
wa_fetch_res_t * out )

DOWNLOAD of release v, from the join on. STAGED with the image in r->up, or why not with r->up not staged.