25 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_cmdReplyOK(
32 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_signalEntered(
38 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_spin(
46 const auto fuel = (fuelParam == 0) ? 1 : fuelParam;
88 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_reset(
91 if (this->m_wasm !=
nullptr) {
95 FW_ASSERT(signal == Svc_WasmSequencer_InterpreterStateMachine::Signal::__FPRIME_INITIAL_TRANSITION);
99 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_clearExitStatus(
104 this->m_exit.code = 0;
108 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_setExitReason_INTERPRETER_FINISHED(
114 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_setExitReason_INTERPRETER_TRAP(
122 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_setExitReason_REPLY_TIMEOUT(
128 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_setExitReason_HOST_FAILURE(
134 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_setExitReason_UNEXPECTED_REPLY(
140 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_setExitReason_TIMER_INCOMPARABLE(
146 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_setExitReason_CANCEL(
152 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_setExitCode(
156 this->m_exit.code = value;
159 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_setTrapReason(
163 this->m_exit.lastTrapReason = value;
166 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_setLastHostFunction(
169 this->m_exit.lastHostFunction = this->m_pendingHostFunction.kind;
172 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_finish(
178 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_reportPaused(
184 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_clearPause(
187 this->m_pendingPause =
false;
190 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_dispatchPendingHostFunction(
193 switch (this->m_pendingHostFunction.kind) {
199 this->dispatchCommand();
202 this->dispatchTelemetry();
205 this->dispatchParameter();
208 this->dispatchEvent();
211 this->dispatchRelativeSleep();
214 this->dispatchAbsoluteSleep();
217 this->dispatchArgs();
220 this->dispatchTime();
223 this->dispatchSerialOut();
226 this->dispatchSerialRecv();
258 void WasmSequencer ::dispatchCommand() {
262 auto serStatus = cmd.
serializeFrom(static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_COMMAND));
280 this->m_tlm.commandsDispatched++;
284 this->m_hostFunctionStart = this->
getTime();
285 this->m_hasHostFunctionStart =
true;
290 void WasmSequencer ::dispatchTelemetry() {
294 auto valid = this->
getTlmChan_out(0, this->m_pendingHostFunction.u.telemetry.chanId, time, tlmBuffer);
306 this->m_pendingHostFunction.u.telemetry.timePtr, timeBuf.
getBuffAddr(),
312 if (tlmBuffer.
getSize() > this->m_pendingHostFunction.u.telemetry.valueLen) {
314 this->m_pendingHostFunction.u.telemetry.valueLen,
315 static_cast<U32>(tlmBuffer.
getSize()));
322 this->m_pendingHostFunction.u.telemetry.valuePtr, tlmBuffer.
getBuffAddr(),
331 void WasmSequencer ::dispatchParameter() {
333 auto prmStatus = this->
getParam_out(0, this->m_pendingHostFunction.u.parameter.prmId, prmBuf);
335 if (prmBuf.
getSize() > this->m_pendingHostFunction.u.parameter.len) {
337 this->m_pendingHostFunction.u.parameter.len,
338 static_cast<U32>(prmBuf.
getSize()));
353 void WasmSequencer ::dispatchEvent() {
364 stringStorage[this->m_pendingHostFunction.u.event.msgLen] = 0;
372 const I32 rawSeverity =
static_cast<I32
>(this->m_pendingHostFunction.u.event.rawSeverity);
373 switch (static_cast<Fw::LogSeverity::T>(rawSeverity)) {
399 void WasmSequencer ::dispatchRelativeSleep() {
400 const U32 seconds =
static_cast<U32
>(this->m_pendingHostFunction.u.rsleep.us / 1000000);
401 const U32 useconds =
static_cast<U32
>(this->m_pendingHostFunction.u.rsleep.us % 1000000);
404 const U64 deadlineSeconds =
405 static_cast<U64
>(now.
getSeconds()) + seconds + (static_cast<U64>(now.
getUSeconds()) + useconds) / 1000000u;
408 if (deadlineSeconds > static_cast<U64>(std::numeric_limits<U32>::max())) {
409 timer.
set(std::numeric_limits<U32>::max(), 999999u);
411 timer.
add(seconds, useconds);
414 this->m_pendingTimer = timer;
415 this->m_hasPendingTimer =
true;
418 void WasmSequencer ::dispatchAbsoluteSleep() {
419 U32 seconds =
static_cast<U32
>(this->m_pendingHostFunction.u.asleep.us / 1000000);
420 U32 useconds =
static_cast<U32
>(this->m_pendingHostFunction.u.asleep.us % 1000000);
424 timer.
set(seconds, useconds);
426 this->m_pendingTimer = timer;
427 this->m_hasPendingTimer =
true;
430 void WasmSequencer ::dispatchArgs() {
432 if (this->m_args.
get_size() > argCapacity) {
434 static_cast<U32>(argCapacity));
439 if (this->m_args.
get_size() > this->m_pendingHostFunction.u.args.len) {
442 static_cast<U32>(this->m_args.get_size()));
457 void WasmSequencer ::dispatchTime() {
477 void WasmSequencer ::dispatchSerialOut() {
482 this->m_serialOutBuffer.getBuffAddr(),
488 auto serStatus = this->m_serialOutBuffer.
setBuffLen(this->m_pendingHostFunction.u.serialOut.len);
492 serStatus = this->
serialOut_out(portNum, this->m_serialOutBuffer);
495 static_cast<I32>(serStatus));
504 void WasmSequencer ::dispatchSerialRecv() {
508 auto& queue = this->m_serialInQueue[portNum];
511 if (queue.get_allocated_size() > 0) {
516 switch (this->m_pendingHostFunction.u.serialRecv.blockingType) {
520 this->m_hostFunctionStart = this->
getTime();
521 this->m_hasHostFunctionStart =
true;
526 constexpr I32 FPRIME_SERIAL_RECV_QUEUE_STATUS_EMPTY = 1;
533 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_clearPendingHostFunction(
537 this->m_pendingHostFunction.caller =
nullptr;
538 this->m_hasPendingTimer =
false;
539 this->m_hasHostFunctionStart =
false;
542 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_setContext(
547 this->m_hasExecutingContext =
true;
548 this->m_executingContext = value;
552 this->m_sequencesStarted++;
555 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_clearContext(
558 this->m_hasExecutingContext =
false;
561 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_resume(
569 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_resumeI32(
576 return_val.
u.
i32_ = value;
582 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_checkSleepTimers(
606 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_checkTimeout(
612 if (!this->m_hasHostFunctionStart) {
620 if (timeoutSecs <= 0.0f || timeoutSecs >= static_cast<F32>(std::numeric_limits<U32>::max())) {
626 U32 seconds =
static_cast<U32
>(timeoutSecs);
627 U32 useconds =
static_cast<U32
>((timeoutSecs -
static_cast<F32>(seconds)) * 1000000.0f + 0.5f);
631 if (useconds >= 1000000u) {
632 seconds += useconds / 1000000u;
633 useconds %= 1000000u;
636 Fw::Time deadline = this->m_hostFunctionStart;
637 deadline.
add(seconds, useconds);
656 void WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_action_dequeueSerialAndResume(
663 auto& queue = this->m_serialInQueue[portNum];
665 this->m_dequeueSucceeded =
false;
669 auto status = queue.peek(msgSize);
672 if (msgSize > this->m_pendingHostFunction.u.serialRecv.dataSize) {
674 this->m_pendingHostFunction.u.serialRecv.dataSize, msgSize);
677 status = queue.rotate(static_cast<U32>(
sizeof(U32)) + msgSize);
683 const U32 queuePayloadStart =
sizeof(U32);
684 const U32 dataSize =
static_cast<U32
>(
sizeof(U32)) + msgSize;
692 this->m_pendingHostFunction.u.serialRecv.actualSizePtr, msgSizeSer.
getBuffAddr(),
698 constexpr U32 CHUNK_SIZE = 32;
699 U8 scratch[CHUNK_SIZE];
702 U32 queueOffset = queuePayloadStart;
703 for (; (queueOffset + CHUNK_SIZE) <= dataSize; queueOffset += CHUNK_SIZE) {
704 status = queue.peek(scratch, CHUNK_SIZE, queueOffset);
709 this->m_pendingHostFunction.u.serialRecv.dataPtr + (queueOffset - queuePayloadStart),
716 if (queueOffset < dataSize) {
717 const U32 remaining = dataSize - queueOffset;
718 FW_ASSERT(remaining < CHUNK_SIZE, static_cast<FwAssertArgType>(dataSize),
719 static_cast<FwAssertArgType>(queueOffset), CHUNK_SIZE);
721 status = queue.peek(scratch, remaining, queueOffset);
726 this->m_pendingHostFunction.u.serialRecv.dataPtr + (queueOffset - queuePayloadStart),
733 status = queue.rotate(dataSize);
736 this->m_dequeueSucceeded =
true;
739 constexpr I32 FPRIME_SERIAL_RECV_QUEUE_STATUS_OK = 0;
742 return_val.
u.
i32_ = FPRIME_SERIAL_RECV_QUEUE_STATUS_OK;
752 bool WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_guard_pendingPause(
755 return this->m_pendingPause;
758 bool WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_guard_pendingHostFunction(
761 return this->m_pendingHostFunction.isPending();
764 bool WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_guard_pendingHostFunctionIsSleep(
771 bool WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_guard_blockingSerialIn(
776 this->m_pendingHostFunction.u.serialRecv.index == static_cast<U32>(value));
779 bool WasmSequencer ::Svc_WasmSequencer_InterpreterStateMachine_guard_dequeueSucceeded(
782 return this->m_dequeueSucceeded;
void log_ACTIVITY_LO_LogActivityLo(const Fw::StringBase &msg) const
union spacewasm_value_payload_t u
Serialization/Deserialization operation was successful.
void interpreter_sendSignal_hostResumeI32(I32 value)
Send signal hostResumeI32 to state machine interpreter.
Fw::ParamValid getParam_out(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val) const
Invoke output port getParam.
U16 FwPacketDescriptorType
The width of packet descriptors when they are serialized by the framework.
spacewasm_run_status_t spacewasm_run(struct spacewasm_t *engine, size_t fuel, spacewasm_trap_t *out_trap)
spacewasm_status_t spacewasm_mem_write(struct spacewasm_caller_t *caller, uint32_t addr, const uint8_t *src, size_t len)
The interpreter exited via HOST_TRAP and we indicated HOST_PANIC in the host function.
PlatformSizeType FwSizeType
void controller_sendSignal_engineFinished(const Svc::WasmSequencer_RequestContext &value)
Send signal engineFinished to state machine controller.
We got an unexpected async reply which caused us to abort.
SerializeStatus moveSerToOffset(FwSizeType offset) override
Move serialization pointer to specified offset.
void log_ACTIVITY_HI_LogActivityHi(const Fw::StringBase &msg) const
U32 get_cmdSeq() const
Get member cmdSeq.
Serializable::SizeType getSize() const override
Get current buffer size.
void interpreter_sendSignal_entered()
Send signal entered to state machine interpreter.
void log_ACTIVITY_HI_SequencePaused() const
void interpreter_sendSignal_serialInMessage(const FwIndexType &value)
Send signal serialInMessage to state machine interpreter.
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
A cancel signal was sent and we exited the interpreter.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
FwSizeType paramGet_INSTRUCTION_FUEL(Fw::ParamValid &valid)
void log_WARNING_HI_HostFunctionInvalidPointer(const Svc::WasmSequencer_HostFunction &host_function, const Svc::WasmSequencer_Status &code) const
Log event HostFunctionInvalidPointer.
Software diagnostic events.
An async host function replied with an error.
An async reply timeout overran while waiting for a host function reply.
spacewasm_status_t spacewasm_mem_read(struct spacewasm_caller_t *caller, uint32_t addr, uint8_t *dst, size_t len)
float F32
32-bit floating point
FwOpcodeType get_opcode() const
Get member opcode.
void cmdOut_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context) const
Invoke output port cmdOut.
void set(U32 seconds, U32 useconds)
void interpreter_sendSignal_interpreterHostFunctionNeedsPause()
Send signal interpreterHostFunctionNeedsPause to state machine interpreter.
U8 * getBuffAddr()
Get buffer address for data filling (non-const version)
Less important informational events.
An activity related to commanding.
A less serious but recoverable event.
Type_of_buffer & get_buffer()
Get member buffer.
void interpreter_sendSignal_hostResponseFailure()
Send signal hostResponseFailure to state machine interpreter.
spacewasm_status_t spacewasm_get_result(struct spacewasm_t *engine, spacewasm_valtype_t expected, struct spacewasm_value_t *out)
void log_WARNING_HI_LogWarningHi(const Fw::StringBase &msg) const
void interpreter_sendSignal_interpreterFinished(I32 value)
Send signal interpreterFinished to state machine interpreter.
spacewasm_status_t spacewasm_resume_value(struct spacewasm_t *engine, struct spacewasm_value_t resume_value)
void interpreter_sendSignal_hostResume()
Send signal hostResume to state machine interpreter.
A string backed by an external buffer.
A serious but recoverable event.
void log_WARNING_HI_HostFunctionInvalidSeverity(I32 raw, const Fw::StringBase &msg) const
FwSizeType get_size() const
Get member size.
The interpreter exited via HOST_TRAP but a host function indicated it was a standard exit() ...
void interpreter_sendSignal_hostResponseTimeout()
Send signal hostResponseTimeout to state machine interpreter.
Fw::SerializeStatus serialOut_out(FwIndexType portNum, Fw::LinearBufferBase &buffer)
Invoke output port serialOut.
Command successfully executed.
Fw::TlmValid getTlmChan_out(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke output port getTlmChan.
F32 paramGet_HOST_FUNCTION_TIMEOUT_SECS(Fw::ParamValid &valid)
uint8_t U8
8-bit unsigned integer
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
void log_WARNING_LO_LogWarningLo(const Fw::StringBase &msg) const
void log_WARNING_HI_BufferTooLarge(const Svc::WasmSequencer_HostFunction &host_function, U32 size, U32 maxSize) const
Important informational events.
static TimeComparison compare(const Time &time1, const Time &time2)
A sleep or host-function timer became incomparable (time base changed) and could not be evaluated...
static Time add(const Time &a, const Time &b)
void interpreter_sendSignal_interpreterTrap(const Svc::WasmSequencer_TrapReason &value)
Send signal interpreterTrap to state machine interpreter.
spacewasm_status_t spacewasm_reset(struct spacewasm_t *engine)
void interpreter_sendSignal_hostResponseTimeIncomparable()
Send signal hostResponseTimeIncomparable to state machine interpreter.
PlatformIndexType FwIndexType
locks a mutex within the current scope
The interpreter exited normally and set m_exitCode.
A fatal non-recoverable event.
void interpreter_sendSignal_interpreterOutOfFuel()
Send signal interpreterOutOfFuel to state machine interpreter.
RateGroupDivider component implementation.
Enum representing parameter validity.
Little endian serialization.
void log_DIAGNOSTIC_LogDiagnostic(const Fw::StringBase &msg) const
SerializeStatus serializeTo(SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const override
Serialize the contents of this object to a buffer.
A struct holding the context needed to reply to a command request.
The interpreter ran into a byte-code trap.
FpySequencer_SequencerStateMachineStateMachineBase::Signal Signal
spacewasm_status_t spacewasm_resume(struct spacewasm_t *engine)
void log_WARNING_HI_SerialPortSendFailed(const Svc::WasmSequencer_HostFunction &host_function, I32 status) const
We did not explicitely set the exit reason, bug?
void log_WARNING_HI_BufferTooSmall(const Svc::WasmSequencer_HostFunction &host_function, U32 size, U32 valueSize) const