|
K-FSW v1.2.1-59-gcaca356
KFSW: modular flight software on Zephyr, for small satellites
|
Public Headers | |
| file | parameter.h |
Data Structures | |
| union | kfsw_param_scalar |
| struct | kfsw_param_value |
| struct | kfsw_param_info |
| struct | kfsw_param_table_info |
| struct | kfsw_param_definition |
| struct | kfsw_param_definition_set |
| struct | kfsw_param_stats |
Macros | |
| #define | KFSW_PARAM_STRING_MAX CONFIG_KFSW_PARAM_STRING_MAX |
| #define | KFSW_PARAM_WIRE_BYTES 58U |
| #define | KFSW_PARAM_TABLE_WIRE_MAX 2048U |
| #define | KFSW_PARAM_DESCRIPTION_MAX 64U |
| #define | KFSW_PARAM_TABLE_FITS_THE_LINK(definitions) |
| #define | KFSW_PARAM_NAME_MAX 32U |
| #define | KFSW_PARAM_TABLE_INVALID 0U |
| #define | KFSW_PARAM_TABLE_CORE_FIRST 1U |
| #define | KFSW_PARAM_TABLE_CORE_LAST 24U |
| #define | KFSW_PARAM_TABLE_SERVICE_FIRST 25U |
| #define | KFSW_PARAM_TABLE_SERVICE_LAST 49U |
| #define | KFSW_PARAM_TABLE_MODULE_FIRST 50U |
| #define | KFSW_PARAM_TABLE_MODULE_LAST 99U |
| #define | KFSW_PARAM_OFFSET_MAX 255U |
| #define | KFSW_PARAM_FLAG_READ_ONLY 0x00000001UL |
| #define | KFSW_PARAM_FLAG_CONFIGURATION 0x00000004UL |
| #define | KFSW_PARAM_FLAG_SYSTEM_INFO 0x00000040UL |
| #define | KFSW_PARAM_FLAG_DEBUG 0x00000200UL |
| #define | KFSW_PARAM_FLAG_PERSISTENT 0x00010000UL |
| #define | KFSW_PARAM_FLAG_OWNER_STORE 0x00080000UL |
| #define | KFSW_PARAM_FLAG_LIVE 0x00020000UL |
| #define | KFSW_PARAM_FLAG_LOCAL_ONLY 0x00040000UL |
| #define | KFSW_PARAM_ID(table, offset) ((uint16_t)(((uint16_t)(table) << 8) | (uint8_t)(offset))) |
| #define | KFSW_PARAM_PARAM_TABLE_ID 26U |
| #define | KFSW_PARAM_PARAM_TABLE_NAME "param" |
Types | |
| typedef int(* | kfsw_param_validator_t) (const union kfsw_param_scalar *value) |
| typedef int(* | kfsw_param_text_validator_t) (const char *text) |
| typedef int(* | kfsw_param_data_validator_t) (const uint8_t *data, size_t size) |
| typedef int(* | kfsw_param_apply_t) (const union kfsw_param_scalar *value) |
| typedef void(* | kfsw_param_changed_t) (const union kfsw_param_scalar *value) |
| typedef void(* | kfsw_param_text_changed_t) (const char *text) |
| typedef void(* | kfsw_param_data_changed_t) (const uint8_t *data, size_t size) |
| typedef void(* | kfsw_param_sample_t) (void *value) |
| typedef bool(* | kfsw_param_visitor_t) (const struct kfsw_param_info *info, void *context) |
| typedef bool(* | kfsw_param_table_visitor_t) (const struct kfsw_param_table_info *info, void *context) |
Enumerations | |
| enum | kfsw_param_type { KFSW_PARAM_U8 , KFSW_PARAM_U16 , KFSW_PARAM_U32 , KFSW_PARAM_U64 , KFSW_PARAM_I8 , KFSW_PARAM_I16 , KFSW_PARAM_I32 , KFSW_PARAM_I64 , KFSW_PARAM_X8 , KFSW_PARAM_X16 , KFSW_PARAM_X32 , KFSW_PARAM_X64 , KFSW_PARAM_FLOAT , KFSW_PARAM_DOUBLE , KFSW_PARAM_STRING , KFSW_PARAM_DATA , KFSW_PARAM_INVALID } |
Functions | |
| int | kfsw_param_init (const struct kfsw_param_definition_set *const *sets, size_t set_count) |
| bool | kfsw_param_is_initialized (void) |
| int | kfsw_param_parse_text (const char *text, struct kfsw_param_value *value) |
| int | kfsw_param_get (const char *name, struct kfsw_param_value *value) |
| int | kfsw_param_set (const char *name, const struct kfsw_param_value *value) |
| int | kfsw_param_get_by_id (uint16_t id, struct kfsw_param_value *value) |
| int | kfsw_param_get_info (const char *name, struct kfsw_param_info *info) |
| int | kfsw_param_visit (kfsw_param_visitor_t visitor, void *context) |
| int | kfsw_param_visit_tables (kfsw_param_table_visitor_t visitor, void *context) |
| int | kfsw_param_remote_tables (uint16_t node, kfsw_param_table_visitor_t visitor, void *context) |
| size_t | kfsw_param_table_count (void) |
| int | kfsw_param_get_stats (struct kfsw_param_stats *stats) |
| bool | kfsw_param_autosave_enabled (void) |
| const char * | kfsw_param_band_name (uint8_t table) |
| const char * | kfsw_param_mode_name (uint32_t flags) |
| int | kfsw_param_persist_save (void) |
| int | kfsw_param_persist_load (void) |
| int | kfsw_param_persist_clear (void) |
| int | kfsw_param_persist_table_count (uint8_t table, uint16_t *count) |
| uint32_t | kfsw_param_persist_bytes (void) |
| uint32_t | kfsw_param_persist_max_bytes (void) |
| int | kfsw_param_restore_defaults (void) |
| int | kfsw_param_server_start (void) |
| int | kfsw_param_remote_refresh (uint16_t node) |
| int | kfsw_param_remote_get (uint16_t node, const char *name, struct kfsw_param_value *value) |
| int | kfsw_param_remote_get_many (uint16_t node, const char *const *names, size_t count, struct kfsw_param_value *values) |
| int | kfsw_param_remote_get_many_until (uint16_t node, const char *const *names, size_t count, struct kfsw_param_value *values, int64_t deadline) |
| int | kfsw_param_remote_visit_until (uint16_t node, kfsw_param_visitor_t visitor, void *context, int64_t deadline) |
| int | kfsw_param_remote_set (uint16_t node, const char *name, const struct kfsw_param_value *value) |
| int | kfsw_param_remote_visit (uint16_t node, kfsw_param_visitor_t visitor, void *context) |
| int | kfsw_param_remote_visit_table (uint16_t node, uint8_t table, kfsw_param_visitor_t visitor, void *context) |
| const char * | kfsw_param_type_name (enum kfsw_param_type type) |
Variables | |
| const struct kfsw_param_definition_set | kfsw_param_param_definitions |
Local tables and persistence with optional remote CSP access.
Initialize the local table with kfsw_param_init(). The application restores persistence independently of CSP. When CONFIG_KFSW_PARAM_CSP is enabled, kfsw_param_server_start() exposes the same table through the CSP adapter.
| #define KFSW_PARAM_DESCRIPTION_MAX 64U |
#include <parameter.h>
Longest description a parameter or a table may carry.
A remote table listing carries the description on the wire and the receiver holds it in a buffer this size, so a longer one makes the listing fail rather than truncate. It also keeps a param describe line, which starts the description at column 71, inside 140 columns.
| #define KFSW_PARAM_FLAG_CONFIGURATION 0x00000004UL |
#include <parameter.h>
Parameter controls operator-selected configuration.
| #define KFSW_PARAM_FLAG_DEBUG 0x00000200UL |
#include <parameter.h>
Parameter exists for diagnostic or test behavior.
| #define KFSW_PARAM_FLAG_LIVE 0x00020000UL |
#include <parameter.h>
User flag: a write takes effect immediately.
Set for every definition with a change callback; a definition that reads its value every cycle can set it too.
| #define KFSW_PARAM_FLAG_LOCAL_ONLY 0x00040000UL |
#include <parameter.h>
Parameter may be configured locally, but remote writes are refused.
| #define KFSW_PARAM_FLAG_OWNER_STORE 0x00080000UL |
#include <parameter.h>
Owner persists writes; exclude from snapshot save/load and RAM defaults.
| #define KFSW_PARAM_FLAG_PERSISTENT 0x00010000UL |
| #define KFSW_PARAM_FLAG_READ_ONLY 0x00000001UL |
#include <parameter.h>
Parameter cannot be changed through local or remote set operations.
| #define KFSW_PARAM_FLAG_SYSTEM_INFO 0x00000040UL |
#include <parameter.h>
Parameter reports build or runtime system identity.
| #define KFSW_PARAM_ID | ( | table, | |
| offset | |||
| ) | ((uint16_t)(((uint16_t)(table) << 8) | (uint8_t)(offset))) |
#include <parameter.h>
Build the wire ID for a table and offset.
| #define KFSW_PARAM_NAME_MAX 32U |
| #define KFSW_PARAM_OFFSET_MAX 255U |
#include <parameter.h>
Largest offset addressable within one table.
| #define KFSW_PARAM_PARAM_TABLE_ID 26U |
#include <parameter.h>
Parameter table of the parameter service, in the service band.
| #define KFSW_PARAM_PARAM_TABLE_NAME "param" |
#include <parameter.h>
Parameter table name.
| #define KFSW_PARAM_STRING_MAX CONFIG_KFSW_PARAM_STRING_MAX |
#include <parameter.h>
Longest string parameter, including the terminator.
| #define KFSW_PARAM_TABLE_CORE_FIRST 1U |
#include <parameter.h>
First and last table of the application, platform and comms layers.
| #define KFSW_PARAM_TABLE_FITS_THE_LINK | ( | definitions | ) |
#include <parameter.h>
Refuse at build time a table too large for the slowest link.
Place it next to the definition set it guards.
| #define KFSW_PARAM_TABLE_INVALID 0U |
#include <parameter.h>
Table ID bands.
A parameter is addressed by table and offset, and the band shows whether a table is core, service or module. Zero is reserved.
| #define KFSW_PARAM_TABLE_MODULE_FIRST 50U |
#include <parameter.h>
First and last module table.
| #define KFSW_PARAM_TABLE_SERVICE_FIRST 25U |
#include <parameter.h>
First and last service table.
| #define KFSW_PARAM_TABLE_WIRE_MAX 2048U |
#include <parameter.h>
Largest a table may be on the link.
4800 baud is the slowest link this has to work on, and carries 480 bytes a second, so 2 KB is 4.2 seconds: inside the refresh budget with room for a retry. A table that outgrows this is split, not carried.
| #define KFSW_PARAM_WIRE_BYTES 58U |
#include <parameter.h>
Bytes one descriptor takes on the link.
The record without the help text, which is not sent: the ground reads it from the interface document.
| typedef int(* kfsw_param_apply_t) (const union kfsw_param_scalar *value) |
#include <parameter.h>
Apply a validated scalar before committing storage.
Return zero on success or a negative errno without changing owner state on failure. Runs under the table lock and must not call the parameter API. Remote writes must contain only this value. Registry initialization copies defaults without calling this callback.
| typedef void(* kfsw_param_changed_t) (const union kfsw_param_scalar *value) |
#include <parameter.h>
Called after the stored scalar changes.
| typedef void(* kfsw_param_data_changed_t) (const uint8_t *data, size_t size) |
#include <parameter.h>
Called after the stored byte array changes.
| typedef int(* kfsw_param_data_validator_t) (const uint8_t *data, size_t size) |
#include <parameter.h>
Validate the whole proposed byte array; return zero to accept it.
The same side-effect-free contract as the scalar validator applies.
| typedef void(* kfsw_param_sample_t) (void *value) |
#include <parameter.h>
Refresh the stored value just before it is read.
Runs under the table lock, so it must not call the parameter API.
| typedef void(* kfsw_param_text_changed_t) (const char *text) |
#include <parameter.h>
Called after the stored string changes.
| typedef int(* kfsw_param_text_validator_t) (const char *text) |
#include <parameter.h>
Validate a proposed string; return zero to accept it.
Separate from the scalar validator because a string does not fit the scalar union. The same side-effect-free contract applies.
| typedef int(* kfsw_param_validator_t) (const union kfsw_param_scalar *value) |
#include <parameter.h>
Validate a proposed scalar value; return zero to accept it.
Validators must not change stored values or apply side effects. Packet preflight may validate a value and later reject the packet. Apply accepted values in the changed callback instead, or use apply for work that can fail.
| enum kfsw_param_type |
#include <parameter.h>
| Enumerator | |
|---|---|
| KFSW_PARAM_DATA | Fixed-length byte array, such as per-module log levels. |
| bool kfsw_param_autosave_enabled | ( | void | ) |
#include <parameter.h>
Whether an accepted change to a persistent value writes a snapshot.
| const char * kfsw_param_band_name | ( | uint8_t | table | ) |
#include <parameter.h>
Name of the band a table ID falls in.
| int kfsw_param_get_by_id | ( | uint16_t | id, |
| struct kfsw_param_value * | value | ||
| ) |
| int kfsw_param_get_info | ( | const char * | name, |
| struct kfsw_param_info * | info | ||
| ) |
#include <parameter.h>
Read one local parameter's description by name.
| name | Parameter name. | |
| [out] | info | Destination description. |
| 0 | The description was written. |
| -EINVAL | name or info is NULL. |
| -EACCES | The local table is not initialized. |
| -ENOENT | No parameter of that name is registered. |
| int kfsw_param_get_stats | ( | struct kfsw_param_stats * | stats | ) |
| int kfsw_param_init | ( | const struct kfsw_param_definition_set *const * | sets, |
| size_t | set_count | ||
| ) |
#include <parameter.h>
Aggregate, validate, and enable the supplied component definition sets.
| bool kfsw_param_is_initialized | ( | void | ) |
#include <parameter.h>
Return whether the local parameter table was initialized successfully.
| const char * kfsw_param_mode_name | ( | uint32_t | flags | ) |
#include <parameter.h>
Write behaviour implied by a parameter's flags.
How a parameter can be written, as letters.
r read-only w writable p persistent: the value survives a reset b boot: the write is read when the node next starts
The returned pointer is a string literal.
| int kfsw_param_parse_text | ( | const char * | text, |
| struct kfsw_param_value * | value | ||
| ) |
#include <parameter.h>
Read a scalar local parameter by name.
Read a value of this parameter's type from text.
The type in value chooses how the text is read and what range is accepted. The scalar is written only when the whole text parses and fits.
| 0 | on success. |
| -EINVAL | when the text is not a value of that type. |
| -ERANGE | when it does not fit the type. |
| uint32_t kfsw_param_persist_bytes | ( | void | ) |
#include <parameter.h>
Space the last built snapshot occupied, in bytes.
| int kfsw_param_persist_clear | ( | void | ) |
#include <parameter.h>
Delete the active persistent snapshot and any abandoned temporary file.
| int kfsw_param_persist_load | ( | void | ) |
#include <parameter.h>
Load a valid snapshot, ignoring unknown names and incompatible entries.
A snapshot holds only persistent values, and registration refuses a persistent parameter with an apply callback, so no entry applies a fallible scalar. Application errors are returned to the caller.
| uint32_t kfsw_param_persist_max_bytes | ( | void | ) |
#include <parameter.h>
Most space a snapshot is allowed to occupy, in bytes.
| int kfsw_param_persist_save | ( | void | ) |
#include <parameter.h>
Save all explicitly persistent local parameters as one atomic snapshot.
| int kfsw_param_persist_table_count | ( | uint8_t | table, |
| uint16_t * | count | ||
| ) |
#include <parameter.h>
Count persistent parameters in a table.
| table | Table identifier. | |
| [out] | count | Persistent parameters in that table. |
| 0 | Counted. |
| -EINVAL | NULL destination. |
| -ENOENT | No such table. |
| int kfsw_param_remote_get | ( | uint16_t | node, |
| const char * | name, | ||
| struct kfsw_param_value * | value | ||
| ) |
#include <parameter.h>
Read a scalar parameter with the bounded retry policy of kfsw_param_remote_get_many().
| int kfsw_param_remote_get_many | ( | uint16_t | node, |
| const char *const * | names, | ||
| size_t | count, | ||
| struct kfsw_param_value * | values | ||
| ) |
#include <parameter.h>
Read several parameters from one node in as few exchanges as possible.
The whole operation shares one time budget, and each receive is also limited by CONFIG_KFSW_PARAM_TIMEOUT_MS. values must hold count entries. All names are resolved before anything is requested. Returns 0 with every value filled, or an errno if any value is missing. Only -ETIMEDOUT is retried, with at most three total read attempts within the original budget. Earlier batches may be read again; this is not a snapshot.
| int kfsw_param_remote_get_many_until | ( | uint16_t | node, |
| const char *const * | names, | ||
| size_t | count, | ||
| struct kfsw_param_value * | values, | ||
| int64_t | deadline | ||
| ) |
#include <parameter.h>
Same read with an absolute k_uptime_get() deadline, including mutex waits.
| int kfsw_param_remote_refresh | ( | uint16_t | node | ) |
#include <parameter.h>
Refresh a node's indexed v4 list; publish it only after count and CRC verification.
| int kfsw_param_remote_set | ( | uint16_t | node, |
| const char * | name, | ||
| const struct kfsw_param_value * | value | ||
| ) |
#include <parameter.h>
Write a scalar parameter on a selected CSP node.
| int kfsw_param_remote_tables | ( | uint16_t | node, |
| kfsw_param_table_visitor_t | visitor, | ||
| void * | context | ||
| ) |
#include <parameter.h>
Visit the tables another node carries, without its descriptors.
One exchange instead of one for every parameter in them, and the names come from the node, so a table this build does not carry is still named. The description is NULL: it is not carried.
| 0 | when every table was visited. |
| -ENOTSUP | when the node does not answer this request. |
| -EMSGSIZE | when the node has more tables than one reply holds. |
| int kfsw_param_remote_visit | ( | uint16_t | node, |
| kfsw_param_visitor_t | visitor, | ||
| void * | context | ||
| ) |
#include <parameter.h>
Visit a node's descriptors.
Copy borrowed strings before the callback returns.
| int kfsw_param_remote_visit_table | ( | uint16_t | node, |
| uint8_t | table, | ||
| kfsw_param_visitor_t | visitor, | ||
| void * | context | ||
| ) |
#include <parameter.h>
Visit one table of another node.
A whole node does not fit the refresh budget on a slow link; one table does.
| 0 | on success, a negative errno otherwise. |
| -EINVAL | when table is zero. |
| int kfsw_param_remote_visit_until | ( | uint16_t | node, |
| kfsw_param_visitor_t | visitor, | ||
| void * | context, | ||
| int64_t | deadline | ||
| ) |
#include <parameter.h>
Visit within an absolute uptime deadline.
Copy names before returning from the callback. The callback must not call remote PARAM operations or block indefinitely.
| int kfsw_param_restore_defaults | ( | void | ) |
#include <parameter.h>
Restore snapshot parameters to compiled defaults in RAM; owner stores stay.
Registration refuses a persistent parameter with an apply callback, so the reset applies no fallible scalar. Application errors are returned to the caller.
| int kfsw_param_server_start | ( | void | ) |
#include <parameter.h>
Register the optional CSP parameter and parameter-list endpoints once.
| int kfsw_param_set | ( | const char * | name, |
| const struct kfsw_param_value * | value | ||
| ) |
#include <parameter.h>
Write a scalar local parameter after exact type/size validation.
| size_t kfsw_param_table_count | ( | void | ) |
#include <parameter.h>
Registered local tables.
| const char * kfsw_param_type_name | ( | enum kfsw_param_type | type | ) |
#include <parameter.h>
Return a stable printable name for a K-FSW parameter type.
| int kfsw_param_visit | ( | kfsw_param_visitor_t | visitor, |
| void * | context | ||
| ) |
#include <parameter.h>
Visit local parameter descriptions, ordered by table then offset.
| int kfsw_param_visit_tables | ( | kfsw_param_table_visitor_t | visitor, |
| void * | context | ||
| ) |
#include <parameter.h>
Visit each registered local table once, in ascending identifier order.
|
extern |
#include <parameter.h>
Parameter service counters and settings.