K-FSW v1.2.1-59-gcaca356
KFSW: modular flight software on Zephyr, for small satellites
Loading...
Searching...
No Matches
K-FSW parameter tables as files

Data Structures

struct  kfsw_table_report
 
struct  kfsw_table_status
 

Macros

#define KFSW_TABLE_MAX_ENTRIES   CONFIG_KFSW_TABLE_MAX_ENTRIES
 
#define KFSW_TABLE_PATH_SIZE   64U
 
#define KFSW_TABLE_DIRECTORY   "/kfsw/tables"
 
#define KFSW_TABLE_PARAM_TABLE_ID   37U
 
#define KFSW_TABLE_PARAM_TABLE_NAME   "table"
 

Enumerations

enum  kfsw_table_event { KFSW_EVENT_TABLE_REJECTED = 1 , KFSW_EVENT_TABLE_LOADED = 2 , KFSW_EVENT_TABLE_REVERTED = 3 }
 
enum  kfsw_table_state { KFSW_TABLE_EMPTY = 0 , KFSW_TABLE_LOADED = 1 , KFSW_TABLE_REVERTED = 2 }
 

Functions

int kfsw_table_validate (const char *path, struct kfsw_table_report *report)
 
int kfsw_table_load (const char *path, struct kfsw_table_report *report)
 
int kfsw_table_revert (void)
 
int kfsw_table_dump (uint8_t table, const char *path, uint16_t *entries)
 
int kfsw_table_get_status (struct kfsw_table_status *status)
 
const char * kfsw_table_state_name (enum kfsw_table_state state)
 

Variables

const struct kfsw_param_definition_set kfsw_table_param_definitions
 

Description

A parameter table uploaded as one file, checked completely before any of it takes effect, and undoable afterwards.

The parameter snapshot is the other way of changing many values at once, and it is a different job: the node writes it, it covers whatever is marked persistent across every table, and it is adopted at boot. A table file is written on the ground, addresses one table, and is adopted when an operator says so during a pass. Both use the same value encoding, so one decoder reads either.

Macro Documentation

◆ KFSW_TABLE_DIRECTORY

#define KFSW_TABLE_DIRECTORY   "/kfsw/tables"

#include <table.h>

Where this node keeps table files it writes, and the usual place to upload to.

◆ KFSW_TABLE_MAX_ENTRIES

#define KFSW_TABLE_MAX_ENTRIES   CONFIG_KFSW_TABLE_MAX_ENTRIES

#include <table.h>

Entries one table file may carry.

◆ KFSW_TABLE_PARAM_TABLE_ID

#define KFSW_TABLE_PARAM_TABLE_ID   37U

#include <table.h>

Parameter table of this service.

◆ KFSW_TABLE_PATH_SIZE

#define KFSW_TABLE_PATH_SIZE   64U

#include <table.h>

Longest path kept for the file that was loaded, including the terminator.

Enumeration Documentation

◆ kfsw_table_event

#include <table.h>

Event IDs of this service.

Enumerator
KFSW_EVENT_TABLE_REJECTED 

A file was refused; nothing was applied.

KFSW_EVENT_TABLE_LOADED 

A file was adopted.

KFSW_EVENT_TABLE_REVERTED 

The last load was undone.

◆ kfsw_table_state

#include <table.h>

Whether anything is loaded, and whether it can still be undone.

Enumerator
KFSW_TABLE_EMPTY 

Nothing has been adopted since boot.

KFSW_TABLE_LOADED 

A file is in effect and the values it replaced are still held.

KFSW_TABLE_REVERTED 

The last load has been undone; there is nothing left to revert.

Function Documentation

◆ kfsw_table_dump()

int kfsw_table_dump ( uint8_t  table,
const char *  path,
uint16_t *  entries 
)

#include <table.h>

Write a table's current values out as a table file.

So an operator can fetch what is running, change a value and upload it back rather than composing a file from the manual.

Parameters
tableTable identifier, 1..99.
pathFile to write, usually under KFSW_TABLE_DIRECTORY, which is created if it is missing. Replaced atomically.
[out]entriesEntries written. May be NULL.
Return values
0The file holds the table.
-EINVALtable or path is not usable.
-EACCESThe parameter service is not initialized.
-ENODEVStorage is not mounted.
-ENOENTNo such table is registered.
-E2BIGThe table has more entries than a file may carry.
<0An errno from the filesystem; any previous file is unchanged.

◆ kfsw_table_get_status()

int kfsw_table_get_status ( struct kfsw_table_status *  status)

#include <table.h>

Read a snapshot of the service.

Parameters
[out]statusDestination.
Return values
0Written.
-EINVALstatus is NULL.

◆ kfsw_table_load()

int kfsw_table_load ( const char *  path,
struct kfsw_table_report *  report 
)

#include <table.h>

Adopt a table file.

Validates the whole file first and applies nothing unless every entry passes, so a file with one bad entry leaves the table as it was. The values it replaces are held, so the load can be undone with kfsw_table_revert. A failed application returns its errno and keeps the previous undo values. No physical rollback is attempted.

Parameters
pathFile to read.
[out]reportWhat was applied, or what stopped it. May be NULL.
Returns
The codes of kfsw_table_validate, or the applier's errno.

◆ kfsw_table_revert()

int kfsw_table_revert ( void  )

#include <table.h>

Put back the values the last load replaced.

Values are validated before application. A failed application keeps the undo values for a later retry and returns its errno.

Return values
0The previous values are back.
-ENOENTNothing has been loaded, or the last load was already undone.
-EACCESThe parameter service is not initialized.

◆ kfsw_table_state_name()

const char * kfsw_table_state_name ( enum kfsw_table_state  state)

#include <table.h>

Human-readable name for a state; "unknown" for an unrecognised value.

◆ kfsw_table_validate()

int kfsw_table_validate ( const char *  path,
struct kfsw_table_report *  report 
)

#include <table.h>

Check a table file without applying any of it.

Reads the file, checks its header, its checksum and every entry against the running parameter registry, and reports what it found. A value with a fallible scalar applier must be the file's only entry; mixed files are refused with report reason -ENOTSUP before any application.

Parameters
pathFile to read.
[out]reportWhat the file holds and, on failure, which entry stopped it. May be NULL.
Return values
0Every entry would be accepted.
-EINVALpath is NULL or too long.
-EACCESThe parameter service is not initialized.
-ENODEVStorage is not mounted.
-ENOENTThere is no such file.
-EFBIGThe file is larger than this image can read.
-EBADMSGIt is not a table file, its checksum is wrong, or an entry was refused. report says which and why.
-ENOTSUPIts format version is not the one this image writes.

Variable Documentation

◆ kfsw_table_param_definitions

const struct kfsw_param_definition_set kfsw_table_param_definitions
extern

#include <table.h>

Definitions of this service's own parameters.