Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Svc/FpySequencer/FpySequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,15 @@ void FpySequencer::cmdResponseIn_handler(FwIndexType portNum, //!< T
this->m_runtime.stack.push(static_cast<I32>(response.e));
}

void FpySequencer ::seqCancelIn_handler(FwIndexType portNum) {
// only state you can't cancel in is IDLE
if (sequencer_getState() == State::IDLE) {
this->log_WARNING_HI_InvalidSeqCancelCall(static_cast<I32>(sequencer_getState()));
return;
}
this->sequencer_sendSignal_cmd_CANCEL();
}

//! Handler for input port seqRunIn
void FpySequencer::seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename, const Svc::SeqArgs& args) {
// can only run a seq while in idle
Expand Down
4 changes: 4 additions & 0 deletions Svc/FpySequencer/FpySequencer.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ module Svc {
# same priority as RUN cmd
async input port seqRunIn: Svc.CmdSeqIn priority 7 assert

@ port for requesting to cancel the currently running sequence
# same priority as CANCEL cmd
async input port seqCancelIn: Svc.CmdSeqCancel priority 8 assert

@ called when a sequence begins running
output port seqStartOut: Svc.CmdSeqIn

Expand Down
6 changes: 6 additions & 0 deletions Svc/FpySequencer/FpySequencer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,12 @@ class FpySequencer : public FpySequencerComponentBase {
//! Handler for input port seqRunIn
void seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename, const Svc::SeqArgs& args) override;

//! Handler implementation for seqCancelIn
//!
//! port for requesting to cancel the currently running sequence
void seqCancelIn_handler(FwIndexType portNum //!< The port number
) override;

//! Handler for input port pingIn
void pingIn_handler(FwIndexType portNum, //!< The port number
U32 key //!< Value to return to pinger
Expand Down
4 changes: 4 additions & 0 deletions Svc/FpySequencer/FpySequencerEvents.fppi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ event InvalidSeqRunCall($state: I32) \
severity warning high \
format "Cannot run sequence from a port in state {}"

event InvalidSeqCancelCall($state: I32) \
severity warning high \
format "Cannot cancel sequence from a port in state {}"

event FileOpenError(
filePath: string
errorCode: I32
Expand Down
19 changes: 19 additions & 0 deletions Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3340,6 +3340,25 @@ TEST_F(FpySequencerTester, seqRunIn) {
removeFile("test.bin");
}

TEST_F(FpySequencerTester, seqCancelIn) {
this->tester_setState(State::IDLE);
this->invoke_to_seqCancelIn(0);
this->tester_doDispatch();
// should fail if we're in IDLE
ASSERT_EVENTS_InvalidSeqCancelCall_SIZE(1);

dispatchCurrentMessages(cmp);
ASSERT_EQ(this->tester_getState(), State::IDLE);

this->clearHistory();
this->tester_setState(State::RUNNING_SLEEPING);
this->invoke_to_seqCancelIn(0);
this->tester_doDispatch();
// should go back to idle
dispatchUntilState(State::IDLE);
ASSERT_EVENTS_SequenceCancelled_SIZE(1);
ASSERT_from_seqDoneOut(0, 0, 0, Fw::CmdResponse::EXECUTION_ERROR);

TEST_F(FpySequencerTester, seqRunInArgs) {
allocMem();
add_LOAD_REL(0, 4); // Load first arg (U32 at offset 0) - duplicates it on stack
Expand Down
Loading