|
K-FSW v1.2.1-59-gcaca356
KFSW: modular flight software on Zephyr, for small satellites
|
Data Structures | |
| struct | kfsw_hk_entry |
| struct | kfsw_hk_sample |
| struct | kfsw_hk_stats |
| struct | kfsw_hk_store_info |
| struct | kfsw_hk_store_filter |
Macros | |
| #define | KFSW_HK_PARAM_TABLE_ID 33U |
| #define | KFSW_HK_PARAM_TABLE_NAME "hk" |
| #define | KFSW_HK_PROTOCOL_VERSION 1U |
| #define | KFSW_HK_CLASS_MAX 7U |
| #define | KFSW_HK_CLASS_DEFAULT 4U |
| #define | KFSW_HK_CLASS_MASK_ALL 0xFFU |
| #define | KFSW_HK_REPORT_ALL 0xFFU |
| #define | KFSW_HK_HEADER_SIZE 10U |
| #define | KFSW_HK_FLAG_INCOMPLETE 0x01U |
| #define | KFSW_HK_FLAG_CLOCK_UNSET 0x02U |
| #define | KFSW_HK_NODE_LOCAL 0U |
| #define | KFSW_HK_APPLIED_UNSAVED 1 |
| #define | KFSW_HK_STORE_PATH "/kfsw/hk" |
Functions | |
| int | kfsw_hk_init (void) |
| bool | kfsw_hk_is_ready (void) |
| int | kfsw_hk_save (void) |
| int | kfsw_hk_start (void) |
| int | kfsw_hk_server_start (void) |
| int | kfsw_hk_define (uint8_t report, const struct kfsw_hk_entry *entries, size_t count) |
| int | kfsw_hk_define_class (uint8_t report, const struct kfsw_hk_entry *entries, size_t count, uint8_t retrieval_class) |
| int | kfsw_hk_get_class (uint8_t report, uint8_t *retrieval_class) |
| int | kfsw_hk_get_selected (uint8_t class_mask, uint16_t index, struct kfsw_hk_sample *sample) |
| int | kfsw_hk_clear (uint8_t report) |
| int | kfsw_hk_get_definition (uint8_t report, struct kfsw_hk_entry *entries, size_t *count) |
| int | kfsw_hk_collect (uint8_t report) |
| int | kfsw_hk_get (uint8_t report, uint16_t age, struct kfsw_hk_sample *sample) |
| int | kfsw_hk_depth (uint8_t report, uint16_t *depth) |
| int | kfsw_hk_set_period (uint8_t report, uint32_t period_ms) |
| int | kfsw_hk_get_period (uint8_t report, uint32_t *period_ms) |
| void | kfsw_hk_get_stats (struct kfsw_hk_stats *stats) |
| void | kfsw_hk_set_enabled (bool enabled) |
| int | kfsw_hk_set_store (uint8_t report, uint32_t interval_ms) |
| int | kfsw_hk_set_beacon (uint8_t report, uint16_t node, uint32_t interval_ms) |
| int | kfsw_hk_get_beacon (uint8_t report, uint16_t *node, uint32_t *interval_ms) |
| int | kfsw_hk_clear_store (uint8_t report) |
| int | kfsw_hk_get_store (uint8_t report, uint32_t *interval_ms) |
| bool | kfsw_hk_enabled (void) |
| int | kfsw_hk_store_query (uint8_t report, struct kfsw_hk_store_info *info) |
| int | kfsw_hk_store_count (const struct kfsw_hk_store_filter *filter, uint16_t *records) |
| int | kfsw_hk_store_read (const struct kfsw_hk_store_filter *filter, uint16_t index, struct kfsw_hk_sample *sample) |
| int | kfsw_hk_store_extract (const struct kfsw_hk_store_filter *filter, const char *path, uint16_t *records) |
Variables | |
| const struct kfsw_param_definition_set | kfsw_hk_param_definitions |
| #define KFSW_HK_APPLIED_UNSAVED 1 |
#include <hk.h>
A setting took effect in RAM, but its snapshot could not be saved.
Setters return this value; last_save_error holds the filesystem error. A rejected snapshot is preserved until an explicit kfsw_hk_save().
| #define KFSW_HK_CLASS_MASK_ALL 0xFFU |
#include <hk.h>
All eight retrieval classes selected.
| #define KFSW_HK_CLASS_MAX 7U |
#include <hk.h>
K-FSW retrieval classes: a three-bit value, lower classes retrieved first.
| #define KFSW_HK_FLAG_CLOCK_UNSET 0x02U |
#include <hk.h>
Set when the node's clock was not set, so the timestamp is zero.
Periodic collection waits for the clock, so this only appears on manual collections.
| #define KFSW_HK_FLAG_INCOMPLETE 0x01U |
#include <hk.h>
Set when at least one entry could not be sampled and was zero-filled.
| #define KFSW_HK_HEADER_SIZE 10U |
#include <hk.h>
Bytes before the first value in a serialised sample.
| #define KFSW_HK_NODE_LOCAL 0U |
#include <hk.h>
Node number meaning the local node.
| #define KFSW_HK_PARAM_TABLE_ID 33U |
#include <hk.h>
Housekeeping parameter table.
| #define KFSW_HK_PROTOCOL_VERSION 1U |
#include <hk.h>
Wire format version; other versions are rejected.
| #define KFSW_HK_REPORT_ALL 0xFFU |
#include <hk.h>
Report selector for class-based retrieval across reports.
| #define KFSW_HK_STORE_PATH "/kfsw/hk" |
#include <hk.h>
Where stored samples are kept.
File transfer already serves this directory read-only, so an extract written here is downloadable without anything else.
| int kfsw_hk_clear | ( | uint8_t | report | ) |
#include <hk.h>
Delete a report definition and its samples.
| int kfsw_hk_clear_store | ( | uint8_t | report | ) |
#include <hk.h>
Stop storing a report and delete its file.
Setting the interval to zero stops writing but keeps the file.
| report | Report index. |
| 0 | Stopped, and the file is gone. |
| -EINVAL | Unknown report. |
| int kfsw_hk_collect | ( | uint8_t | report | ) |
#include <hk.h>
Collect a report now.
Blocks while remote values are read. Don't call it from a parameter sample callback, which holds the table lock this needs. Existing samples stay readable meanwhile. Returns -EAGAIN and drops the sample if the definition changed during the collection.
| int kfsw_hk_define | ( | uint8_t | report, |
| const struct kfsw_hk_entry * | entries, | ||
| size_t | count | ||
| ) |
#include <hk.h>
Set the values a report collects, replacing the old definition.
Every parameter must exist and the values must fit one sample. If not, the definition is refused and the previous one stays. Uses class 4 by default.
| int kfsw_hk_define_class | ( | uint8_t | report, |
| const struct kfsw_hk_entry * | entries, | ||
| size_t | count, | ||
| uint8_t | retrieval_class | ||
| ) |
#include <hk.h>
Define a report with a retrieval class (0..7).
Refuses larger values with -ERANGE before changing anything. Replacing a definition discards its history. Class affects retrieval only, never collection or scheduling.
| int kfsw_hk_depth | ( | uint8_t | report, |
| uint16_t * | depth | ||
| ) |
#include <hk.h>
How many samples a report is currently holding.
| bool kfsw_hk_enabled | ( | void | ) |
#include <hk.h>
Whether periodic collection is enabled.
| int kfsw_hk_get | ( | uint8_t | report, |
| uint16_t | age, | ||
| struct kfsw_hk_sample * | sample | ||
| ) |
#include <hk.h>
Read back a collected sample, counting backwards from the newest.
age of 0 is the most recent. Returns -ENOENT past what the ring holds.
| int kfsw_hk_get_beacon | ( | uint8_t | report, |
| uint16_t * | node, | ||
| uint32_t * | interval_ms | ||
| ) |
#include <hk.h>
Read back a report's beacon destination and interval.
| report | Report index. | |
| [out] | node | Destination address. |
| [out] | interval_ms | Milliseconds between beacons, 0 when not beaconing. |
| 0 | Written. |
| -EINVAL | Unknown report or a NULL destination. |
| int kfsw_hk_get_class | ( | uint8_t | report, |
| uint8_t * | retrieval_class | ||
| ) |
#include <hk.h>
Read the class carried by a report definition; -ENOENT when undefined.
| int kfsw_hk_get_definition | ( | uint8_t | report, |
| struct kfsw_hk_entry * | entries, | ||
| size_t * | count | ||
| ) |
#include <hk.h>
Copy a report's definition.
count is in and out.
| int kfsw_hk_get_period | ( | uint8_t | report, |
| uint32_t * | period_ms | ||
| ) |
#include <hk.h>
Read the configured period.
| int kfsw_hk_get_selected | ( | uint8_t | class_mask, |
| uint16_t | index, | ||
| struct kfsw_hk_sample * | sample | ||
| ) |
#include <hk.h>
Read selected RAM samples across reports: lower class first, newest collection first within each class.
Bit n of class_mask selects class n; zero selects nothing. Index counts from zero. Returns -ENOENT past selected history.
| void kfsw_hk_get_stats | ( | struct kfsw_hk_stats * | stats | ) |
#include <hk.h>
Copy the service counters.
| int kfsw_hk_get_store | ( | uint8_t | report, |
| uint32_t * | interval_ms | ||
| ) |
#include <hk.h>
Read back a report's store interval.
| report | Report index. | |
| [out] | interval_ms | Milliseconds between writes, 0 when RAM only. |
| 0 | The interval was written. |
| -EINVAL | Unknown report or NULL destination. |
| int kfsw_hk_init | ( | void | ) |
#include <hk.h>
Prepare the service.
Safe to call before CSP exists.
| bool kfsw_hk_is_ready | ( | void | ) |
#include <hk.h>
True after restore finishes, including diagnostic operation with defaults.
| int kfsw_hk_save | ( | void | ) |
#include <hk.h>
Save current settings explicitly; permits replacing a rejected snapshot.
| int kfsw_hk_server_start | ( | void | ) |
#include <hk.h>
Serve housekeeping requests from other nodes.
Call after the router starts.
| int kfsw_hk_set_beacon | ( | uint8_t | report, |
| uint16_t | node, | ||
| uint32_t | interval_ms | ||
| ) |
#include <hk.h>
Send a report's newest sample to a node periodically.
The frame is the one a request gets, sent without a connection at low priority, and skipped when CSP buffers are short. Nothing is sent while the report is not collecting or the clock is not set.
| report | Report index. |
| node | Destination address. |
| interval_ms | Milliseconds between beacons, or 0 to stop. |
| 0 | Configured. |
| -EINVAL | Unknown report, or an address outside 1..KFSW_CSP_BROADCAST_ADDRESS - 1. |
| -ERANGE | The interval is below CONFIG_KFSW_HK_BEACON_FLOOR_MS. |
| void kfsw_hk_set_enabled | ( | bool | enabled | ) |
#include <hk.h>
Start or stop periodic collection.
Definitions and samples are kept, and manual collection still works.
| enabled | True to collect on each report's period. |
| int kfsw_hk_set_period | ( | uint8_t | report, |
| uint32_t | period_ms | ||
| ) |
#include <hk.h>
Collect this report every period_ms, or stop when it is zero.
| int kfsw_hk_set_store | ( | uint8_t | report, |
| uint32_t | interval_ms | ||
| ) |
#include <hk.h>
Store a report's samples in a file, written every interval_ms.
The interval is capped by the ring depth so no sample is overwritten before it is written.
| report | Report index. |
| interval_ms | Milliseconds between writes, or 0 to keep samples in RAM. |
| 0 | Storage configured. |
| -EINVAL | Unknown report. |
| -ENOENT | The report is not defined. |
| -ERANGE | The interval is below CONFIG_KFSW_HK_STORE_FLOOR_MS. |
| -ENOSPC | The file would not fit. |
| -ENODEV | There is no storage. |
| int kfsw_hk_start | ( | void | ) |
#include <hk.h>
Start collecting reports that have been given a period.
| int kfsw_hk_store_count | ( | const struct kfsw_hk_store_filter * | filter, |
| uint16_t * | records | ||
| ) |
#include <hk.h>
Count the stored records a filter selects.
| filter | What to select. | |
| [out] | records | How many match. |
| int kfsw_hk_store_extract | ( | const struct kfsw_hk_store_filter * | filter, |
| const char * | path, | ||
| uint16_t * | records | ||
| ) |
#include <hk.h>
Write the stored records a filter selects to a file, for downlink.
The file is a 20-byte header (magic KHKD, version, report, record size, record count, the first and last sequence, and a CRC32) followed by the matching records unchanged, so the ground decodes them with the report definition it already has. It is written beside the target and renamed over it, so an interrupted extract leaves the previous file.
| filter | What to select. | |
| path | File to write. | |
| [out] | records | How many were written. May be NULL. |
| 0 | The file holds the selected records. |
| -EINVAL | A NULL argument, or a path that is empty or too long. |
| -ENOENT | Nothing matched, and no file was written. |
| <0 | An errno from the filesystem; any previous file is unchanged. |
| int kfsw_hk_store_query | ( | uint8_t | report, |
| struct kfsw_hk_store_info * | info | ||
| ) |
#include <hk.h>
Read what a report's stored history holds.
| report | Report index. | |
| [out] | info | Destination. |
| 0 | Written. |
| -EINVAL | Unknown report or a NULL destination. |
| -ENODEV | There is no storage. |
| -ENOENT | The report has no file. |
| -EBADMSG | The file is not this report's store. |
| int kfsw_hk_store_read | ( | const struct kfsw_hk_store_filter * | filter, |
| uint16_t | index, | ||
| struct kfsw_hk_sample * | sample | ||
| ) |
#include <hk.h>
Read one stored record a filter selects, oldest first.
The sample is the one kfsw_hk_get would have returned when it was collected, so the same printer and the same remote reply serve both.
| filter | What to select. | |
| index | Position among the matching records, 0 being the oldest. | |
| [out] | sample | Destination. |
| 0 | Written. |
| -ENOENT | Fewer records match than index asks for. |
|
extern |
#include <hk.h>
Definitions this service publishes as parameter table 33.