Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -357,6 +357,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_InvalidCommand(static_cast<I32>(sequencer_getState()));
Comment thread
Lex-ari marked this conversation as resolved.
Outdated
return;
}
this->sequencer_sendSignal_cmd_CANCEL();
}

//! Handler for input port seqRunIn
void FpySequencer::seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename) {
// 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 @@ -472,6 +472,12 @@ class FpySequencer : public FpySequencerComponentBase {
//! Handler for input port seqRunIn
void seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename) 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
50 changes: 50 additions & 0 deletions Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3191,6 +3191,56 @@ 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_InvalidCommand_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, flag_EXIT_ON_CMD_FAIL) {
Comment thread
Lex-ari marked this conversation as resolved.
Outdated
// test a simple seq that fails because a cmd fails
this->paramSet_FLAG_DEFAULT_EXIT_ON_CMD_FAIL(true, Fw::ParamValid::VALID);
this->paramSend_FLAG_DEFAULT_EXIT_ON_CMD_FAIL(0, 0);
this->clearHistory();
allocMem();
add_CONST_CMD(123);
writeAndRun();
dispatchUntilState(State::RUNNING_AWAITING_STATEMENT_RESPONSE);
// okay now send in a failure
invoke_to_cmdResponseIn(0, 123, 0x00010001, Fw::CmdResponse::EXECUTION_ERROR);
dispatchUntilState(State::IDLE);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, 0, get_OPCODE_RUN(), Fw::CmdResponse::EXECUTION_ERROR);

// now test that it doesn't fail if we set flag to false
this->paramSet_FLAG_DEFAULT_EXIT_ON_CMD_FAIL(false, Fw::ParamValid::VALID);
this->paramSend_FLAG_DEFAULT_EXIT_ON_CMD_FAIL(0, 0);
this->clearHistory();
// cmd is already in seq, can just rerun
writeAndRun();
dispatchUntilState(State::RUNNING_AWAITING_STATEMENT_RESPONSE);
// okay now send in a failure
invoke_to_cmdResponseIn(0, 123, 0x00020002, Fw::CmdResponse::EXECUTION_ERROR);
dispatchUntilState(State::IDLE);
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, 0, get_OPCODE_RUN(), Fw::CmdResponse::OK);
}

// ----------------------------------------------------------------------
// Stack Unit Tests
// ----------------------------------------------------------------------
Expand Down
Loading