diff --git a/Svc/FpySequencer/FpySequencer.cpp b/Svc/FpySequencer/FpySequencer.cpp index 100ef7c86a..a5899037ca 100644 --- a/Svc/FpySequencer/FpySequencer.cpp +++ b/Svc/FpySequencer/FpySequencer.cpp @@ -379,6 +379,15 @@ void FpySequencer::cmdResponseIn_handler(FwIndexType portNum, //!< T this->m_runtime.stack.push(static_cast(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(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 diff --git a/Svc/FpySequencer/FpySequencer.fpp b/Svc/FpySequencer/FpySequencer.fpp index 8af40d3d7c..9831ef3de5 100644 --- a/Svc/FpySequencer/FpySequencer.fpp +++ b/Svc/FpySequencer/FpySequencer.fpp @@ -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 diff --git a/Svc/FpySequencer/FpySequencer.hpp b/Svc/FpySequencer/FpySequencer.hpp index 7e1e302485..6d41d4b91f 100644 --- a/Svc/FpySequencer/FpySequencer.hpp +++ b/Svc/FpySequencer/FpySequencer.hpp @@ -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 diff --git a/Svc/FpySequencer/FpySequencerEvents.fppi b/Svc/FpySequencer/FpySequencerEvents.fppi index 683021ab62..06c75d6a28 100644 --- a/Svc/FpySequencer/FpySequencerEvents.fppi +++ b/Svc/FpySequencer/FpySequencerEvents.fppi @@ -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 diff --git a/Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp b/Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp index 6f6548416c..90e03648fc 100644 --- a/Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp +++ b/Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp @@ -3340,6 +3340,26 @@ 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