|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
A store record's configuration by version. More...
#include "out_store_rec.h"#include <string.h>#include "link_crc.h"#include "out_store_map.h"#include "prog_port.h"#include "sense_page.h"#include "supply_page.h"#include "tone_page.h"Functions | |
| size_t | out_store_cfg_size (uint16_t version) |
| Each version appends: its size is where the next version's field starts. | |
| bool | out_store_cfg_read (uint16_t version, const void *cfg, out_store_t *out) |
A record's configuration, as version wrote it at cfg (out_store_cfg_size() bytes), into out at the newest layout. | |
| size_t | out_store_rec_size (uint16_t version) |
A whole record of version, head and configuration: 308 bytes for version 8, 228 for 7. 0 for a version not read. | |
| static uint16_t | rec_crc (const uint8_t *rec, size_t size) |
| The checksum: from the version to the record's end. | |
| static uint32_t | rec_zeros (const uint8_t *rec, size_t size) |
| The 0 bits from the checksum to the record's end: everything but the magic and the count itself. | |
| bool | out_store_rec_build (uint8_t *rec, size_t slot, uint16_t version, uint32_t seq, const out_store_t *cfg) |
A record of version for cfg and seq into the slot bytes at rec: the record, then 0xFF to the slot's end, as an erased slot reads, so a program of the whole slot changes nothing past the record. A save writes OUT_STORE_VERSION; an older version is what an earlier build wrote. False, and nothing written, for a version not read or a record longer than slot. | |
| bool | out_store_rec_check (const uint8_t *rec, size_t avail, uint16_t min_version, uint16_t max_version, uint16_t *version, uint32_t *seq) |
Whether the avail bytes at rec start with a whole record of a version this build reads, from min_version to max_version: magic, version, zero count and checksum. | |
| bool out_store_cfg_read | ( | uint16_t | version, |
| const void * | cfg, | ||
| out_store_t * | out ) |
A record's configuration, as version wrote it at cfg (out_store_cfg_size() bytes), into out at the newest layout.
What the version does not carry starts as its page does: the supply disabled at the module's 19200 baud, both current monitors off at their defaults (sense_page_defaults()), the phase tap off at its defaults (tone_page_defaults()), programming port 0 on PROG_PORT_DEFAULT_PIN and the other ports without a pin (prog_port_defaults()).
False for a version this build does not read, and out is untouched.
| version | Record version the configuration was written with. |
| cfg | The configuration, out_store_cfg_size() bytes. Not NULL. |
| out | Receives the configuration in the newest layout. Not NULL. |
| size_t out_store_cfg_size | ( | uint16_t | version | ) |
Each version appends: its size is where the next version's field starts.
How many bytes of configuration a record of version carries, from the start of an out_store_t: 128 for version 3, 136 for 4, 160 for 5, 176 for 6 (two of them the word prog_func), 208 for 7, 288 for 8. 0 for a version this build does not read.
Each version appends: its size is where the next version's field starts.
| version | Record version, one of the OUT_STORE_VERSION values. |
| bool out_store_rec_build | ( | uint8_t * | rec, |
| size_t | slot, | ||
| uint16_t | version, | ||
| uint32_t | seq, | ||
| const out_store_t * | cfg ) |
A record of version for cfg and seq into the slot bytes at rec: the record, then 0xFF to the slot's end, as an erased slot reads, so a program of the whole slot changes nothing past the record. A save writes OUT_STORE_VERSION; an older version is what an earlier build wrote. False, and nothing written, for a version not read or a record longer than slot.
| rec | Receives the record and the 0xFF fill, slot bytes. |
| slot | Size of the slot in bytes. |
| version | Record version, one of the OUT_STORE_VERSION values. |
| seq | Sequence number stored in the head. |
| cfg | The configuration to store, out_store_cfg_size() bytes of it. |
rec or cfg is NULL, the version is not read, or the record is longer than slot. | bool out_store_rec_check | ( | const uint8_t * | rec, |
| size_t | avail, | ||
| uint16_t | min_version, | ||
| uint16_t | max_version, | ||
| uint16_t * | version, | ||
| uint32_t * | seq ) |
Whether the avail bytes at rec start with a whole record of a version this build reads, from min_version to max_version: magic, version, zero count and checksum.
On true, its version and sequence number. A record longer than avail is no record. The two-page layout takes version 8 alone: a version 7 record that happens to start a two-page slot is the layout before's, read with the rest of its slots.
| rec | The bytes to check. |
| avail | Number of bytes at rec. |
| min_version | Lowest record version accepted. |
| max_version | Highest record version accepted. |
| version | Receives the record's version on true. May be NULL. |
| seq | Receives the record's sequence number on true. May be NULL. |
rec is NULL or avail is below the head size. | size_t out_store_rec_size | ( | uint16_t | version | ) |
A whole record of version, head and configuration: 308 bytes for version 8, 228 for 7. 0 for a version not read.
| version | Record version, one of the OUT_STORE_VERSION values. |
|
static |
The checksum: from the version to the record's end.
| rec | The record, at least size bytes. |
| size | Record size in bytes, from out_store_rec_size(). |
size.
|
static |
The 0 bits from the checksum to the record's end: everything but the magic and the count itself.
| rec | The record, at least size bytes. |
| size | Record size in bytes, from out_store_rec_size(). |
size.