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 #include <Fw/Deprecate.hpp>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif // __cplusplus
15 
16 #include <Fw/FPrimeBasicTypes.h>
17 
18 #if defined(__wasm__)
19 #define WASM_IMPORT(module, name) __attribute__((__import_module__(module), __import_name__(name)))
20 #else
21 #define WASM_IMPORT(module, name)
22 #endif // defined(__wasm__)
23 
24 #define WASM_MODULE_NAME ("fprime_v1")
25 
30 // be reported in an event and the sequence will exit
31 // with failure status
33 extern void fprime_wasm_exit(I32 code);
34 
40 extern void fprime_wasm_panic(I32 code);
41 
52 extern U32 DEPRECATED(fprime_wasm_get_args(U32 destination_ptr, U32 destination_size),
53  "args always returns 0. Pass inputs through the sequence's exported function signature instead");
54 
62 extern void fprime_wasm_get_time(U32 time_ptr, U32 time_size);
63 
67 };
68 
77 extern FprimeTlmValid fprime_wasm_read_telemetry(I64 id, U32 time_ptr, U32 time_size, U32 value_ptr, U32 value_size);
78 
87 };
88 
98 extern FprimeParamValid fprime_wasm_read_parameter(I64 id, U32 value_ptr, U32 value_size);
99 
118 };
119 
128 extern FprimeCmdResponse fprime_wasm_command(U32 buf_ptr, U32 buf_size);
129 
138 };
139 
146 extern void fprime_wasm_event(FprimeEventSeverity severity, U32 msg_ptr, U32 msg_size);
147 
151 WASM_IMPORT(WASM_MODULE_NAME, "rsleep")
152 extern void fprime_wasm_rsleep(U64 us);
153 
157 WASM_IMPORT(WASM_MODULE_NAME, "asleep")
158 extern void fprime_wasm_asleep(U64 us);
159 
166 WASM_IMPORT(WASM_MODULE_NAME, "serial_send")
167 extern void fprime_wasm_serial_out(I32 index, U32 data_ptr, U32 data_size);
168 
172 };
173 
177 };
178 
187 WASM_IMPORT(WASM_MODULE_NAME, "serial_recv")
189  U32 data_ptr,
190  U32 data_size,
191  U32 actual_size_ptr,
192  FprimeBlockingType block_type);
193 
194 #ifdef __cplusplus
195 } // extern "C"
196 #endif // __cplusplus
197 
198 #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:64
Command had execution error.
Definition: fprime.h:111
Block the wasm execution until a message is received (subject to timeouts)
Definition: fprime.h:170
Parameter has a valid value from the parameter database.
Definition: fprime.h:84
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:133
FprimeCmdResponse
Command response. Fw::CmdResponse in Fw/Cmd/Cmd.fpp.
Definition: fprime.h:101
FprimeParamValid
Definition: fprime.h:82
Component busy.
Definition: fprime.h:113
Parameter is serving its compiled-in default value.
Definition: fprime.h:86
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:105
Command failed validation.
Definition: fprime.h:107
void fprime_wasm_rsleep(U64 us)
Pause the runtime for a specified time.
Important informational events.
Definition: fprime.h:135
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:83
Less important informational events.
Definition: fprime.h:136
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:131
#define WASM_IMPORT(module, name)
Definition: fprime.h:21
An activity related to commanding.
Definition: fprime.h:134
U32 DEPRECATED(fprime_wasm_get_args(U32 destination_ptr, U32 destination_size), "args always returns 0. Pass inputs through the sequence's exported function signature instead")
Deprecated no-op retained for binary compatibility with older guests.
Parameter value is invalid (e.g. not found)
Definition: fprime.h:85
Message was received and copied into the destination memory.
Definition: fprime.h:175
Software diagnostic events.
Definition: fprime.h:137
#define WASM_MODULE_NAME
Definition: fprime.h:24
A serious but recoverable event.
Definition: fprime.h:132
FprimeQueueStatus
Definition: fprime.h:174
Command tracking was cleared before the command completed.
Definition: fprime.h:115
Command was dispatched but the response tracking failed, indicating unknown state.
Definition: fprime.h:117
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:109
If there are no messages in the queue, return immediately.
Definition: fprime.h:171
void fprime_wasm_asleep(U64 us)
Pause the runtime until a specified time.
Command successfully executed.
Definition: fprime.h:103
FprimeBlockingType
Definition: fprime.h:169
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:176
void fprime_wasm_panic(I32 code)
Exit the current Wasm program with a failure. This function does not return.
FprimeEventSeverity
Definition: fprime.h:130