K-FSW v1.2.1-59-gcaca356
KFSW: modular flight software on Zephyr, for small satellites
Loading...
Searching...
No Matches
command.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <kfsw/services/parameter.h>

Data Structures

struct  kfsw_command_stats
 
struct  kfsw_command_claim_state
 
struct  kfsw_command_arg
 
struct  kfsw_command_source
 
struct  kfsw_command_result
 
struct  kfsw_command_definition
 
struct  kfsw_command_definition_set
 
struct  kfsw_command_info
 

Macros

#define KFSW_COMMAND_MAX_ARGS   4U
 
#define KFSW_COMMAND_MAX_TEXT_SIZE   64U
 
#define KFSW_COMMAND_MAX_DETAIL_SIZE   96U
 
#define KFSW_COMMAND_TIMEOUT_MIN_MS   1000U
 
#define KFSW_COMMAND_TIMEOUT_MAX_MS   120000U
 
#define KFSW_COMMAND_FLAG_MUTATING   BIT(0)
 
#define KFSW_COMMAND_CLAIM_NAME_MAX   32U
 
#define KFSW_COMMAND_PARAM_TABLE_ID   28U
 
#define KFSW_COMMAND_PARAM_TABLE_NAME   "command"
 

Types

typedef int(* kfsw_command_handler_t) (const struct kfsw_command_arg *args, size_t arg_count, const struct kfsw_command_source *source, struct kfsw_command_result *result)
 
typedef bool(* kfsw_command_visitor_t) (const struct kfsw_command_info *info, void *context)
 
typedef void(* kfsw_command_echo_handler_t) (bool enabled)
 

Enumerations

enum  kfsw_command_type { KFSW_COMMAND_TYPE_U32 = 1 , KFSW_COMMAND_TYPE_I32 = 2 , KFSW_COMMAND_TYPE_TEXT = 3 }
 
enum  kfsw_command_status {
  KFSW_COMMAND_OK = 0 , KFSW_COMMAND_UNKNOWN = 1 , KFSW_COMMAND_INVALID_ARGUMENT = 2 , KFSW_COMMAND_DENIED = 3 ,
  KFSW_COMMAND_BUSY = 4 , KFSW_COMMAND_FAILED = 5 , KFSW_COMMAND_UNAVAILABLE = 6
}
 
enum  kfsw_event_command_id { KFSW_EVENT_COMMAND_INVOKED = 1 , KFSW_EVENT_COMMAND_UNKNOWN = 2 , KFSW_EVENT_COMMAND_REJECTED = 3 }
 
enum  kfsw_command_claim_mode { KFSW_COMMAND_CLAIM_SHARED = 0 , KFSW_COMMAND_CLAIM_EXCLUSIVE = 1 }
 

Functions

int kfsw_command_init (const struct kfsw_command_definition_set *const *sets, size_t set_count)
 
bool kfsw_command_is_initialized (void)
 
void kfsw_command_visit (kfsw_command_visitor_t visitor, void *context)
 
int kfsw_command_parse_arg (const char *text, enum kfsw_command_type type, struct kfsw_command_arg *arg)
 
int kfsw_command_find (const char *name, struct kfsw_command_info *info)
 
int kfsw_command_invoke (const char *name, const struct kfsw_command_arg *args, size_t arg_count, struct kfsw_command_result *result)
 
int kfsw_command_invoke_id (uint16_t id, const struct kfsw_command_arg *args, size_t arg_count, const struct kfsw_command_source *source, struct kfsw_command_result *result)
 
int kfsw_command_claim_acquire (enum kfsw_command_claim_mode mode, const char *owner)
 
int kfsw_command_claim_release (void)
 
int kfsw_command_claim_get (struct kfsw_command_claim_state *state)
 
const char * kfsw_command_status_name (enum kfsw_command_status status)
 
int kfsw_command_get_stats (struct kfsw_command_stats *stats)
 
void kfsw_command_set_echo_handler (kfsw_command_echo_handler_t handler)
 
bool kfsw_command_echo_enabled (void)
 
void kfsw_command_set_echo (bool enabled)
 

Variables

const struct kfsw_param_definition_set kfsw_command_param_definitions
 

Description

Command registry and its two front ends.

Commands called by name from the shell and by ID over CSP.

Both use the same definition, validation and handler. Definitions are registered at build time, and the registry is fixed before startup ends.