Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions Svc/FpySequencer/FpySequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ void FpySequencer::updateDebugTelemetryStruct() {

void FpySequencer::parametersLoaded() {
parameterUpdated(PARAMID_STATEMENT_TIMEOUT_SECS);
parameterUpdated(PARAMID_SEQ_BASE_DIR);
}

void FpySequencer::parameterUpdated(FwPrmIdType id) {
Expand All @@ -498,6 +499,10 @@ void FpySequencer::parameterUpdated(FwPrmIdType id) {
this->tlmWrite_PRM_STATEMENT_TIMEOUT_SECS(this->paramGet_STATEMENT_TIMEOUT_SECS(valid));
break;
}
case PARAMID_SEQ_BASE_DIR: {
this->tlmWrite_PRM_SEQ_BASE_DIR(this->paramGet_SEQ_BASE_DIR(valid));
break;
}
default: {
FW_ASSERT(0, static_cast<FwAssertArgType>(id)); // coding error, forgot to include in switch statement
}
Expand Down
8 changes: 7 additions & 1 deletion Svc/FpySequencer/FpySequencerParams.fppi
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
@ on a directive or command. if <= 0 or greater than U32 max, never time out.
@ accuracy of this timeout is determined by the rate group driving this
@ component. it will be rounded up
param STATEMENT_TIMEOUT_SECS: F32 default 0
param STATEMENT_TIMEOUT_SECS: F32 default 0

@ the base directory relative to which sequence file paths are resolved.
@ added as a suffix to the sequence path before opening the file. if it is
@ a relative path, then the sequence path is resolved relative to the process's
@ current working directory
param SEQ_BASE_DIR: string size FileNameStringSize default Fpy.DEFAULT_SEQ_BASE_DIR
12 changes: 10 additions & 2 deletions Svc/FpySequencer/FpySequencerStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@
//! Implementation for action setSequenceFilePath of state machine
//! Svc_FpySequencer_SequencerStateMachine
//!
//! sets the current sequence file path member var
//! sets the current sequence file path member var, resolving it against
//! the SEQ_BASE_DIR parameter so that subsequent telemetry, events, and
//! file IO see the fully qualified path
void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setSequenceFilePath(
SmId smId, //!< The state machine id
Svc_FpySequencer_SequencerStateMachine::Signal signal, //!< The signal
const Svc::FpySequencer_SequenceExecutionArgs& value //!< The value
) {
this->m_sequenceFilePath = value.get_filePath();
Fw::ParamValid valid;
Fw::ParamString baseDir = this->paramGet_SEQ_BASE_DIR(valid);
if (baseDir.length() > 0) {
this->m_sequenceFilePath.format("%s/%s", baseDir.toChar(), value.get_filePath().toChar());

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
format
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter value has not been checked.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
LeStarch marked this conversation as resolved.
Outdated
} else {
this->m_sequenceFilePath = value.get_filePath();

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter value has not been checked.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
LeStarch marked this conversation as resolved.
Dismissed
Comment thread
LeStarch marked this conversation as resolved.
Dismissed
}
}

//! Implementation for action setSequenceBlockState of state machine
Expand Down
3 changes: 3 additions & 0 deletions Svc/FpySequencer/FpySequencerTelemetry.fppi
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ telemetry BreakBeforeNextLine: bool update on change

@ value of prm STATEMENT_TIMEOUT_SECS
telemetry PRM_STATEMENT_TIMEOUT_SECS: F32 update on change

@ value of prm SEQ_BASE_DIR
telemetry PRM_SEQ_BASE_DIR: string size FileNameStringSize update on change
68 changes: 68 additions & 0 deletions Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2770,6 +2770,74 @@ TEST_F(FpySequencerTester, validate) {
ASSERT_EVENTS_ExtraBytesInSequence_SIZE(1);
}

TEST_F(FpySequencerTester, seqBaseDir_resolvesPath) {
// base dir of "." should resolve "test.bin" to "./test.bin" — m_sequenceFilePath
Comment thread
LeStarch marked this conversation as resolved.
Outdated
// (used by tlm/events/file IO) should hold the fully resolved path
allocMem();
add_NO_OP();
writeToFile("test.bin");

paramSet_SEQ_BASE_DIR(Fw::ParamString("."), Fw::ParamValid::VALID);
paramSend_SEQ_BASE_DIR(0, 0);
this->clearHistory();

sendCmd_VALIDATE(0, 0, Fw::String("test.bin"));
dispatchUntilState(State::VALIDATING);
dispatchUntilState(State::AWAITING_CMD_RUN_VALIDATED);

ASSERT_EQ(tester_get_m_sequenceFilePath(), Fw::String("./test.bin"));
ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, Svc::FpySequencerTester::get_OPCODE_VALIDATE(), 0, Fw::CmdResponse::OK);

removeFile("test.bin");
}

TEST_F(FpySequencerTester, seqBaseDir_emptyKeepsRawPath) {
// empty base dir — m_sequenceFilePath should be the raw user-provided path
allocMem();
add_NO_OP();
writeToFile("test.bin");

paramSet_SEQ_BASE_DIR(Fw::ParamString(""), Fw::ParamValid::VALID);
paramSend_SEQ_BASE_DIR(0, 0);
this->clearHistory();

sendCmd_VALIDATE(0, 0, Fw::String("test.bin"));
dispatchUntilState(State::VALIDATING);
dispatchUntilState(State::AWAITING_CMD_RUN_VALIDATED);

ASSERT_EQ(tester_get_m_sequenceFilePath(), Fw::String("test.bin"));

removeFile("test.bin");
}

TEST_F(FpySequencerTester, seqBaseDir_fileOpenLogsResolvedPath) {
// a base dir that doesn't exist makes file open fail. the FileOpenError
// event should report the fully resolved path, not the user-supplied one
allocMem();
paramSet_SEQ_BASE_DIR(Fw::ParamString("nonexistent_dir"), Fw::ParamValid::VALID);
paramSend_SEQ_BASE_DIR(0, 0);
this->clearHistory();

sendCmd_VALIDATE(0, 0, Fw::String("test.bin"));
dispatchUntilState(State::VALIDATING);
dispatchUntilState(State::IDLE);

ASSERT_EVENTS_FileOpenError_SIZE(1);
ASSERT_EQ(this->eventHistory_FileOpenError->at(0).filePath,
Fw::LogStringArg("nonexistent_dir/test.bin"));
}

TEST_F(FpySequencerTester, prmSeqBaseDirTlm) {
// setting the param should emit the telemetry channel via parameterUpdated
Fw::ParamString val("/seq");
paramSet_SEQ_BASE_DIR(val, Fw::ParamValid::VALID);
paramSend_SEQ_BASE_DIR(0, 0);

ASSERT_TLM_PRM_SEQ_BASE_DIR_SIZE(1);
ASSERT_TLM_PRM_SEQ_BASE_DIR(0, val.toChar());
}

Comment thread
LeStarch marked this conversation as resolved.
TEST_F(FpySequencerTester, allocateBuffer) {
Fw::MallocAllocator alloc;
cmp.allocateBuffer(0, alloc, 100);
Expand Down
4 changes: 4 additions & 0 deletions default/config/FpySequencerCfg.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@ module Svc {
dictionary constant MAX_STACK_SIZE = 65535
@ the maximum number of bytes in a directive
dictionary constant MAX_DIRECTIVE_SIZE = 2048
@ the default value of the SEQ_BASE_DIR parameter. if a relative path or
@ empty, sequence paths are resolved relative to the process's current
@ working directory.
dictionary constant DEFAULT_SEQ_BASE_DIR = ""
}
}
Loading