|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
Receiving a panel image into memory, as a source hands it over. More...
Go to the source code of this file.
Data Structures | |
| struct | fw_upload_t |
| An upload into a buffer the caller owns. More... | |
Enumerations | |
| enum | fw_up_state_t { FW_UP_IDLE = 0 , FW_UP_RECEIVING , FW_UP_STAGED , FW_UP_FAILED } |
| Where an upload is. More... | |
Functions | |
| void | fw_upload_init (fw_upload_t *u, uint8_t *buf, uint32_t cap, uint32_t slot) |
An upload into buf of cap bytes, for a slot of slot bytes: IDLE. | |
| fw_err_t | fw_upload_begin (fw_upload_t *u, uint32_t bytes) |
A source announces bytes. | |
| fw_err_t | fw_upload_add (fw_upload_t *u, const uint8_t *data, uint32_t len) |
len more bytes. | |
| fw_err_t | fw_upload_end (fw_upload_t *u, bool whole) |
| The source is done; the image is checked at once. | |
| fw_err_t | fw_upload_seal (fw_upload_t *u, bool whole) |
The first half of fw_upload_end(), for a check run without the caller's lock: the bytes are whole and wait for fw_image_check() over buf and bytes. | |
| fw_err_t | fw_upload_checked (fw_upload_t *u, fw_err_t e, const fw_image_info_t *info) |
| The second half: the answer of the check over a sealed upload. | |
| bool | fw_upload_busy (const fw_upload_t *u) |
| Whether the buffer is in use: bytes arriving, or a check under way. A caller frees the buffer of an upload that is neither this nor STAGED. | |
| void | fw_upload_discard (fw_upload_t *u) |
| Drop what is received or staged: IDLE. During a check, IDLE once fw_upload_checked() has its answer. | |
| unsigned | fw_upload_percent (const fw_upload_t *u) |
| Received of announced. | |
Receiving a panel image into memory, as a source hands it over.
The installer (fw_install.h) takes an image already in memory and knows nothing about where it came from. This is the step before it: a source announces how many bytes it will send, then hands them over in pieces of any size, into a buffer the caller owns (PSRAM, pseudo-static random-access memory, on the panel). The Wi-Fi page's upload is one source; nothing here assumes a network or a file system.
Refused before a byte is stored: an announced size of 0 or larger than the slot, a buffer too small, and a second image while one is being received or waits for the operator. A source that breaks off, or sends more than it announced, leaves nothing staged. A whole image is checked at once (fw_image_check()), so what waits for the operator is an image that can be installed or one that says why not.
Not thread-safe: the platform serialises the calls. No flash is touched.
Pure C, no ESP-IDF (Espressif Internet-of-Things Development Framework).
SPDX-License-Identifier: MIT
| enum fw_up_state_t |
Where an upload is.
| Enumerator | |
|---|---|
| FW_UP_IDLE | nothing received or waiting |
| FW_UP_RECEIVING | bytes are arriving |
| FW_UP_STAGED | a whole image passed fw_image_check() |
| FW_UP_FAILED | the last one was refused: see |
| fw_err_t fw_upload_add | ( | fw_upload_t * | u, |
| const uint8_t * | data, | ||
| uint32_t | len ) |
len more bytes.
| u | the upload |
| data | the bytes |
| len | how many |
| fw_err_t fw_upload_begin | ( | fw_upload_t * | u, |
| uint32_t | bytes ) |
A source announces bytes.
| u | the upload |
| bytes | the image's bytes |
| bool fw_upload_busy | ( | const fw_upload_t * | u | ) |
Whether the buffer is in use: bytes arriving, or a check under way. A caller frees the buffer of an upload that is neither this nor STAGED.
| u | the upload |
| fw_err_t fw_upload_checked | ( | fw_upload_t * | u, |
| fw_err_t | e, | ||
| const fw_image_info_t * | info ) |
The second half: the answer of the check over a sealed upload.
| u | the upload |
| e | what fw_image_check() returned |
| info | what it filled in |
e; FW_ERR_BUSY and IDLE when the upload was discarded during the check, or was not sealed | void fw_upload_discard | ( | fw_upload_t * | u | ) |
Drop what is received or staged: IDLE. During a check, IDLE once fw_upload_checked() has its answer.
| u | the upload |
| fw_err_t fw_upload_end | ( | fw_upload_t * | u, |
| bool | whole ) |
The source is done; the image is checked at once.
| u | the upload |
| whole | false when the source broke off |
| void fw_upload_init | ( | fw_upload_t * | u, |
| uint8_t * | buf, | ||
| uint32_t | cap, | ||
| uint32_t | slot ) |
An upload into buf of cap bytes, for a slot of slot bytes: IDLE.
| u | the upload |
| buf | the buffer, or NULL |
| cap | its bytes |
| slot | the slot's bytes |
| unsigned fw_upload_percent | ( | const fw_upload_t * | u | ) |
Received of announced.
| u | the upload |
| fw_err_t fw_upload_seal | ( | fw_upload_t * | u, |
| bool | whole ) |
The first half of fw_upload_end(), for a check run without the caller's lock: the bytes are whole and wait for fw_image_check() over buf and bytes.
Between this and fw_upload_checked() the state stays RECEIVING and fw_upload_busy() is true, a fw_upload_discard() included: the buffer is the check's, and no caller frees it.
| u | the upload |
| whole | false when the source broke off |
checking set; otherwise what fw_upload_end() returns for the same call, with the same state