F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
fprime.h
Go to the documentation of this file.
1 // ======================================================================
2 // \title fprime.h
3 // \author tumbar
4 // \brief Header for the F Prime WebAssembly System Interface (fwasi)
5 // ======================================================================
6 
7 #ifndef FPRIME_SPACEWASM_GUEST_H
8 #define FPRIME_SPACEWASM_GUEST_H
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif // __cplusplus
13 
14 #include <Fw/FPrimeBasicTypes.h>
15 
16 #if defined(__wasm__)
17 #define WASM_IMPORT(module, name) __attribute__((__import_module__(module), __import_name__(name)))
18 #else
19 #define WASM_IMPORT(module, name)
20 #endif // defined(__wasm__)
21 
22 #define WASM_MODULE_NAME ("fprime_v1")
23 
28 // be reported in an event and the sequence will exit
29 // with failure status
31 extern void fprime_wasm_exit(I32 code);
32 
38 extern void fprime_wasm_panic(I32 code);
39 
50 extern U32 fprime_wasm_get_args(U32 destination_ptr, U32 destination_size);
51 
59 extern void fprime_wasm_get_time(U32 time_ptr, U32 time_size);
60 
64 };
65 
74 extern FprimeTlmValid fprime_wasm_read_telemetry(I64 id, U32 time_ptr, U32 time_size, U32 value_ptr, U32 value_size);
75 
84 };
85 
95 extern FprimeParamValid fprime_wasm_read_parameter(I64 id, U32 value_ptr, U32 value_size);
96 
112 };
113 
122 extern FprimeCmdResponse fprime_wasm_command(U32 buf_ptr, U32 buf_size);
123 
132 };
133 
140 extern void fprime_wasm_event(FprimeEventSeverity severity, U32 msg_ptr, U32 msg_size);
141 
145 WASM_IMPORT(WASM_MODULE_NAME, "rsleep")
146 extern void fprime_wasm_rsleep(U64 us);
147 
151 WASM_IMPORT(WASM_MODULE_NAME, "asleep")
152 extern void fprime_wasm_asleep(U64 us);
153 
160 WASM_IMPORT(WASM_MODULE_NAME, "serial_send")
161 extern void fprime_wasm_serial_out(I32 index, U32 data_ptr, U32 data_size);
162 
166 };
167 
171 };
172 
181 WASM_IMPORT(WASM_MODULE_NAME, "serial_recv")
183  U32 data_ptr,
184  U32 data_size,
185  U32 actual_size_ptr,
186  FprimeBlockingType block_type);
187 
188 #ifdef __cplusplus
189 } // extern "C"
190 #endif // __cplusplus
191 
192 #endif // FPRIME_SPACEWASM_GUEST_H
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. ...
FprimeTlmValid
Definition: fprime.h:61
Command had execution error.
Definition: fprime.h:107
Block the wasm execution until a message is received (subject to timeouts)
Definition: fprime.h:164
Parameter has a valid value from the parameter database.
Definition: fprime.h:81
FprimeCmdResponse fprime_wasm_command(U32 buf_ptr, U32 buf_size)
Dispatch a command, blocking call.
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.
A less serious but recoverable event.
Definition: fprime.h:127
FprimeCmdResponse
Definition: fprime.h:97
FprimeParamValid
Definition: fprime.h:79
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 prov...
Component busy.
Definition: fprime.h:109
Parameter is serving its compiled-in default value.
Definition: fprime.h:83
void fprime_wasm_exit(I32 code)
Exit the current Wasm program with a return code. This function does not return.
Invalid opcode dispatched.
Definition: fprime.h:101
Command failed validation.
Definition: fprime.h:103
void fprime_wasm_rsleep(U64 us)
Pause the runtime for a specified time.
Important informational events.
Definition: fprime.h:129
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.
Parameter storage has not been initialized.
Definition: fprime.h:80
Less important informational events.
Definition: fprime.h:130
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.
A fatal non-recoverable event.
Definition: fprime.h:125
#define WASM_IMPORT(module, name)
Definition: fprime.h:19
An activity related to commanding.
Definition: fprime.h:128
Parameter value is invalid (e.g. not found)
Definition: fprime.h:82
Message was received and copied into the destination memory.
Definition: fprime.h:169
Software diagnostic events.
Definition: fprime.h:131
#define WASM_MODULE_NAME
Definition: fprime.h:22
A serious but recoverable event.
Definition: fprime.h:126
FprimeQueueStatus
Definition: fprime.h:168
Command tracking was cleared before the command completed.
Definition: fprime.h:111
void fprime_wasm_get_time(U32 time_ptr, U32 time_size)
Read the current F´ system time into guest memory.
Command failed to deserialize.
Definition: fprime.h:105
If there are no messages in the queue, return immediately.
Definition: fprime.h:165
void fprime_wasm_asleep(U64 us)
Pause the runtime until a specified time.
Command successfully executed.
Definition: fprime.h:99
FprimeBlockingType
Definition: fprime.h:163
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.
Empty queue with a NONBLOCKING request.
Definition: fprime.h:170
void fprime_wasm_panic(I32 code)
Exit the current Wasm program with a failure. This function does not return.
FprimeEventSeverity
Definition: fprime.h:124