F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
fprime.h File Reference

Go to the source code of this file.

Macros

#define WASM_IMPORT(module, name)
 
#define WASM_MODULE_NAME   ("fprime_v1")
 

Enumerations

enum  FprimeTlmValid { FPRIME_TLM_VALID = 0, FPRIME_TLM_INVALID = 1 }
 
enum  FprimeParamValid { FPRIME_PARAM_UNINIT = 0, FPRIME_PARAM_VALID = 1, FPRIME_PARAM_INVALID = 2, FPRIME_PARAM_DEFAULT = 3 }
 
enum  FprimeCmdResponse {
  FPRIME_CMD_OK = 0, FPRIME_CMD_INVALID_OPCODE = 1, FPRIME_CMD_VALIDATION_ERROR = 2, FPRIME_CMD_FORMAT_ERROR = 3,
  FPRIME_CMD_EXECUTION_ERROR = 4, FPRIME_CMD_BUSY = 5, FPRIME_CMD_CLEARED = 5
}
 
enum  FprimeEventSeverity : I32 {
  FPRIME_EVENT_FATAL = 1, FPRIME_EVENT_WARNING_HI = 2, FPRIME_EVENT_WARNING_LO = 3, FPRIME_EVENT_COMMAND = 4,
  FPRIME_EVENT_ACTIVITY_HI = 5, FPRIME_EVENT_ACTIVITY_LO = 6, FPRIME_EVENT_DIAGNOSTIC = 7
}
 
enum  FprimeBlockingType { FPRIME_BLOCK_BLOCKING = 0, FPRIME_BLOCK_NONBLOCKING = 1 }
 
enum  FprimeQueueStatus { FPRIME_QUEUE_OK = 0, FPRIME_QUEUE_EMPTY = 1 }
 

Functions

void fprime_wasm_exit (I32 code)
 Exit the current Wasm program with a return code. This function does not return. More...
 
void fprime_wasm_panic (I32 code)
 Exit the current Wasm program with a failure. This function does not return. More...
 
U32 fprime_wasm_get_args (U32 destination_ptr, U32 destination_size)
 Get the sequence arguments this sequence was invoked with This function will write the arguments provided from the invoke/run into the guest memory. More...
 
void fprime_wasm_get_time (U32 time_ptr, U32 time_size)
 Read the current F´ system time into guest memory. More...
 
FprimeTlmValid fprime_wasm_read_telemetry (I64 id, U32 time_ptr, U32 time_size, U32 value_ptr, U32 value_size)
 Read a telemetry channel value and write it to the specified memory addresses. More...
 
FprimeParamValid fprime_wasm_read_parameter (I64 id, U32 value_ptr, U32 value_size)
 Read a parameter value and write it to the specified memory addresses. More...
 
FprimeCmdResponse fprime_wasm_command (U32 buf_ptr, U32 buf_size)
 Dispatch a command, blocking call. More...
 
void fprime_wasm_event (FprimeEventSeverity severity, U32 msg_ptr, U32 msg_size)
 Emit an event from the current WasmSequencer component at a given severity level. More...
 
void fprime_wasm_rsleep (U64 us)
 Pause the runtime for a specified time. More...
 
void fprime_wasm_asleep (U64 us)
 Pause the runtime until a specified time. More...
 
void fprime_wasm_serial_out (I32 index, U32 data_ptr, U32 data_size)
 Invoke a serial port If the port is not connected, the module will panic/trap. More...
 
FprimeQueueStatus fprime_wasm_serial_receive (I32 index, U32 data_ptr, U32 data_size, U32 actual_size_ptr, FprimeBlockingType block_type)
 Receive a message from a serial input queue. More...
 

Macro Definition Documentation

◆ WASM_IMPORT

#define WASM_IMPORT (   module,
  name 
)

Definition at line 19 of file fprime.h.

◆ WASM_MODULE_NAME

#define WASM_MODULE_NAME   ("fprime_v1")

Definition at line 22 of file fprime.h.

Enumeration Type Documentation

◆ FprimeBlockingType

Enumerator
FPRIME_BLOCK_BLOCKING 

Block the wasm execution until a message is received (subject to timeouts)

FPRIME_BLOCK_NONBLOCKING 

If there are no messages in the queue, return immediately.

Definition at line 163 of file fprime.h.

◆ FprimeCmdResponse

Enumerator
FPRIME_CMD_OK 

Command successfully executed.

FPRIME_CMD_INVALID_OPCODE 

Invalid opcode dispatched.

FPRIME_CMD_VALIDATION_ERROR 

Command failed validation.

FPRIME_CMD_FORMAT_ERROR 

Command failed to deserialize.

FPRIME_CMD_EXECUTION_ERROR 

Command had execution error.

FPRIME_CMD_BUSY 

Component busy.

FPRIME_CMD_CLEARED 

Command tracking was cleared before the command completed.

Definition at line 97 of file fprime.h.

◆ FprimeEventSeverity

enum FprimeEventSeverity : I32
Enumerator
FPRIME_EVENT_FATAL 

A fatal non-recoverable event.

FPRIME_EVENT_WARNING_HI 

A serious but recoverable event.

FPRIME_EVENT_WARNING_LO 

A less serious but recoverable event.

FPRIME_EVENT_COMMAND 

An activity related to commanding.

FPRIME_EVENT_ACTIVITY_HI 

Important informational events.

FPRIME_EVENT_ACTIVITY_LO 

Less important informational events.

FPRIME_EVENT_DIAGNOSTIC 

Software diagnostic events.

Definition at line 124 of file fprime.h.

◆ FprimeParamValid

Parameter validity, mirroring Fw::ParamValid. Unlike telemetry (FprimeTlmValid, a two-state VALID/INVALID enum), a parameter read distinguishes four states, so it uses its own encoding. Note FPRIME_PARAM_VALID is 1, not 0.

Enumerator
FPRIME_PARAM_UNINIT 

Parameter storage has not been initialized.

FPRIME_PARAM_VALID 

Parameter has a valid value from the parameter database.

FPRIME_PARAM_INVALID 

Parameter value is invalid (e.g. not found)

FPRIME_PARAM_DEFAULT 

Parameter is serving its compiled-in default value.

Definition at line 79 of file fprime.h.

◆ FprimeQueueStatus

Enumerator
FPRIME_QUEUE_OK 

Message was received and copied into the destination memory.

FPRIME_QUEUE_EMPTY 

Empty queue with a NONBLOCKING request.

Definition at line 168 of file fprime.h.

◆ FprimeTlmValid

Enumerator
FPRIME_TLM_VALID 
FPRIME_TLM_INVALID 

Definition at line 61 of file fprime.h.

Function Documentation

◆ fprime_wasm_asleep()

void fprime_wasm_asleep ( U64  us)

Pause the runtime until a specified time.

Parameters
usMicroseconds from system epoch to pause until

◆ fprime_wasm_command()

FprimeCmdResponse fprime_wasm_command ( U32  buf_ptr,
U32  buf_size 
)

Dispatch a command, blocking call.

Command must be encoded with the FwOpcodeType + arguments. A FORMAT_ERROR will be returned if the format is not valid!

Parameters
buf_ptrGuest memory address to encoded command
buf_sizeSize allocated for value_ptr

◆ fprime_wasm_event()

void fprime_wasm_event ( FprimeEventSeverity  severity,
U32  msg_ptr,
U32  msg_size 
)

Emit an event from the current WasmSequencer component at a given severity level.

Parameters
severityEvent severity level to emit
msg_ptrGuest memory address to event message string
msg_sizeSize allocated for value_ptr

◆ fprime_wasm_exit()

void fprime_wasm_exit ( I32  code)

Exit the current Wasm program with a return code. This function does not return.

Parameters
code0 indicates success, any non-zero exit code will

◆ fprime_wasm_get_args()

U32 fprime_wasm_get_args ( U32  destination_ptr,
U32  destination_size 
)

Get the sequence arguments this sequence was invoked with This function will write the arguments provided from the invoke/run into the guest memory.

Parameters
destination_ptrGuest memory address to argument buffer
destination_sizeLength of the argument buffer. This size must be greater than or equal to the length of arguments passed to the sequence otherwise the interpreter will trap
Returns
The number of bytes written to [destination_ptr]

◆ fprime_wasm_get_time()

void fprime_wasm_get_time ( U32  time_ptr,
U32  time_size 
)

Read the current F´ system time into guest memory.

The host serializes an Fw::Time into the guest buffer.

Parameters
time_ptrGuest memory address to write the serialized time
time_sizeSize allocated for time_ptr, must equal Fw::Time::SERIALIZED_SIZE

◆ fprime_wasm_panic()

void fprime_wasm_panic ( I32  code)

Exit the current Wasm program with a failure. This function does not return.

Parameters
codeAribtrary code to indicate source of the panic

◆ fprime_wasm_read_parameter()

FprimeParamValid fprime_wasm_read_parameter ( I64  id,
U32  value_ptr,
U32  value_size 
)

Read a parameter value and write it to the specified memory addresses.

Parameters
idParameter ID to read
value_ptrGuest memory address to parameters's value
value_sizeSize allocated for value_ptr
Returns
Parameter validity (FprimeParamValid); value bytes are written when the parameter is present. This differs from the telemetry validity enum: FPRIME_PARAM_VALID is 1, not 0.

◆ fprime_wasm_read_telemetry()

FprimeTlmValid fprime_wasm_read_telemetry ( I64  id,
U32  time_ptr,
U32  time_size,
U32  value_ptr,
U32  value_size 
)

Read a telemetry channel value and write it to the specified memory addresses.

Parameters
idChannel ID to read
time_ptrGuest memory address to write channel update time
time_sizeSize allocated for time_ptr, should be Fw::Time::SERIALIZED_SIZE
value_ptrGuest memory address to channel's value
value_sizeSize allocated for value_ptr

◆ fprime_wasm_rsleep()

void fprime_wasm_rsleep ( U64  us)

Pause the runtime for a specified time.

Parameters
usMicroseconds to pause the runtime for

◆ fprime_wasm_serial_out()

void fprime_wasm_serial_out ( I32  index,
U32  data_ptr,
U32  data_size 
)

Invoke a serial port If the port is not connected, the module will panic/trap.

Parameters
indexPort index to emit on the serialOut on
data_ptrPointer to the data to send on the output port
data_sizeLength of the data to send on the output port

◆ fprime_wasm_serial_receive()

FprimeQueueStatus fprime_wasm_serial_receive ( I32  index,
U32  data_ptr,
U32  data_size,
U32  actual_size_ptr,
FprimeBlockingType  block_type 
)

Receive a message from a serial input queue.

Parameters
indexPort number/queue index to receive message from
data_ptrPointer to the destination to write serial messages into
data_sizeSize of the data_ptr memory. If a message is larger than this size, trap the wasm module
actual_size_ptr(U32*). On message receive, number of bytes received will be written here (little endian)
block_typeWhether or not to block for a message when the queue on this index is empty
Returns
Status on whether or not we received a message (blocking will always return OK)