|
K-FSW v1.2.1-59-gcaca356
KFSW: modular flight software on Zephyr, for small satellites
|
Data Structures | |
| struct | kfsw_limits_rule |
| struct | kfsw_limits_status |
Macros | |
| #define | KFSW_LIMITS_PARAM_TABLE_ID 40U |
| #define | KFSW_LIMITS_PARAM_TABLE_NAME "limits" |
| #define | KFSW_LIMITS_FTP_PATH "limits" |
| #define | KFSW_LIMITS_BOUND_TEXT_MAX 24U |
| #define | KFSW_LIMITS_INTERVAL_MIN_MS 100U |
| #define | KFSW_LIMITS_INTERVAL_MAX_MS 3600000U |
| #define | KFSW_LIMITS_DWELL_MAX 255U |
| #define | KFSW_LIMITS_NO_RULE 255U |
Types | |
| typedef bool(* | kfsw_limits_visitor_t) (const struct kfsw_limits_rule *rule, void *context) |
Enumerations | |
| enum | kfsw_limits_event { KFSW_EVENT_LIMITS_FIRED = 1 } |
| enum | kfsw_limits_cmp { KFSW_LIMITS_GT = 0 , KFSW_LIMITS_GE = 1 , KFSW_LIMITS_LT = 2 , KFSW_LIMITS_LE = 3 , KFSW_LIMITS_EQ = 4 , KFSW_LIMITS_NE = 5 } |
Functions | |
| int | kfsw_limits_init (void) |
| int | kfsw_limits_load (const char *name) |
| int | kfsw_limits_sweep (void) |
| int | kfsw_limits_set_interval_ms (uint32_t interval_ms) |
| void | kfsw_limits_get_status (struct kfsw_limits_status *status) |
| void | kfsw_limits_visit_rules (kfsw_limits_visitor_t visitor, void *context) |
| const char * | kfsw_limits_cmp_text (enum kfsw_limits_cmp cmp) |
Variables | |
| uint8_t | kfsw_limits_enabled |
| uint32_t | kfsw_limits_interval_ms |
| const struct kfsw_param_definition_set | kfsw_limits_param_definitions |
Watches local or remote numeric parameters against a bound and releases a command when one is crossed.
The rules live in one text file under the FTP root, uploaded as a procedure is, and read at boot and on command:
The first five whitespace separated fields are the parameter, comparison, bound, dwell and node. Everything after them is the action, a registered command with its arguments, kept as written. A line starting with # is a comment. The parameter may be prefixed with <node>: to read remotely; 0: and this node's own address read locally. The node column still names the action destination. Nonzero prefixes require PARAM_CSP. Remote types and bounds are bound on reading, so the peer may be absent at load. Failed remote reads break the dwell, preserve the latch and release nothing.
A file with any bad line is refused whole and the previous rule set stays in force, so a rule set is never half loaded.
A rule fires once per crossing. It latches when its action is released and re-arms on the first sweep that finds the comparison false. The action goes through kfsw_fbo_schedule_add(), so the release is recorded, may target another node, and has no execution path of its own.
| #define KFSW_LIMITS_BOUND_TEXT_MAX 24U |
#include <limits.h>
Longest bound as written in the file, including the terminator.
| #define KFSW_LIMITS_DWELL_MAX 255U |
#include <limits.h>
Longest dwell a rule may ask for.
| #define KFSW_LIMITS_FTP_PATH "limits" |
#include <limits.h>
Rule files live in this directory of the FTP root.
| #define KFSW_LIMITS_INTERVAL_MAX_MS 3600000U |
#include <limits.h>
Longest periodic sweep.
| #define KFSW_LIMITS_INTERVAL_MIN_MS 100U |
#include <limits.h>
Shortest periodic sweep.
Zero turns the periodic sweep off.
| #define KFSW_LIMITS_NO_RULE 255U |
#include <limits.h>
Value of last_fired_index before any rule has fired.
| #define KFSW_LIMITS_PARAM_TABLE_ID 40U |
#include <limits.h>
Table 40: the counters of this service and its two switches.
| #define KFSW_LIMITS_PARAM_TABLE_NAME "limits" |
#include <limits.h>
Parameter table name.
| typedef bool(* kfsw_limits_visitor_t) (const struct kfsw_limits_rule *rule, void *context) |
#include <limits.h>
Visit the rules in force.
Returning false stops the walk. The rule set is locked during the walk, so a visitor must not call back into this service.
| enum kfsw_limits_cmp |
#include <limits.h>
How a parameter is compared with its bound.
| enum kfsw_limits_event |
| const char * kfsw_limits_cmp_text | ( | enum kfsw_limits_cmp | cmp | ) |
#include <limits.h>
The symbol for a comparison, for listings.
| void kfsw_limits_get_status | ( | struct kfsw_limits_status * | status | ) |
#include <limits.h>
Read the counters.
| int kfsw_limits_init | ( | void | ) |
#include <limits.h>
Read the configured rule file and start the periodic sweep.
A missing file or storage is not a failure: the node simply has no rules until one is loaded.
| 0 | Started, with or without rules. |
| negative | The file exists and could not be loaded; see kfsw_limits_load(). The periodic sweep runs regardless. |
| int kfsw_limits_load | ( | const char * | name | ) |
#include <limits.h>
Replace the rule set with the rules in a file.
| name | File under the rule directory, without a path. |
| 0 | The file was loaded; the streaks and latches of every rule restart. |
| -EINVAL | name is NULL, empty, too long or has a path, or a line of the file is bad. The previous set stays in force and the line is in kfsw_limits_get_status(). |
| -ENODEV | There is no storage. |
| -ENOENT | No such file. |
| -EFBIG | The file is larger than the rule set could be. |
| int kfsw_limits_set_interval_ms | ( | uint32_t | interval_ms | ) |
#include <limits.h>
Change the periodic sweep.
Zero stops it. Returns -ERANGE out of bounds.
| int kfsw_limits_sweep | ( | void | ) |
#include <limits.h>
Evaluate local rules, then remote groups within a bounded time share.
Remote reads may block for half the interval, capped at 5000 ms; a manual sweep with interval zero uses 5000 ms. Deferred remote rules retain their streak and latch and resume next sweep. Do not call from the system workqueue.
| -EACCES | The service is disabled; streaks restart. |
| void kfsw_limits_visit_rules | ( | kfsw_limits_visitor_t | visitor, |
| void * | context | ||
| ) |
#include <limits.h>
Visit the rules in force.
|
extern |
#include <limits.h>
Nonzero lets the sweeps run.
Backs the limits_enabled parameter.
|
extern |
#include <limits.h>
Milliseconds between periodic sweeps.
Backs limits_interval_ms.
|
extern |
#include <limits.h>
Parameter table of this service.