Skip to content

WasmSequencer#5386

Draft
Kronos3 wants to merge 9 commits into
nasa:develfrom
Kronos3:wasm
Draft

WasmSequencer#5386
Kronos3 wants to merge 9 commits into
nasa:develfrom
Kronos3:wasm

Conversation

@Kronos3

@Kronos3 Kronos3 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator
Related Issue(s)
Has Unit Tests (y/n)
Documentation Included (y/n)
Generative AI was used in this contribution (y/n)

Change Description

This component is still under active development. I'm creating a draft PR to work in tandem with @zimri-leisher Fpy development and capture review items.

Rationale

Testing/Review Recommendations

Future Work

AI Usage (see policy)

@zimri-leisher

zimri-leisher commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Documenting the host environment assumptions:

  • exit host func for user-triggered early end of sequence. should have an i32 code
  • fault host func for non-user-triggered early end of sequence, should have an i32 code
    • this is used for things like arithmetic overflow and other implicit termination points in the code
  • write_tlm host func (id, time ptr, time size, value ptr, value size)
  • write_prm host func (id, value ptr, value size)
  • dispatch_cmd host func ((opcode+args) buf ptr, (opcode+args) buf size)
    • TODO should the buf be a fully constructed fprime cmd? or should the component build the cmd from opcode+args
  • emit_event host func (severity, message size, message bytes)
    • TODO consider how we want to provide string formatting in events
  • sleep_relative (timeinterval) and sleep_absolute (fw.time)
  • output_serial (value ptr, value size) (see current FpySequencer POP_SERIALIZABLE)
    • also TODO, we may want to consider having this able to return a value back into the sequence? it would be a step towards allowing users to define their own host environment behavior
  • write_time host func (time ptr, time size)

Math functions (use libm implementation, trap if undefined behavior or out of domain)

  • sin, cos, tan, inverse of those, hyperbolic of those, atan2
  • ln, exp

@Kronos3

Kronos3 commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

String formatting in events should be done one of two ways.

  1. Inside the Wasm code: We have shown this done using the Rust core crate so presumably something to that end.
  2. The other way to do it is something like https://github.com/knurling-rs/defmt which basically detects string formatting in the frontend and generates a ground-side lookup (dictionary). Then all we need to do is encode format arguments into a buffer and downlink it in the event.
    a. This can be used if the formatted string is not needed on-board and reduces downlink and on-board processing.

// Implementations for internal state machine actions
// ----------------------------------------------------------------------

void WasmSequencer ::Svc_WasmSequencer_SequencerStateMachine_action_signalEntered(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to follow the idioms of the fpy sequencer, you could split all the sm guard/action impls out into a separate file. just helps to keep the length of any one file down

@ 3. INVOKE "" "main"
@ 4. CONTINUE
@
@ If $block == Svc.BlockState.BLOCK this command will wait for complemention.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in completion

)

@ Wait for the interpreter to finish and return it's result as a CmdResponse
async command WAIT()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider more descriptive name? WAIT_FOR_SEQUENCE?

)

@ Invoke a function from a loaded module
async command INVOKE(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a very interesting capability and i wonder if we can make use of it more

signal interpreterTrap: TrapReason

@ No more fuel (ran to instruction bound)
signal interpreterOutOfFuel

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a fuel param or arg?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I was going to make it a config but parameter makes more sense.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That parameter essentially controls how responsive the interpreter is to PAUSE if it's doing computationally heavy tasks.

}

@ sequencer is spinning the interpreter loop
state SPINNING {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

briefly, would it be more clear if you called it "RUNNING"? spin is a bit jargony

@zimri-leisher

Copy link
Copy Markdown
Collaborator

Some non substantive review. I think I will wait to deeply review this component until you can go over it with me together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants