|
K-FSW ec10f94
Modular flight software on Zephyr, for small satellites
|
#include <stdbool.h>#include <stddef.h>#include <stdint.h>Data Structures | |
| struct | kfsw_csp_info |
| struct | kfsw_csp_interface_info |
| struct | kfsw_csp_counters |
| struct | kfsw_csp_route_info |
| struct | kfsw_csp_interface_stats |
| struct | kfsw_csp_clock |
| struct | kfsw_csp_identity |
Macros | |
| #define | KFSW_CSP_ROUTE_TABLE_MAX_LENGTH 99U |
| #define | KFSW_CSP_SECURE_OVERHEAD 32U |
| #define | KFSW_CSP_PAYLOAD_MAX (CONFIG_CSP_BUFFER_SIZE - KFSW_CSP_SECURE_OVERHEAD) |
| #define | KFSW_CSP_INTERFACE_NAME_SIZE 11U |
| #define | KFSW_CSP_IDENTITY_HOSTNAME_SIZE 21U |
| #define | KFSW_CSP_IDENTITY_MODEL_SIZE 31U |
| #define | KFSW_CSP_IDENTITY_REVISION_SIZE 21U |
| #define | KFSW_CSP_IDENTITY_DATE_SIZE 13U |
| #define | KFSW_CSP_IDENTITY_TIME_SIZE 10U |
Types | |
| typedef bool(* | kfsw_csp_interface_visitor_t) (const struct kfsw_csp_interface_info *interface_info, void *context) |
| typedef bool(* | kfsw_csp_route_visitor_t) (const struct kfsw_csp_route_info *route_info, void *context) |
Functions | |
| void | kfsw_csp_set_packet_trace (bool enabled) |
| bool | kfsw_csp_get_packet_trace (void) |
| void | kfsw_csp_set_revision (const char *revision) |
| int | kfsw_csp_init (void) |
| int | kfsw_csp_start (void) |
| void | kfsw_csp_get_info (struct kfsw_csp_info *info) |
| void | kfsw_csp_visit_interfaces (kfsw_csp_interface_visitor_t visitor, void *context) |
| void | kfsw_csp_visit_routes (kfsw_csp_route_visitor_t visitor, void *context) |
| void | kfsw_csp_get_counters (struct kfsw_csp_counters *counters) |
| void | kfsw_csp_clear_counters (void) |
| const char * | kfsw_csp_error_name (uint8_t code) |
| const char * | kfsw_csp_can_error_name (uint8_t code) |
| int | kfsw_csp_route_table_check (const char *route_table, size_t *entry_count) |
| int | kfsw_csp_route_table_apply (const char *route_table) |
| int | kfsw_csp_ping (uint16_t node, uint32_t timeout_ms, size_t payload_size, uint32_t *round_trip_ms) |
| int | kfsw_csp_interface_stats_read (uint16_t node, const char *name, uint32_t timeout_ms, struct kfsw_csp_interface_stats *stats) |
| void | kfsw_csp_clock_get (struct kfsw_csp_clock *clock) |
| bool | kfsw_csp_clock_is_set (const struct kfsw_csp_clock *clock) |
| int | kfsw_csp_clock_set (const struct kfsw_csp_clock *clock) |
| int | kfsw_csp_clock_read (uint16_t node, uint32_t timeout_ms, struct kfsw_csp_clock *clock) |
| int | kfsw_csp_clock_write (uint16_t node, uint32_t timeout_ms, struct kfsw_csp_clock *clock) |
| int | kfsw_csp_identify (uint16_t node, uint32_t timeout_ms, struct kfsw_csp_identity *identity) |
CSP setup, routes, interfaces and ping.
| #define KFSW_CSP_INTERFACE_NAME_SIZE 11U |
Interface names in CMP have ten characters and a terminator.
| #define KFSW_CSP_PAYLOAD_MAX (CONFIG_CSP_BUFFER_SIZE - KFSW_CSP_SECURE_OVERHEAD) |
Largest application payload that survives every K-FSW transport.
A service that sizes a full packet checks against this and not CSP_BUFFER_SIZE: the encrypted UHF link is the tightest and drops anything longer without reporting it.
| #define KFSW_CSP_ROUTE_TABLE_MAX_LENGTH 99U |
Maximum route-table string length accepted by the pinned libcsp parser.
| #define KFSW_CSP_SECURE_OVERHEAD 32U |
Framing the encrypted UHF link adds inside one CSP buffer: a 12-byte header, a 16-byte tag and a 4-byte checksum.
| const char * kfsw_csp_can_error_name | ( | uint8_t | code | ) |
Name of a kfsw_csp_counters last_can_error code, or "unknown".
| void kfsw_csp_clear_counters | ( | void | ) |
Clear the error counters.
| void kfsw_csp_clock_get | ( | struct kfsw_csp_clock * | clock | ) |
Read this node's RTC clock.
| bool kfsw_csp_clock_is_set | ( | const struct kfsw_csp_clock * | clock | ) |
Whether a clock reading has been set.
| int kfsw_csp_clock_read | ( | uint16_t | node, |
| uint32_t | timeout_ms, | ||
| struct kfsw_csp_clock * | clock | ||
| ) |
Read another node's RTC clock.
Returns 0 and fills clock, or a negative errno. A node whose clock was never set answers zero seconds.
| int kfsw_csp_clock_set | ( | const struct kfsw_csp_clock * | clock | ) |
Set this node's RTC clock.
Returns 0 on success, -ENOTSUP where the composition carries no real-time clock, and -EINVAL for a time the platform will not accept.
| int kfsw_csp_clock_write | ( | uint16_t | node, |
| uint32_t | timeout_ms, | ||
| struct kfsw_csp_clock * | clock | ||
| ) |
Set another node's clock.
clock is filled with the time the node reads back after setting it. The link delay is not compensated.
| const char * kfsw_csp_error_name | ( | uint8_t | code | ) |
Name of a kfsw_csp_counters last_error code, or "unknown".
| void kfsw_csp_get_counters | ( | struct kfsw_csp_counters * | counters | ) |
Copy libcsp's error counters.
Safe before initialization; they read zero.
| void kfsw_csp_get_info | ( | struct kfsw_csp_info * | info | ) |
Copy the current local CSP identity information.
| bool kfsw_csp_get_packet_trace | ( | void | ) |
Whether packet tracing is currently on.
| int kfsw_csp_identify | ( | uint16_t | node, |
| uint32_t | timeout_ms, | ||
| struct kfsw_csp_identity * | identity | ||
| ) |
Ask a remote node to identify itself.
Gets the hostname, model, revision, and build date and time.
| node | Remote CSP address. | |
| timeout_ms | Reply timeout in milliseconds. | |
| [out] | identity | Destination identity. |
| CSP_ERR_NONE | The node answered. |
| CSP_ERR_INVAL | CSP is not running, identity is NULL, or the address is out of range. |
| CSP_ERR_TIMEDOUT | No answer arrived in time. |
| int kfsw_csp_init | ( | void | ) |
Initialize libcsp, the configured interfaces, and static routes once.
| int kfsw_csp_interface_stats_read | ( | uint16_t | node, |
| const char * | name, | ||
| uint32_t | timeout_ms, | ||
| struct kfsw_csp_interface_stats * | stats | ||
| ) |
Read a named interface through CSP management.
Returns 0, -EINVAL for invalid arguments, -ENETDOWN before router start, -ETIMEDOUT for no complete reply (including unknown interfaces), or -EBADMSG for an inconsistent reply. Output is unchanged on failure. The query itself contributes traffic; counters are an observation, not an atomic snapshot.
| int kfsw_csp_ping | ( | uint16_t | node, |
| uint32_t | timeout_ms, | ||
| size_t | payload_size, | ||
| uint32_t * | round_trip_ms | ||
| ) |
Send a standard CSP ping using CRC32 and return its round-trip time.
| int kfsw_csp_route_table_apply | ( | const char * | route_table | ) |
Validate and replace routes after initialization, before router start.
| route_table | Table in libcsp's CIDR syntax. |
| 0 | The table is loaded. |
| CSP_ERR_NOTSUP | The router is running; routes remain unchanged. |
| CSP_ERR_INVAL | CSP is not initialized or the table is invalid. |
| int kfsw_csp_route_table_check | ( | const char * | route_table, |
| size_t * | entry_count | ||
| ) |
Check a route table without applying it.
Returns 0 when the table is well formed, -ENETDOWN when CSP has not been initialised yet and the interfaces a table names do not exist, and a libcsp error otherwise.
| void kfsw_csp_set_packet_trace | ( | bool | enabled | ) |
Print every packet the router receives and every packet this node sends.
Each line has the source and destination node and port, priority, flags and size. Off by default.
| enabled | True to trace, false to stop. |
| void kfsw_csp_set_revision | ( | const char * | revision | ) |
Set the revision this node reports.
Call before CSP is initialised.
| int kfsw_csp_start | ( | void | ) |
Start the CSP router thread.
| void kfsw_csp_visit_interfaces | ( | kfsw_csp_interface_visitor_t | visitor, |
| void * | context | ||
| ) |
Call visitor for each registered interface, under libcsp's lock.
Return false from visitor to stop early.
| void kfsw_csp_visit_routes | ( | kfsw_csp_route_visitor_t | visitor, |
| void * | context | ||
| ) |
Call visitor for each static route.
Return false to stop early.