GCC Code Coverage Report


Directory: ./
File: Svc/FpySequencer/FpySequencer.cpp
Date: 2026-09-23 22:11:34
Exec Total Coverage
Lines: 0 249 0.0%
Functions: 0 24 0.0%
Branches: 0 231 0.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title FpySequencer.cpp
3 // \author zimri.leisher
4 // \brief cpp file for FpySequencer component implementation class
5 // ======================================================================
6
7 #include <Fw/Prm/ParamValid.hpp>
8 #include <Svc/FpySequencer/FpySequencer.hpp>
9 #include <config/CommandDispatcherImplCfg.hpp>
10 #include <new>
11
12 namespace Svc {
13
14 // ----------------------------------------------------------------------
15 // Construction, initialization, and destruction
16 // ----------------------------------------------------------------------
17
18 ✗ FpySequencer ::FpySequencer(const char* const compName)
19 : FpySequencerComponentBase(compName),
20 ✗ m_sequenceBuffer(),
21 ✗ m_allocatorId(0),
22 ✗ m_sequenceFilePath("<invalid_seq>"),
23 ✗ m_sequenceObj(),
24 ✗ m_computedCRC(),
25 ✗ m_totalExpectedArgSize(0),
26 ✗ m_sequenceBlockState(),
27 ✗ m_savedOpCode(0),
28 ✗ m_savedCmdSeq(0),
29 ✗ m_sequenceArgs(0, 0),
30 ✗ m_goalState(),
31 ✗ m_sequencesStarted(0),
32 ✗ m_statementsDispatched(0),
33 ✗ m_runtime(),
34 ✗ m_breakpoint(),
35 ✗ m_debug(),
36 ✗ m_tlm() {}
37
38 ✗ FpySequencer ::~FpySequencer() {}
39
40 //! Handler for command RUN
41 //!
42 //! Loads, validates and runs a sequence
43 ✗ void FpySequencer::RUN_cmdHandler(FwOpcodeType opCode, //!< The opcode
44 U32 cmdSeq, //!< The command sequence number
45 const Fw::CmdStringArg& fileName, //!< The name of the sequence file
46 const BlockState& block //!< Return command status when complete or not
47 ) {
48 // Empty args and delegate to RUN_ARGS handler
49 ✗ this->RUN_ARGS_cmdHandler(opCode, cmdSeq, fileName, block, Svc::SeqArgs{0, 0});
50 ✗ }
51
52 ✗ void FpySequencer ::RUN_ARGS_cmdHandler(FwOpcodeType opCode, //!< The opcode
53 U32 cmdSeq, //!< The command sequence number
54 const Fw::CmdStringArg& fileName, //!< The name of the sequence file
55 const Svc::BlockState& block, //!< Return command status when complete or not
56 const Svc::SeqArgs& args //!< Arguments to pass to the sequencer
57 ) {
58 // can only run a seq while in idle
59 ✗ if (sequencer_getState() != State::IDLE) {
60 ✗ this->log_WARNING_HI_InvalidCommand(static_cast<I32>(sequencer_getState()));
61 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
62 ✗ return;
63 }
64
65 ✗ if (block == BlockState::BLOCK) {
66 // save the opCode and cmdSeq so we can respond later
67 ✗ this->m_savedOpCode = opCode;
68 ✗ this->m_savedCmdSeq = cmdSeq;
69 }
70
71 // Store args for pushArgsToStack action
72 ✗ this->sequencer_sendSignal_cmd_RUN(FpySequencer_SequenceExecutionArgs(fileName, block, args));
73
74 // only respond if the user doesn't want us to block further execution
75 ✗ if (block == BlockState::NO_BLOCK) {
76 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
77 }
78 }
79
80 //! Handler for command VALIDATE
81 //!
82 //! Loads and validates a sequence
83 ✗ void FpySequencer::VALIDATE_cmdHandler(FwOpcodeType opCode, //!< The opcode
84 U32 cmdSeq, //!< The command sequence number
85 const Fw::CmdStringArg& fileName //!< The name of the sequence file
86 ) {
87 ✗ this->VALIDATE_ARGS_cmdHandler(opCode, cmdSeq, fileName, Svc::SeqArgs{0, 0});
88 ✗ }
89
90 //! Handler implementation for command VALIDATE_ARGS
91 //!
92 //! Loads and validates a sequence with arguments
93 ✗ void FpySequencer ::VALIDATE_ARGS_cmdHandler(FwOpcodeType opCode,
94 U32 cmdSeq,
95 const Fw::CmdStringArg& fileName,
96 const Svc::SeqArgs& buffer) {
97 // can only validate a seq while in idle
98 ✗ if (sequencer_getState() != State::IDLE) {
99 ✗ this->log_WARNING_HI_InvalidCommand(static_cast<I32>(sequencer_getState()));
100 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
101 ✗ return;
102 }
103
104 // validate always blocks until finished, so save opcode/cmdseq
105 // so we can respond once done
106 ✗ this->m_savedOpCode = opCode;
107 ✗ this->m_savedCmdSeq = cmdSeq;
108
109 // VALIDATE_ARGS receives args via command interface
110 // Store args for pushArgsToStack action when RUN_VALIDATED is called
111 ✗ this->sequencer_sendSignal_cmd_VALIDATE(FpySequencer_SequenceExecutionArgs(fileName, BlockState::BLOCK, buffer));
112 }
113
114 ✗ void FpySequencer::RUN_VALIDATED_cmdHandler(FwOpcodeType opCode, //!< The opcode
115 U32 cmdSeq, //!< The command sequence number
116 const BlockState& block //!< Return command status when complete or not
117 ) {
118 // can only RUN_VALIDATED if we have validated and are awaiting this exact cmd
119 ✗ if (sequencer_getState() != State::AWAITING_CMD_RUN_VALIDATED) {
120 ✗ this->log_WARNING_HI_InvalidCommand(static_cast<I32>(sequencer_getState()));
121 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
122 ✗ return;
123 }
124
125 ✗ if (block == BlockState::BLOCK) {
126 // save the opCode and cmdSeq so we can respond later
127 ✗ this->m_savedOpCode = opCode;
128 ✗ this->m_savedCmdSeq = cmdSeq;
129 }
130
131 ✗ this->sequencer_sendSignal_cmd_RUN_VALIDATED(
132 ✗ FpySequencer_SequenceExecutionArgs(this->m_sequenceFilePath, block, this->m_sequenceArgs));
133
134 // only respond if the user doesn't want us to block further execution
135 ✗ if (block == BlockState::NO_BLOCK) {
136 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
137 }
138 }
139
140 //! Handler for command CANCEL
141 //!
142 //! Cancels a running or validated sequence
143 ✗ void FpySequencer::CANCEL_cmdHandler(FwOpcodeType opCode, //!< The opcode
144 U32 cmdSeq //!< The command sequence number
145 ) {
146 // only state you can't cancel in is IDLE
147 ✗ if (sequencer_getState() == State::IDLE) {
148 ✗ this->log_WARNING_HI_InvalidCommand(static_cast<I32>(sequencer_getState()));
149 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
150 ✗ return;
151 }
152
153 ✗ this->sequencer_sendSignal_cmd_CANCEL();
154
155 // cancel returns immediately and always succeeds
156 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
157 }
158
159 //! Handler for command SET_BREAKPOINT
160 //!
161 //! Sets the breakpoint which will pause the execution of the sequencer when
162 //! reached, until unpaused by the CONTINUE command. Will pause just before
163 //! dispatching the specified statement. This command is valid in all states. Breakpoint
164 //! settings are cleared after a sequence ends execution.
165 ✗ void FpySequencer::SET_BREAKPOINT_cmdHandler(FwOpcodeType opCode, //!< The opcode
166 U32 cmdSeq, //!< The command sequence number
167 U32 stmtIdx, //!< The statement index to pause execution before.
168 bool breakOnce //!< Whether or not to break only once at this breakpoint
169 ) {
170 ✗ this->sequencer_sendSignal_cmd_SET_BREAKPOINT(FpySequencer_BreakpointArgs(true, breakOnce, stmtIdx));
171
172 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
173 ✗ }
174
175 //! Handler for command BREAK
176 //!
177 //! Pauses the execution of the sequencer, just before it is about to dispatch the next statement,
178 //! until unpaused by the CONTINUE command, or stepped by the STEP command. This command is only valid
179 //! in substates of the RUNNING state that are not RUNNING.PAUSED.
180 ✗ void FpySequencer::BREAK_cmdHandler(FwOpcodeType opCode, //!< The opcode
181 U32 cmdSeq //!< The command sequence number
182 ) {
183 ✗ if (!this->isRunningState(this->sequencer_getState()) || this->sequencer_getState() == State::RUNNING_PAUSED) {
184 // can only break while running, and not paused
185 ✗ this->log_WARNING_HI_InvalidCommand(static_cast<I32>(sequencer_getState()));
186 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
187 ✗ return;
188 }
189 ✗ this->sequencer_sendSignal_cmd_BREAK();
190
191 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
192 }
193
194 //! Handler for command CONTINUE
195 //!
196 //! Continues the automatic execution of the sequence after it has been paused. If a breakpoint is still
197 //! set, it may pause again on that breakpoint. This command is only valid in the RUNNING.PAUSED state.
198 ✗ void FpySequencer::CONTINUE_cmdHandler(FwOpcodeType opCode, //!< The opcode
199 U32 cmdSeq //!< The command sequence number
200 ) {
201 ✗ if (this->sequencer_getState() != State::RUNNING_PAUSED) {
202 ✗ this->log_WARNING_HI_InvalidCommand(static_cast<I32>(sequencer_getState()));
203 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
204 ✗ return;
205 }
206
207 ✗ this->sequencer_sendSignal_cmd_CONTINUE();
208
209 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
210 }
211
212 //! Handler for command CLEAR_BREAKPOINT
213 //!
214 //! Clears the breakpoint, but does not continue executing the sequence. This command
215 //! is valid in all states. This happens automatically when a sequence ends execution.
216 ✗ void FpySequencer::CLEAR_BREAKPOINT_cmdHandler(FwOpcodeType opCode, //!< The opcode
217 U32 cmdSeq //!< The command sequence number
218 ) {
219 ✗ this->sequencer_sendSignal_cmd_CLEAR_BREAKPOINT();
220 ✗ this->log_ACTIVITY_HI_BreakpointCleared();
221
222 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
223 ✗ }
224
225 //! Handler for command STEP
226 //!
227 //! Dispatches and awaits the result of the next directive, or ends the sequence if no more directives remain.
228 //! Returns to the RUNNING.PAUSED state if the directive executes successfully. This command is only valid in the
229 //! RUNNING.PAUSED state.
230 ✗ void FpySequencer::STEP_cmdHandler(FwOpcodeType opCode, //!< The opcode
231 U32 cmdSeq //!< The command sequence number
232 ) {
233 ✗ if (this->sequencer_getState() != State::RUNNING_PAUSED) {
234 ✗ this->log_WARNING_HI_InvalidCommand(static_cast<I32>(sequencer_getState()));
235 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
236 ✗ return;
237 }
238
239 ✗ this->sequencer_sendSignal_cmd_STEP();
240 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
241 }
242
243 //! Handler for command DUMP_STACK_TO_FILE
244 //!
245 //! Writes the contents of the stack to a file. This command is only valid in the RUNNING.PAUSED state.
246 ✗ void FpySequencer::DUMP_STACK_TO_FILE_cmdHandler(FwOpcodeType opCode, //!< The opcode
247 U32 cmdSeq, //!< The command sequence number
248 const Fw::CmdStringArg& fileName //!< The name of the output file
249 ) {
250 ✗ if (this->sequencer_getState() != State::RUNNING_PAUSED) {
251 ✗ this->log_WARNING_HI_InvalidCommand(static_cast<I32>(sequencer_getState()));
252 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
253 ✗ return;
254 }
255 ✗ Os::File sequenceFile;
256 ✗ Os::File::Status status = sequenceFile.open(fileName.toChar(), Os::File::OPEN_WRITE);
257
258 ✗ if (status != Os::File::Status::OP_OK) {
259 ✗ this->log_WARNING_HI_FileOpenError(fileName, static_cast<I32>(status));
260 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
261 ✗ return;
262 }
263
264 ✗ FwSizeType writeSize = static_cast<FwSizeType>(this->m_runtime.stack.size);
265 ✗ status = sequenceFile.write(this->m_runtime.stack.bytes, writeSize);
266 ✗ if (status != Os::File::Status::OP_OK || writeSize != this->m_runtime.stack.size) {
267 ✗ this->log_WARNING_HI_FileWriteError(writeSize, fileName, static_cast<I32>(status));
268 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
269 ✗ return;
270 }
271 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
272 ✗ return;
273 ✗ }
274 //! Handler for input port checkTimers
275 ✗ void FpySequencer::checkTimers_handler(FwIndexType portNum, //!< The port number
276 U32 context //!< The call order
277 ) {
278 ✗ this->sequencer_sendSignal_checkTimersIn();
279 ✗ }
280
281 ✗ void FpySequencer::pingIn_handler(FwIndexType portNum, /*!< The port number*/
282 U32 key /*!< Value to return to pinger*/
283 ) {
284 // send ping response
285 ✗ this->pingOut_out(0, key);
286 ✗ }
287
288 //! Handler for input port cmdResponseIn
289 ✗ void FpySequencer::cmdResponseIn_handler(FwIndexType portNum, //!< The port number
290 FwOpcodeType opCode, //!< Command Op Code
291 U32 cmdSeq, //!< Command Sequence
292 const Fw::CmdResponse& response //!< The command response argument
293 ) {
294 // if we aren't in the RUNNING state:
295 ✗ if (!this->isRunningState(sequencer_getState())) {
296 // must be a coding error from an outside component (off nom), or due to CANCEL while running a command (nom).
297 // because we can't be sure that it wasn't a nominal sequence of events leading to this, don't fail the
298 // sequence, just report it
299 ✗ this->log_WARNING_LO_CmdResponseWhileNotRunningSequence(static_cast<I32>(this->sequencer_getState()),
300 CmdDispatcherCfg::getEventOpcode(opCode), response);
301 ✗ return;
302 }
303
304 // okay, we're running a sequence. now let's use the cmdUid to check if the response was for a cmd
305 // from this sequence
306
307 // the cmdSeq arg is confusingly not the cmdSeq in this case, according to the current implementation
308 // of the CmdDisp. instead, it is the context that we passed in when we originally sent the cmd out.
309 // this context is in turn the cmdUid that we calculated just before sending it. rename the variable for
310 // clarity's sake
311 ✗ U32 cmdUid = cmdSeq;
312
313 // pull the sequence index (modulo 2^16) out of the cmdUid. see the comment in FpySequencer::dispatchCommand
314 // for info on the binary format of this cmdUid. as a reminder, this should be equal to the first 16 bits of
315 // the m_sequencesStarted variable
316 ✗ U16 sequenceIndex = static_cast<U16>((cmdUid & 0xFFFF0000) >> 16);
317 ✗ U16 currentSequenceIndex = static_cast<U16>(this->m_sequencesStarted & 0xFFFF);
318
319 // if it was from a different sequence:
320 ✗ if (sequenceIndex != currentSequenceIndex) {
321 ✗ this->log_WARNING_LO_CmdResponseFromOldSequence(CmdDispatcherCfg::getEventOpcode(opCode), response,
322 sequenceIndex, currentSequenceIndex);
323 ✗ return;
324 }
325
326 // okay, it was from this sequence. now if anything's wrong from this point on we should fail the sequence
327
328 // first, make sure we're actually awaiting a statement response
329 ✗ if (this->sequencer_getState() != State::RUNNING_AWAITING_STATEMENT_RESPONSE) {
330 // okay, crap. something from this sequence responded, and we weren't awaiting anything. end it all
331 ✗ this->log_WARNING_HI_CmdResponseWhileNotAwaiting(CmdDispatcherCfg::getEventOpcode(opCode), response);
332 ✗ this->sequencer_sendSignal_stmtResponse_unexpected();
333 ✗ return;
334 }
335
336 ✗ if (this->m_runtime.currentStatementOpcode != Fpy::DirectiveId::CONST_CMD &&
337 ✗ this->m_runtime.currentStatementOpcode != Fpy::DirectiveId::STACK_CMD) {
338 // we were not awaiting a cmd response, we were waiting for a directive
339 ✗ this->log_WARNING_HI_CmdResponseWhileAwaitingDirective(CmdDispatcherCfg::getEventOpcode(opCode), response,
340 ✗ this->m_runtime.currentStatementOpcode);
341 ✗ this->sequencer_sendSignal_stmtResponse_unexpected();
342 ✗ return;
343 }
344
345 // okay, we were awaiting a cmd response. were we awaiting this opcode?
346 ✗ if (opCode != this->m_runtime.currentCmdOpcode) {
347 // we were not awaiting this opcode. coding error, likely on the part of the responding component or cmd
348 // dispatcher
349 ✗ this->log_WARNING_HI_WrongCmdResponseOpcode(CmdDispatcherCfg::getEventOpcode(opCode), response,
350 CmdDispatcherCfg::getEventOpcode(this->m_runtime.currentCmdOpcode));
351 ✗ this->sequencer_sendSignal_stmtResponse_unexpected();
352 ✗ return;
353 }
354
355 // okay, we were awaiting this opcode. but was it from this exact statement, or a different one with the same opcode
356 // in the same file?
357
358 // pull the cmd index (modulo 2^16) out of cmdUid. this should be equal to the first 16 bits of the
359 // m_statementsDispatched variable
360 ✗ U16 cmdIndex = static_cast<U16>(cmdUid & 0xFFFF);
361 // check for coding errors. at this point in the function, we have definitely dispatched a stmt
362 ✗ FW_ASSERT(this->m_statementsDispatched > 0);
363 ✗ U16 currentCmdIndex = static_cast<U16>((this->m_statementsDispatched) & 0xFFFF);
364
365 ✗ if (cmdIndex != currentCmdIndex) {
366 // we were not awaiting this exact statement, it was a different one with the same opcode. coding error
367 ✗ this->log_WARNING_HI_WrongCmdResponseIndex(CmdDispatcherCfg::getEventOpcode(opCode), response, cmdIndex,
368 currentCmdIndex);
369 ✗ this->sequencer_sendSignal_stmtResponse_unexpected();
370 ✗ return;
371 }
372
373 // okay, got the right cmd back. we have verified:
374 // 1) we are in the RUNNING state
375 // 2) the response is from this sequence
376 // 3) the response is from the correct opcode
377 // 4) the response is from the correct instance of that opcode in the sequence
378
379 // always succeed; the cmd response value is pushed to the stack so the sequence
380 // can branch on it if desired
381 ✗ this->sequencer_sendSignal_stmtResponse_success();
382
383 // push the cmd response to the stack so we can branch off of it
384 // the constCmd/stackCmd directive handlers guarantee there is room for this push
385 ✗ this->m_runtime.stack.push(static_cast<Fw::CmdResponse::SerialType>(response.e));
386 }
387
388 ✗ void FpySequencer ::seqCancelIn_handler(FwIndexType portNum) {
389 // only state you can't cancel in is IDLE
390 ✗ if (sequencer_getState() == State::IDLE) {
391 ✗ this->log_WARNING_HI_InvalidSeqCancelCall(static_cast<I32>(sequencer_getState()));
392 ✗ return;
393 }
394 ✗ this->sequencer_sendSignal_cmd_CANCEL();
395 }
396
397 //! Handler for input port seqRunIn
398 ✗ void FpySequencer::seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename, const Svc::SeqArgs& args) {
399 // can only run a seq while in idle
400 ✗ if (sequencer_getState() != State::IDLE) {
401 ✗ this->log_WARNING_HI_InvalidSeqRunCall(static_cast<I32>(sequencer_getState()));
402 ✗ return;
403 }
404
405 // seqRunIn is never blocking - store args for pushArgsToStack action
406 // Args must be serialized in F' big-endian format by the caller before being sent
407 ✗ this->sequencer_sendSignal_cmd_RUN(FpySequencer_SequenceExecutionArgs(filename, BlockState::NO_BLOCK, args));
408 }
409
410 //! Handler for input port tlmWrite
411 ✗ void FpySequencer::tlmWrite_handler(FwIndexType portNum, //!< The port number
412 U32 context //!< The call order
413 ) {
414 ✗ this->tlmWrite_State(static_cast<FwEnumStoreType>(this->sequencer_getState()));
415 ✗ this->tlmWrite_StatementsDispatched(this->m_statementsDispatched);
416 ✗ this->tlmWrite_StatementsFailed(this->m_tlm.statementsFailed);
417 ✗ this->tlmWrite_SequencesCancelled(this->m_tlm.sequencesCancelled);
418 ✗ this->tlmWrite_SequencesSucceeded(this->m_tlm.sequencesSucceeded);
419 ✗ this->tlmWrite_SequencesFailed(this->m_tlm.sequencesFailed);
420 ✗ this->tlmWrite_LastDirectiveError(this->m_tlm.lastDirectiveError);
421 ✗ this->tlmWrite_DirectiveErrorIndex(this->m_tlm.directiveErrorIndex);
422 ✗ this->tlmWrite_DirectiveErrorId(this->m_tlm.directiveErrorId);
423 ✗ this->tlmWrite_SeqPath(this->m_sequenceFilePath);
424
425 ✗ this->tlmWrite_BreakpointIndex(this->m_breakpoint.breakpointIndex);
426 ✗ this->tlmWrite_BreakOnlyOnceOnBreakpoint(this->m_breakpoint.breakOnlyOnceOnBreakpoint);
427 ✗ this->tlmWrite_BreakBeforeNextLine(this->m_breakpoint.breakBeforeNextLine);
428 ✗ this->tlmWrite_BreakpointInUse(this->m_breakpoint.breakpointInUse);
429
430 ✗ this->updateDebugTelemetryStruct();
431 ✗ this->tlmWrite_Debug_NextCmdOpcode(this->m_debug.nextCmdOpcode);
432 ✗ this->tlmWrite_Debug_NextStatementOpcode(this->m_debug.nextStatementOpcode);
433 ✗ this->tlmWrite_Debug_NextStatementReadSuccess(this->m_debug.nextStatementReadSuccess);
434 ✗ this->tlmWrite_Debug_NextStatementIndex(this->m_debug.nextStatementIndex);
435 ✗ this->tlmWrite_Debug_ReachedEndOfFile(this->m_debug.reachedEndOfFile);
436 ✗ this->tlmWrite_Debug_StackSize(this->m_debug.stackSize);
437 ✗ }
438
439 ✗ void FpySequencer::updateDebugTelemetryStruct() {
440 // only send debug tlm when we are paused
441 ✗ if (this->sequencer_getState() == State::RUNNING_PAUSED) {
442 ✗ if (this->m_runtime.nextStatementIndex >= this->m_sequenceObj.get_header().get_statementCount()) {
443 // reached end of file, turn on EOF flag and otherwise send some default tlm
444 ✗ this->m_debug.reachedEndOfFile = true;
445 ✗ this->m_debug.nextStatementReadSuccess = false;
446 ✗ this->m_debug.nextStatementOpcode = 0;
447 ✗ this->m_debug.nextCmdOpcode = 0;
448 ✗ this->m_debug.nextStatementIndex = this->m_runtime.nextStatementIndex;
449 ✗ this->m_debug.stackSize = this->m_runtime.stack.size;
450 ✗ return;
451 }
452
453 ✗ FW_ASSERT(this->m_runtime.nextStatementIndex < Fpy::MAX_SEQUENCE_STATEMENT_COUNT,
454 static_cast<FwAssertArgType>(this->m_runtime.nextStatementIndex));
455 ✗ const Fpy::Statement& nextStmt = this->m_sequenceObj.get_statements()[this->m_runtime.nextStatementIndex];
456 ✗ DirectiveUnion directiveUnion;
457 ✗ Fw::Success status = this->deserializeDirective(nextStmt, directiveUnion);
458
459 ✗ if (status != Fw::Success::SUCCESS) {
460 ✗ this->m_debug.reachedEndOfFile = false;
461 ✗ this->m_debug.nextStatementReadSuccess = false;
462 ✗ this->m_debug.nextStatementOpcode = nextStmt.get_opCode();
463 ✗ this->m_debug.nextCmdOpcode = 0;
464 ✗ this->m_debug.nextStatementIndex = this->m_runtime.nextStatementIndex;
465 ✗ this->m_debug.stackSize = this->m_runtime.stack.size;
466 ✗ return;
467 }
468
469 ✗ if (nextStmt.get_opCode() == Fpy::DirectiveId::CONST_CMD) {
470 // send opcode of the cmd to the ground
471 ✗ this->m_debug.reachedEndOfFile = false;
472 ✗ this->m_debug.nextStatementReadSuccess = true;
473 ✗ this->m_debug.nextStatementOpcode = nextStmt.get_opCode();
474 ✗ this->m_debug.nextCmdOpcode = directiveUnion.constCmd.get_opCode();
475 ✗ this->m_debug.nextStatementIndex = this->m_runtime.nextStatementIndex;
476 ✗ this->m_debug.stackSize = this->m_runtime.stack.size;
477 ✗ return;
478 }
479
480 ✗ this->m_debug.reachedEndOfFile = false;
481 ✗ this->m_debug.nextStatementReadSuccess = true;
482 ✗ this->m_debug.nextStatementOpcode = nextStmt.get_opCode();
483 ✗ this->m_debug.nextCmdOpcode = 0;
484 ✗ this->m_debug.nextStatementIndex = this->m_runtime.nextStatementIndex;
485 ✗ this->m_debug.stackSize = this->m_runtime.stack.size;
486 ✗ return;
487 ✗ }
488 // send some default tlm when we aren't in debug break
489 ✗ this->m_debug.reachedEndOfFile = false;
490 ✗ this->m_debug.nextStatementReadSuccess = false;
491 ✗ this->m_debug.nextStatementOpcode = 0;
492 ✗ this->m_debug.nextCmdOpcode = 0;
493 ✗ this->m_debug.nextStatementIndex = 0;
494 ✗ this->m_debug.stackSize = 0;
495 }
496
497 ✗ void FpySequencer::parametersLoaded() {
498 ✗ parameterUpdated(PARAMID_STATEMENT_TIMEOUT_SECS);
499 ✗ parameterUpdated(PARAMID_SEQ_BASE_DIR);
500 ✗ }
501
502 ✗ void FpySequencer::parameterUpdated(FwPrmIdType id) {
503 ✗ Fw::ParamValid valid;
504 ✗ switch (id) {
505 ✗ case PARAMID_STATEMENT_TIMEOUT_SECS: {
506 ✗ this->tlmWrite_PRM_STATEMENT_TIMEOUT_SECS(this->paramGet_STATEMENT_TIMEOUT_SECS(valid));
507 ✗ break;
508 }
509 ✗ case PARAMID_SEQ_BASE_DIR: {
510 ✗ this->tlmWrite_PRM_SEQ_BASE_DIR(this->paramGet_SEQ_BASE_DIR(valid));
511 ✗ break;
512 }
513 ✗ default: {
514 ✗ FW_ASSERT(false, static_cast<FwAssertArgType>(id)); // coding error, forgot to include in switch statement
515 }
516 }
517
518 ✗ FW_ASSERT(FW_PARAM_OK(valid), static_cast<FwAssertArgType>(valid.e));
519 ✗ }
520
521 ✗ bool FpySequencer::isRunningState(State state) {
522 // TODO ask Rob if there's a better way to check if we're in a superstate. I don't want to have
523 // to update this every time I add a new substate to the RUNNING state.
524
525 ✗ return state == State::RUNNING_AWAITING_STATEMENT_RESPONSE || state == State::RUNNING_DISPATCH_STATEMENT ||
526 ✗ state == State::RUNNING_PAUSED || state == State::RUNNING_SLEEPING;
527 }
528
529 } // namespace Svc
530