Skip to content

Commit 5843907

Browse files
authored
Add args to CmdSeqIn (#4962)
* Add args to CmdSeqIn * Fix function header * Add RUN_ARGS handlers + UTs * Fix argument sizing / states * Removed cmd_RUN_VALIDATED_ARGS * Fix math * Fix comment * Formatting * Formatting
1 parent ebd2306 commit 5843907

23 files changed

Lines changed: 630 additions & 72 deletions

Svc/CmdSequencer/CmdSequencerImpl.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ void CmdSequencerComponentImpl::CS_RUN_cmdHandler(FwOpcodeType opCode,
100100
if (AUTO == this->m_stepMode) {
101101
this->m_runMode = RUNNING;
102102
if (this->isConnected_seqStartOut_OutputPort(0)) {
103-
this->seqStartOut_out(0, this->m_sequence->getStringFileName());
103+
// Create empty SeqArgs as placeholder
104+
// Use parameterized constructor to ensure m_size is initialized to 0
105+
Svc::SeqArgs emptyArgs{0, 0};
106+
this->seqStartOut_out(0, this->m_sequence->getStringFileName(), emptyArgs);
104107
}
105108
this->performCmd_Step();
106109
}
@@ -162,15 +165,21 @@ void CmdSequencerComponentImpl::doSequenceRun(const Fw::StringBase& filename) {
162165
if (AUTO == this->m_stepMode) {
163166
this->m_runMode = RUNNING;
164167
if (this->isConnected_seqStartOut_OutputPort(0)) {
165-
this->seqStartOut_out(0, this->m_sequence->getStringFileName());
168+
// Create empty SeqArgs as placeholder
169+
// Use parameterized constructor to ensure m_size is initialized to 0
170+
Svc::SeqArgs emptyArgs{0, 0};
171+
this->seqStartOut_out(0, this->m_sequence->getStringFileName(), emptyArgs);
166172
}
167173
this->performCmd_Step();
168174
}
169175

170176
this->log_ACTIVITY_HI_CS_PortSequenceStarted(this->m_sequence->getLogFileName());
171177
}
172178

173-
void CmdSequencerComponentImpl::seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename) {
179+
void CmdSequencerComponentImpl::seqRunIn_handler(FwIndexType portNum,
180+
const Fw::StringBase& filename,
181+
const Svc::SeqArgs& args) {
182+
(void)args; // Suppress unused parameter warning
174183
this->doSequenceRun(filename);
175184
}
176185

@@ -322,7 +331,9 @@ void CmdSequencerComponentImpl ::CS_START_cmdHandler(FwOpcodeType opcode, U32 cm
322331
this->performCmd_Step();
323332
this->log_ACTIVITY_HI_CS_CmdStarted(this->m_sequence->getLogFileName());
324333
if (this->isConnected_seqStartOut_OutputPort(0)) {
325-
this->seqStartOut_out(0, this->m_sequence->getStringFileName());
334+
// Create empty SeqArgs as placeholder
335+
Svc::SeqArgs emptyArgs{0, 0};
336+
this->seqStartOut_out(0, this->m_sequence->getStringFileName(), emptyArgs);
326337
}
327338
this->cmdResponse_out(opcode, cmdSeq, Fw::CmdResponse::OK);
328339
}

Svc/CmdSequencer/CmdSequencerImpl.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,9 @@ class CmdSequencerComponentImpl final : public CmdSequencerComponentBase {
519519
) override;
520520

521521
//! Handler for input port seqRunIn
522-
void seqRunIn_handler(FwIndexType portNum, //!< The port number
523-
const Fw::StringBase& filename //!< The sequence file
522+
void seqRunIn_handler(FwIndexType portNum, //!< The port number
523+
const Fw::StringBase& filename, //!< The sequence file
524+
const Svc::SeqArgs& args //!< Sequence arguments (not currently used)
524525
) override;
525526

526527
//! Handler implementation for seqDispatchIn

Svc/CmdSequencer/Commands.fppi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
@ Run a command sequence file
44
async command CS_RUN(
5-
fileName: string size 240 @< The name of the sequence file
5+
fileName: string size FileNameStringSize @< The name of the sequence file
66
$block: BlockState @< Return command status when complete or not
77
) \
88
opcode 0
99

1010
@ Validate a command sequence file
1111
async command CS_VALIDATE(
12-
fileName: string size 240 @< The name of the sequence file
12+
fileName: string size FileNameStringSize @< The name of the sequence file
1313
) \
1414
opcode 1
1515

Svc/CmdSequencer/test/ut/CmdSequencerTester.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ void CmdSequencerTester ::parameterizedDataReadErrors(SequenceFiles::File& file)
271271
void CmdSequencerTester ::parameterizedNeverLoaded() {
272272
// Try to run a sequence
273273
Fw::String fArg("");
274-
this->invoke_to_seqRunIn(0, fArg);
274+
Svc::SeqArgs emptyArgs{0, 0};
275+
this->invoke_to_seqRunIn(0, fArg, emptyArgs);
275276
this->clearAndDispatch();
276277
// Assert seqDone response
277278
ASSERT_from_seqDone_SIZE(1);
@@ -474,7 +475,8 @@ void CmdSequencerTester ::runSequence(const U32 cmdSeq, const char* const fileNa
474475
void CmdSequencerTester ::runSequenceByPortCall(const char* const fileName) {
475476
// Invoke the seqRun port
476477
Fw::String fArg(fileName);
477-
this->invoke_to_seqRunIn(0, fArg);
478+
Svc::SeqArgs emptyArgs{0, 0};
479+
this->invoke_to_seqRunIn(0, fArg, emptyArgs);
478480
this->clearAndDispatch();
479481
// Assert no command response
480482
ASSERT_CMD_RESPONSE_SIZE(0);
@@ -500,7 +502,8 @@ void CmdSequencerTester ::runSequenceByFileDispatcherPortCall(const char* const
500502
void CmdSequencerTester ::runLoadedSequence() {
501503
// Invoke the port
502504
Fw::String fArg("");
503-
this->invoke_to_seqRunIn(0, fArg);
505+
Svc::SeqArgs emptyArgs{0, 0};
506+
this->invoke_to_seqRunIn(0, fArg, emptyArgs);
504507
this->clearAndDispatch();
505508
// Assert no command response
506509
ASSERT_CMD_RESPONSE_SIZE(0);
@@ -530,7 +533,8 @@ void CmdSequencerTester ::startNewSequence(const char* const fileName) {
530533
ASSERT_EVENTS_CS_InvalidMode_SIZE(1);
531534
// Invoke sequence port
532535
Fw::String fArg(fileName);
533-
this->invoke_to_seqRunIn(0, fArg);
536+
Svc::SeqArgs emptyArgs{0, 0};
537+
this->invoke_to_seqRunIn(0, fArg, emptyArgs);
534538
this->clearAndDispatch();
535539
// Assert response on seqDone
536540
ASSERT_from_seqDone_SIZE(1);

Svc/CmdSequencer/test/ut/ImmediateBase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ void CmdSequencerTester ::parameterizedLoadRunRun(SequenceFiles::File& file, con
166166
this->parameterizedAutoByPort(file, numCommands, bound);
167167
// Try to run a loaded sequence
168168
Fw::String fArg("");
169-
this->invoke_to_seqRunIn(0, fArg);
169+
Svc::SeqArgs emptyArgs{0, 0};
170+
this->invoke_to_seqRunIn(0, fArg, emptyArgs);
170171
this->clearAndDispatch();
171172
// Assert seqDone response
172173
ASSERT_from_seqDone_SIZE(1);

Svc/CmdSequencer/test/ut/InvalidFiles.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ void CmdSequencerTester ::MissingCRC() {
218218
ASSERT_TLM_CS_Errors(0, 2);
219219
// Run the sequence by port call
220220
Fw::String fArg(file.getName());
221-
this->invoke_to_seqRunIn(0, fArg);
221+
Svc::SeqArgs emptyArgs{0, 0};
222+
this->invoke_to_seqRunIn(0, fArg, emptyArgs);
222223
this->clearAndDispatch();
223224
// Assert seqDone response
224225
ASSERT_from_seqDone_SIZE(1);

Svc/FpySequencer/FpySequencer.cpp

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ void FpySequencer::RUN_cmdHandler(FwOpcodeType opCode, //!< The op
3939
U32 cmdSeq, //!< The command sequence number
4040
const Fw::CmdStringArg& fileName, //!< The name of the sequence file
4141
FpySequencer_BlockState block //!< Return command status when complete or not
42+
) {
43+
// Empty args and delegate to RUN_ARGS handler
44+
this->RUN_ARGS_cmdHandler(opCode, cmdSeq, fileName, block, Svc::SeqArgs{0, 0});
45+
}
46+
47+
void FpySequencer ::RUN_ARGS_cmdHandler(
48+
FwOpcodeType opCode, //!< The opcode
49+
U32 cmdSeq, //!< The command sequence number
50+
const Fw::CmdStringArg& fileName, //!< The name of the sequence file
51+
Svc::FpySequencer_BlockState block, //!< Return command status when complete or not
52+
Svc::SeqArgs args //!< Arguments to pass to the sequencer
4253
) {
4354
// can only run a seq while in idle
4455
if (sequencer_getState() != State::IDLE) {
@@ -53,7 +64,8 @@ void FpySequencer::RUN_cmdHandler(FwOpcodeType opCode, //!< The op
5364
this->m_savedCmdSeq = cmdSeq;
5465
}
5566

56-
this->sequencer_sendSignal_cmd_RUN(FpySequencer_SequenceExecutionArgs(fileName, block));
67+
// Store args for pushArgsToStack action
68+
this->sequencer_sendSignal_cmd_RUN(FpySequencer_SequenceExecutionArgs(fileName, block, args));
5769

5870
// only respond if the user doesn't want us to block further execution
5971
if (block == FpySequencer_BlockState::NO_BLOCK) {
@@ -68,6 +80,16 @@ void FpySequencer::VALIDATE_cmdHandler(FwOpcodeType opCode, //!< Th
6880
U32 cmdSeq, //!< The command sequence number
6981
const Fw::CmdStringArg& fileName //!< The name of the sequence file
7082
) {
83+
this->VALIDATE_ARGS_cmdHandler(opCode, cmdSeq, fileName, Svc::SeqArgs{0, 0});
84+
}
85+
86+
//! Handler implementation for command VALIDATE_ARGS
87+
//!
88+
//! Loads and validates a sequence with arguments
89+
void FpySequencer ::VALIDATE_ARGS_cmdHandler(FwOpcodeType opCode,
90+
U32 cmdSeq,
91+
const Fw::CmdStringArg& fileName,
92+
Svc::SeqArgs buffer) {
7193
// can only validate a seq while in idle
7294
if (sequencer_getState() != State::IDLE) {
7395
this->log_WARNING_HI_InvalidCommand(static_cast<I32>(sequencer_getState()));
@@ -80,13 +102,12 @@ void FpySequencer::VALIDATE_cmdHandler(FwOpcodeType opCode, //!< Th
80102
this->m_savedOpCode = opCode;
81103
this->m_savedCmdSeq = cmdSeq;
82104

105+
// VALIDATE_ARGS receives args via command interface
106+
// Store args for pushArgsToStack action when RUN_VALIDATED is called
83107
this->sequencer_sendSignal_cmd_VALIDATE(
84-
FpySequencer_SequenceExecutionArgs(fileName, FpySequencer_BlockState::BLOCK));
108+
FpySequencer_SequenceExecutionArgs(fileName, FpySequencer_BlockState::BLOCK, buffer));
85109
}
86110

87-
//! Handler for command RUN_VALIDATED
88-
//!
89-
//! Runs a previously validated sequence
90111
void FpySequencer::RUN_VALIDATED_cmdHandler(
91112
FwOpcodeType opCode, //!< The opcode
92113
U32 cmdSeq, //!< The command sequence number
@@ -105,7 +126,8 @@ void FpySequencer::RUN_VALIDATED_cmdHandler(
105126
this->m_savedCmdSeq = cmdSeq;
106127
}
107128

108-
this->sequencer_sendSignal_cmd_RUN_VALIDATED(FpySequencer_SequenceExecutionArgs(this->m_sequenceFilePath, block));
129+
this->sequencer_sendSignal_cmd_RUN_VALIDATED(
130+
FpySequencer_SequenceExecutionArgs(this->m_sequenceFilePath, block, this->m_sequenceArgs));
109131

110132
// only respond if the user doesn't want us to block further execution
111133
if (block == FpySequencer_BlockState::NO_BLOCK) {
@@ -358,15 +380,17 @@ void FpySequencer::cmdResponseIn_handler(FwIndexType portNum, //!< T
358380
}
359381

360382
//! Handler for input port seqRunIn
361-
void FpySequencer::seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename) {
383+
void FpySequencer::seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename, const Svc::SeqArgs& args) {
362384
// can only run a seq while in idle
363385
if (sequencer_getState() != State::IDLE) {
364386
this->log_WARNING_HI_InvalidSeqRunCall(static_cast<I32>(sequencer_getState()));
365387
return;
366388
}
367389

368-
// seqRunIn is never blocking
369-
this->sequencer_sendSignal_cmd_RUN(FpySequencer_SequenceExecutionArgs(filename, FpySequencer_BlockState::NO_BLOCK));
390+
// seqRunIn is never blocking - store args for pushArgsToStack action
391+
// Args must be serialized in F' big-endian format by the caller before being sent
392+
this->sequencer_sendSignal_cmd_RUN(
393+
FpySequencer_SequenceExecutionArgs(filename, FpySequencer_BlockState::NO_BLOCK, args));
370394
}
371395

372396
//! Handler for input port tlmWrite

Svc/FpySequencer/FpySequencer.hpp

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class FpySequencer : public FpySequencerComponentBase {
104104
// pushes a byte array to the top of the stack from the source array
105105
// leaves the source array unmodified
106106
// does not convert endianness
107-
void push(U8* src, Fpy::StackSizeType size);
107+
void push(const U8* src, Fpy::StackSizeType size);
108108

109109
// pushes zero bytes to the stack
110110
void pushZeroes(Fpy::StackSizeType byteCount);
@@ -146,6 +146,14 @@ class FpySequencer : public FpySequencerComponentBase {
146146
FpySequencer_BlockState block //!< Return command status when complete or not
147147
) override;
148148

149+
//! Handler implementation for command RUN_ARGS
150+
void RUN_ARGS_cmdHandler(FwOpcodeType opCode, //!< The opcode
151+
U32 cmdSeq, //!< The command sequence number
152+
const Fw::CmdStringArg& fileName, //!< The name of the sequence file
153+
Svc::FpySequencer_BlockState block, //!< Return command status when complete or not
154+
Svc::SeqArgs args //!< Arguments to pass to the sequencer
155+
) override;
156+
149157
//! Handler for command VALIDATE
150158
//!
151159
//! Loads and validates a sequence
@@ -154,12 +162,21 @@ class FpySequencer : public FpySequencerComponentBase {
154162
const Fw::CmdStringArg& fileName //!< The name of the sequence file
155163
) override;
156164

157-
//! Handler for command RUN_VALIDATED
165+
//! Handler implementation for command VALIDATE_ARGS
166+
//!
167+
//! Loads and validates a sequence with arguments
168+
void VALIDATE_ARGS_cmdHandler(FwOpcodeType opCode, //!< The opcode
169+
U32 cmdSeq, //!< The command sequence number
170+
const Fw::CmdStringArg& fileName, //!< The name of the sequence file
171+
Svc::SeqArgs buffer //!< Arguments to pass to the sequencer
172+
) override;
173+
174+
//! Handler implementation for command RUN_VALIDATED
158175
//!
159-
//! Runs a previously validated sequence
160-
void RUN_VALIDATED_cmdHandler(FwOpcodeType opCode, //!< The opcode
161-
U32 cmdSeq, //!< The command sequence number
162-
FpySequencer_BlockState block //!< Return command status when complete or not
176+
//! Must be called after VALIDATE. Runs the sequence that was validated.
177+
void RUN_VALIDATED_cmdHandler(FwOpcodeType opCode, //!< The opcode
178+
U32 cmdSeq, //!< The command sequence number
179+
Svc::FpySequencer_BlockState block //!< Return command status when complete or not
163180
) override;
164181

165182
//! Handler for command CANCEL
@@ -253,6 +270,15 @@ class FpySequencer : public FpySequencerComponentBase {
253270
const Svc::FpySequencer_SequenceExecutionArgs& value //!< The value
254271
) override;
255272

273+
//! Implementation for action setSequenceArguments of state machine Svc_FpySequencer_SequencerStateMachine
274+
//!
275+
//! sets the arguments to pass to the sequence
276+
void Svc_FpySequencer_SequencerStateMachine_action_setSequenceArguments(
277+
SmId smId, //!< The state machine id
278+
Svc_FpySequencer_SequencerStateMachine::Signal signal, //!< The signal
279+
const Svc::FpySequencer_SequenceExecutionArgs& value //!< The value
280+
) override;
281+
256282
//! Implementation for action validate of state machine Svc_FpySequencer_SequencerStateMachine
257283
//!
258284
//! performs all steps necessary for sequence validation, and raises a signal result_success or result_failure
@@ -334,6 +360,14 @@ class FpySequencer : public FpySequencerComponentBase {
334360
Svc_FpySequencer_SequencerStateMachine::Signal signal //!< The signal
335361
) override;
336362

363+
//! Implementation for action clearSequenceArguments of state machine Svc_FpySequencer_SequencerStateMachine
364+
//!
365+
//! clears arguments
366+
void Svc_FpySequencer_SequencerStateMachine_action_clearSequenceArguments(
367+
SmId smId, //!< The state machine id
368+
Svc_FpySequencer_SequencerStateMachine::Signal signal //!< The signal
369+
) override;
370+
337371
//! Implementation for action checkShouldWake of state machine Svc_FpySequencer_SequencerStateMachine
338372
//!
339373
//! checks if sequencer should wake from sleep
@@ -366,6 +400,14 @@ class FpySequencer : public FpySequencerComponentBase {
366400
Svc_FpySequencer_SequencerStateMachine::Signal signal //!< The signal
367401
) override;
368402

403+
//! Implementation for action pushArgsToStack of state machine Svc_FpySequencer_SequencerStateMachine
404+
//!
405+
//! pushes sequence arguments to the stack
406+
void Svc_FpySequencer_SequencerStateMachine_action_pushArgsToStack(
407+
SmId smId, //!< The state machine id
408+
Svc_FpySequencer_SequencerStateMachine::Signal signal //!< The signal
409+
) override;
410+
369411
//! Implementation for action clearBreakpoint of state machine Svc_FpySequencer_SequencerStateMachine
370412
//!
371413
//! clears the breakpoint, allowing execution of the sequence to continue
@@ -470,7 +512,7 @@ class FpySequencer : public FpySequencerComponentBase {
470512
) override;
471513

472514
//! Handler for input port seqRunIn
473-
void seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename) override;
515+
void seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename, const Svc::SeqArgs& args) override;
474516

475517
//! Handler for input port pingIn
476518
void pingIn_handler(FwIndexType portNum, //!< The port number
@@ -600,6 +642,9 @@ class FpySequencer : public FpySequencerComponentBase {
600642
FwOpcodeType m_savedOpCode;
601643
U32 m_savedCmdSeq;
602644

645+
// sequence arguments to push to stack when entering RUNNING state
646+
Svc::SeqArgs m_sequenceArgs{};
647+
603648
// the goal state is the state that we're trying to reach in the sequencer
604649
// if it's RUNNING, then we should promptly go to RUNNING once we validate the
605650
// sequence. if it's VALID, we should wait after VALIDATING

0 commit comments

Comments
 (0)