F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FpySequencerDirectives.cpp
Go to the documentation of this file.
1 #include <algorithm>
2 #include <cmath>
3 #include <cstring>
4 #include <type_traits>
5 #include "Fw/Com/ComPacket.hpp"
8 
9 namespace Svc {
10 
11 void FpySequencer::sendSignal(Signal signal) {
12  switch (signal) {
15  break;
16  }
19  break;
20  }
23  break;
24  }
27  break;
28  }
29  default: {
30  FW_ASSERT(false, static_cast<FwAssertArgType>(signal));
31  }
32  }
33 }
34 
35 // utility method for updating telemetry based on a directive error code
36 void FpySequencer::handleDirectiveErrorCode(Fpy::DirectiveId id, DirectiveError err) {
37  this->m_tlm.lastDirectiveError = err;
38  if (err != DirectiveError::NO_ERROR) {
39  this->m_tlm.directiveErrorIndex = this->currentStatementIdx();
40  this->m_tlm.directiveErrorId = id;
41  }
42 }
43 
44 Fw::Success FpySequencer::sendCmd(FwOpcodeType opcode, const U8* argBuf, FwSizeType argBufSize) {
45  Fw::ComBuffer cmdBuf;
46  Fw::SerializeStatus stat =
47  cmdBuf.serializeFrom(static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_COMMAND));
48  // TODO should I assert here? this really shouldn't fail, I should just add a static assert
49  // on com buf size and then assert here
51  return Fw::Success::FAILURE;
52  }
53  stat = cmdBuf.serializeFrom(opcode);
55  return Fw::Success::FAILURE;
56  }
57  stat = cmdBuf.serializeFrom(argBuf, argBufSize, Fw::Serialization::OMIT_LENGTH);
59  return Fw::Success::FAILURE;
60  }
61 
62  // calculate the unique command identifier:
63  // cmd UID is formatted like XXYY, where XX are the first two bytes of the m_sequencesStarted counter
64  // and YY are the first two bytes of the m_statementsDispatched counter.
65  // this way, we know when we get a cmd back A) whether or not it's from this sequence (modulo 2^16) and B)
66  // whether or not it's this specific instance of the cmd in the sequence, and not another one with the same opcode
67  // somewhere else in the file.
68  // if we put this uid in the context we send to the cmdDisp, we will get it back when the cmd returns
69  U32 cmdUid =
70  static_cast<U32>(((this->m_sequencesStarted & 0xFFFF) << 16) | (this->m_statementsDispatched & 0xFFFF));
71 
72  this->cmdOut_out(0, cmdBuf, cmdUid);
73 
74  return Fw::Success::SUCCESS;
75 }
76 
80  this->sendSignal(this->waitRel_directiveHandler(directive, error));
81  handleDirectiveErrorCode(Fpy::DirectiveId::WAIT_REL, error);
82 }
83 
87  this->sendSignal(this->waitAbs_directiveHandler(directive, error));
88  handleDirectiveErrorCode(Fpy::DirectiveId::WAIT_ABS, error);
89 }
90 
94  this->sendSignal(this->goto_directiveHandler(directive, error));
95  handleDirectiveErrorCode(Fpy::DirectiveId::GOTO, error);
96 }
97 
101  this->sendSignal(this->if_directiveHandler(directive, error));
102  handleDirectiveErrorCode(Fpy::DirectiveId::IF, error);
103 }
104 
108  this->sendSignal(this->noOp_directiveHandler(directive, error));
109  handleDirectiveErrorCode(Fpy::DirectiveId::NO_OP, error);
110 }
111 
114  const Svc::FpySequencer_PushTlmValDirective& directive) {
116  this->sendSignal(this->pushTlmVal_directiveHandler(directive, error));
117  handleDirectiveErrorCode(Fpy::DirectiveId::PUSH_TLM_VAL, error);
118 }
119 
124  this->sendSignal(this->pushTlmValAndTime_directiveHandler(directive, error));
125  handleDirectiveErrorCode(Fpy::DirectiveId::PUSH_TLM_VAL_AND_TIME, error);
126 }
127 
131  this->sendSignal(this->pushPrm_directiveHandler(directive, error));
132  handleDirectiveErrorCode(Fpy::DirectiveId::PUSH_PRM, error);
133 }
134 
138  this->sendSignal(this->constCmd_directiveHandler(directive, error));
139  handleDirectiveErrorCode(Fpy::DirectiveId::CONST_CMD, error);
140 }
141 
145  this->sendSignal(this->stackOp_directiveHandler(directive, error));
146  handleDirectiveErrorCode(directive.get__op(), error);
147 }
148 
152  this->sendSignal(this->exit_directiveHandler(directive, error));
153  handleDirectiveErrorCode(Fpy::DirectiveId::EXIT, error);
154 }
155 
159  this->sendSignal(this->allocate_directiveHandler(directive, error));
160  handleDirectiveErrorCode(Fpy::DirectiveId::ALLOCATE, error);
161 }
162 
167  this->sendSignal(this->storeRelConstOffset_directiveHandler(directive, error));
168  handleDirectiveErrorCode(Fpy::DirectiveId::STORE_REL_CONST_OFFSET, error);
169 }
170 
174  this->sendSignal(this->pushVal_directiveHandler(directive, error));
175  handleDirectiveErrorCode(Fpy::DirectiveId::PUSH_VAL, error);
176 }
177 
181  this->sendSignal(this->loadRel_directiveHandler(directive, error));
182  handleDirectiveErrorCode(Fpy::DirectiveId::LOAD_REL, error);
183 }
184 
188  this->sendSignal(this->discard_directiveHandler(directive, error));
189  handleDirectiveErrorCode(Fpy::DirectiveId::DISCARD, error);
190 }
191 
195  this->sendSignal(this->memCmp_directiveHandler(directive, error));
196  handleDirectiveErrorCode(Fpy::DirectiveId::MEMCMP, error);
197 }
198 
202  this->sendSignal(this->stackCmd_directiveHandler(directive, error));
203  handleDirectiveErrorCode(Fpy::DirectiveId::STACK_CMD, error);
204 }
205 
209  this->sendSignal(this->pushTime_directiveHandler(directive, error));
210  handleDirectiveErrorCode(Fpy::DirectiveId::PUSH_TIME, error);
211 }
212 
216  this->sendSignal(this->setSeed_directiveHandler(directive, error));
217  handleDirectiveErrorCode(Fpy::DirectiveId::SET_SEED, error);
218 }
219 
223  this->sendSignal(this->pushRand_directiveHandler(directive, error));
224  handleDirectiveErrorCode(Fpy::DirectiveId::PUSH_RAND, error);
225 }
226 
230  this->sendSignal(this->getField_directiveHandler(directive, error));
231  handleDirectiveErrorCode(Fpy::DirectiveId::GET_FIELD, error);
232 }
233 
237  this->sendSignal(this->peek_directiveHandler(directive, error));
238  handleDirectiveErrorCode(Fpy::DirectiveId::PEEK, error);
239 }
240 
244  this->sendSignal(this->storeRel_directiveHandler(directive, error));
245  handleDirectiveErrorCode(Fpy::DirectiveId::STORE_REL, error);
246 }
247 
251  this->sendSignal(this->call_directiveHandler(directive, error));
252  handleDirectiveErrorCode(Fpy::DirectiveId::CALL, error);
253 }
254 
258  this->sendSignal(this->return_directiveHandler(directive, error));
259  handleDirectiveErrorCode(Fpy::DirectiveId::RETURN, error);
260 }
261 
265  this->sendSignal(this->loadAbs_directiveHandler(directive, error));
266  handleDirectiveErrorCode(Fpy::DirectiveId::LOAD_ABS, error);
267 }
268 
272  this->sendSignal(this->storeAbs_directiveHandler(directive, error));
273  handleDirectiveErrorCode(Fpy::DirectiveId::STORE_ABS, error);
274 }
275 
280  this->sendSignal(this->storeAbsConstOffset_directiveHandler(directive, error));
281  handleDirectiveErrorCode(Fpy::DirectiveId::STORE_ABS_CONST_OFFSET, error);
282 }
283 
287  this->sendSignal(this->popEvent_directiveHandler(directive, error));
288  handleDirectiveErrorCode(Fpy::DirectiveId::POP_EVENT, error);
289 }
290 
295  this->sendSignal(this->popSerializable_directiveHandler(directive, error));
296  handleDirectiveErrorCode(Fpy::DirectiveId::POP_SERIALIZABLE, error);
297 }
298 
300 Signal FpySequencer::waitRel_directiveHandler(const FpySequencer_WaitRelDirective& directive, DirectiveError& error) {
301  if (this->m_runtime.stack.size < 8) {
304  }
305 
306  Fw::Time wakeupTime = this->getTime();
307 
308  U32 uSeconds = this->m_runtime.stack.pop<U32>();
309  U32 seconds = this->m_runtime.stack.pop<U32>();
310 
311  wakeupTime.add(seconds, uSeconds);
312  this->m_runtime.wakeupTime = wakeupTime;
314 }
315 
317 Signal FpySequencer::waitAbs_directiveHandler(const FpySequencer_WaitAbsDirective& directive, DirectiveError& error) {
318  if (this->m_runtime.stack.size < 2 * sizeof(U32) + sizeof(FwTimeContextStoreType) + sizeof(FwTimeBaseStoreType)) {
321  }
322 
323  U32 uSeconds = this->m_runtime.stack.pop<U32>();
324  U32 seconds = this->m_runtime.stack.pop<U32>();
325  FwTimeContextStoreType ctx = this->m_runtime.stack.pop<FwTimeContextStoreType>();
326  FwTimeBaseStoreType base = this->m_runtime.stack.pop<FwTimeBaseStoreType>();
327 
328  this->m_runtime.wakeupTime = Fw::Time(static_cast<TimeBase::T>(base), ctx, seconds, uSeconds);
330 }
331 
333 Signal FpySequencer::goto_directiveHandler(const FpySequencer_GotoDirective& directive, DirectiveError& error) {
334  // check within sequence bounds, or at EOF (we allow == case cuz this just ends the sequence)
335  if (directive.get_statementIndex() > m_sequenceObj.get_header().get_statementCount()) {
338  }
339  m_runtime.nextStatementIndex = directive.get_statementIndex();
341 }
342 
344 Signal FpySequencer::if_directiveHandler(const FpySequencer_IfDirective& directive, DirectiveError& error) {
345  if (this->m_runtime.stack.size < 1) {
348  }
349  // check within sequence bounds, or at EOF (we allow == case cuz this just ends the sequence)
350  if (directive.get_falseGotoStmtIndex() > m_sequenceObj.get_header().get_statementCount()) {
353  }
354 
355  if (this->m_runtime.stack.pop<U8>() != 0) {
356  // proceed to next instruction
358  }
359 
360  // conditional false case
361  this->m_runtime.nextStatementIndex = directive.get_falseGotoStmtIndex();
363 }
364 
365 Signal FpySequencer::noOp_directiveHandler(const FpySequencer_NoOpDirective& directive, DirectiveError& error) {
367 }
368 
369 Signal FpySequencer::pushTlmVal_directiveHandler(const FpySequencer_PushTlmValDirective& directive,
370  DirectiveError& error) {
371  if (!this->isConnected_getTlmChan_OutputPort(0)) {
374  }
375  Fw::Time tlmTime;
376  Fw::TlmBuffer tlmValue;
377  Fw::TlmValid valid = this->getTlmChan_out(0, directive.get_chanId(), tlmTime, tlmValue);
378 
379  if (valid != Fw::TlmValid::VALID) {
380  // could not find this tlm chan
383  }
384 
385  if (Fpy::MAX_STACK_SIZE - tlmValue.getSize() < this->m_runtime.stack.size) {
388  }
389  this->m_runtime.stack.push(tlmValue.getBuffAddr(), static_cast<Fpy::StackSizeType>(tlmValue.getSize()));
391 }
392 
393 Signal FpySequencer::pushTlmValAndTime_directiveHandler(const FpySequencer_PushTlmValAndTimeDirective& directive,
394  DirectiveError& error) {
395  if (!this->isConnected_getTlmChan_OutputPort(0)) {
398  }
399 
400  Fw::Time tlmTime;
401  Fw::TlmBuffer tlmValue;
402  Fw::TlmValid valid = this->getTlmChan_out(0, directive.get_chanId(), tlmTime, tlmValue);
403 
404  if (valid != Fw::TlmValid::VALID) {
405  // could not find this tlm chan
408  }
409 
410  U8 tlmTimeBuf[Fw::Time::SERIALIZED_SIZE] = {};
412  Fw::SerializeStatus stat = timeEsb.serializeFrom(tlmTime);
413 
414  // coding error if this failed, we should have enough space
415  FW_ASSERT(stat == Fw::SerializeStatus::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
416 
417  // check that our stack won't overflow if we put both val and time on it
418  if (Fpy::MAX_STACK_SIZE - tlmValue.getSize() - timeEsb.getSize() < this->m_runtime.stack.size) {
421  }
422 
423  // push tlm to end of stack
424  this->m_runtime.stack.push(tlmValue.getBuffAddr(), static_cast<Fpy::StackSizeType>(tlmValue.getSize()));
425  // now push time to end of stack
426  this->m_runtime.stack.push(timeEsb.getBuffAddr(), static_cast<Fpy::StackSizeType>(timeEsb.getSize()));
428 }
429 
430 Signal FpySequencer::pushPrm_directiveHandler(const FpySequencer_PushPrmDirective& directive, DirectiveError& error) {
431  if (!this->isConnected_prmGet_OutputPort(0)) {
434  }
435 
436  Fw::ParamBuffer prmValue;
437  Fw::ParamValid valid = this->getParam_out(0, directive.get_prmId(), prmValue);
438 
439  if (valid != Fw::ParamValid::VALID) {
440  // could not find this prm in the DB
443  }
444 
445  if (Fpy::MAX_STACK_SIZE - prmValue.getSize() < this->m_runtime.stack.size) {
448  }
449 
450  this->m_runtime.stack.push(prmValue.getBuffAddr(), static_cast<Fpy::StackSizeType>(prmValue.getSize()));
452 }
453 
454 Signal FpySequencer::constCmd_directiveHandler(const FpySequencer_ConstCmdDirective& directive, DirectiveError& error) {
455  // the cmd response code will be pushed to the stack when it comes back, so make sure
456  // there is room for it now, before the cmd is dispatched
457  if (Fpy::MAX_STACK_SIZE - sizeof(Fw::CmdResponse::SerialType) < this->m_runtime.stack.size) {
460  }
461  if (this->sendCmd(directive.get_opCode(), directive.get_argBuf(), directive.get__argBufSize()) ==
464  } else {
465  // now tell the SM to wait some more until we get the cmd response back
466  // if we've already got the response back this should be harmless
468  }
469 }
470 
471 DirectiveError FpySequencer::op_or() {
472  if (this->m_runtime.stack.size < sizeof(U8) * 2) {
474  }
475  this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<U8>() | this->m_runtime.stack.pop<U8>()));
477 }
478 DirectiveError FpySequencer::op_and() {
479  if (this->m_runtime.stack.size < sizeof(U8) * 2) {
481  }
482  this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<U8>() & this->m_runtime.stack.pop<U8>()));
484 }
485 DirectiveError FpySequencer::op_ieq() {
486  if (this->m_runtime.stack.size < sizeof(I64) * 2) {
488  }
489  this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<I64>() == this->m_runtime.stack.pop<I64>())
490  ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
491  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
493 }
494 DirectiveError FpySequencer::op_ine() {
495  if (this->m_runtime.stack.size < sizeof(I64) * 2) {
497  }
498  this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<I64>() != this->m_runtime.stack.pop<I64>())
499  ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
500  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
502 }
503 DirectiveError FpySequencer::op_ult() {
504  if (this->m_runtime.stack.size < sizeof(U64) * 2) {
506  }
507  U64 rhs = this->m_runtime.stack.pop<U64>();
508  U64 lhs = this->m_runtime.stack.pop<U64>();
509  this->m_runtime.stack.push(static_cast<U8>((lhs < rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
510  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
512 }
513 DirectiveError FpySequencer::op_ule() {
514  if (this->m_runtime.stack.size < sizeof(U64) * 2) {
516  }
517  U64 rhs = this->m_runtime.stack.pop<U64>();
518  U64 lhs = this->m_runtime.stack.pop<U64>();
519  this->m_runtime.stack.push(static_cast<U8>((lhs <= rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
520  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
522 }
523 DirectiveError FpySequencer::op_ugt() {
524  if (this->m_runtime.stack.size < sizeof(U64) * 2) {
526  }
527  U64 rhs = this->m_runtime.stack.pop<U64>();
528  U64 lhs = this->m_runtime.stack.pop<U64>();
529  this->m_runtime.stack.push(static_cast<U8>((lhs > rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
530  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
532 }
533 DirectiveError FpySequencer::op_uge() {
534  if (this->m_runtime.stack.size < sizeof(U64) * 2) {
536  }
537  U64 rhs = this->m_runtime.stack.pop<U64>();
538  U64 lhs = this->m_runtime.stack.pop<U64>();
539  this->m_runtime.stack.push(static_cast<U8>((lhs >= rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
540  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
542 }
543 DirectiveError FpySequencer::op_slt() {
544  if (this->m_runtime.stack.size < sizeof(I64) * 2) {
546  }
547  I64 rhs = this->m_runtime.stack.pop<I64>();
548  I64 lhs = this->m_runtime.stack.pop<I64>();
549  this->m_runtime.stack.push(static_cast<U8>((lhs < rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
550  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
552 }
553 DirectiveError FpySequencer::op_sle() {
554  if (this->m_runtime.stack.size < sizeof(I64) * 2) {
556  }
557  I64 rhs = this->m_runtime.stack.pop<I64>();
558  I64 lhs = this->m_runtime.stack.pop<I64>();
559  this->m_runtime.stack.push(static_cast<U8>((lhs <= rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
560  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
562 }
563 DirectiveError FpySequencer::op_sgt() {
564  if (this->m_runtime.stack.size < sizeof(I64) * 2) {
566  }
567  I64 rhs = this->m_runtime.stack.pop<I64>();
568  I64 lhs = this->m_runtime.stack.pop<I64>();
569  this->m_runtime.stack.push(static_cast<U8>((lhs > rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
570  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
572 }
573 DirectiveError FpySequencer::op_sge() {
574  if (this->m_runtime.stack.size < sizeof(I64) * 2) {
576  }
577  I64 rhs = this->m_runtime.stack.pop<I64>();
578  I64 lhs = this->m_runtime.stack.pop<I64>();
579  this->m_runtime.stack.push(static_cast<U8>((lhs >= rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
580  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
582 }
583 DirectiveError FpySequencer::op_feq() {
584  if (this->m_runtime.stack.size < sizeof(F64) * 2) {
586  }
587  F64 rhs = this->m_runtime.stack.pop<F64>();
588  F64 lhs = this->m_runtime.stack.pop<F64>();
589  // eq is true if they are equal and neither is nan
590  this->m_runtime.stack.push(static_cast<U8>((lhs == rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
591  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
593 }
594 DirectiveError FpySequencer::op_fne() {
595  if (this->m_runtime.stack.size < sizeof(F64) * 2) {
597  }
598  F64 rhs = this->m_runtime.stack.pop<F64>();
599  F64 lhs = this->m_runtime.stack.pop<F64>();
600  // ne is true if they are not equal or either is nan
601  this->m_runtime.stack.push(static_cast<U8>((lhs != rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
602  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
604 }
605 DirectiveError FpySequencer::op_flt() {
606  if (this->m_runtime.stack.size < sizeof(F64) * 2) {
608  }
609  F64 rhs = this->m_runtime.stack.pop<F64>();
610  F64 lhs = this->m_runtime.stack.pop<F64>();
611  this->m_runtime.stack.push(static_cast<U8>(std::isless(lhs, rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
612  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
614 }
615 DirectiveError FpySequencer::op_fle() {
616  if (this->m_runtime.stack.size < sizeof(F64) * 2) {
618  }
619  F64 rhs = this->m_runtime.stack.pop<F64>();
620  F64 lhs = this->m_runtime.stack.pop<F64>();
621  this->m_runtime.stack.push(static_cast<U8>(std::islessequal(lhs, rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
622  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
624 }
625 DirectiveError FpySequencer::op_fgt() {
626  if (this->m_runtime.stack.size < sizeof(F64) * 2) {
628  }
629  F64 rhs = this->m_runtime.stack.pop<F64>();
630  F64 lhs = this->m_runtime.stack.pop<F64>();
631  this->m_runtime.stack.push(static_cast<U8>(std::isgreater(lhs, rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
632  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
634 }
635 DirectiveError FpySequencer::op_fge() {
636  if (this->m_runtime.stack.size < sizeof(F64) * 2) {
638  }
639  F64 rhs = this->m_runtime.stack.pop<F64>();
640  F64 lhs = this->m_runtime.stack.pop<F64>();
641  this->m_runtime.stack.push(static_cast<U8>(std::isgreaterequal(lhs, rhs)
642  ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
643  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
645 }
646 DirectiveError FpySequencer::op_not() {
647  if (this->m_runtime.stack.size < sizeof(U8)) {
649  }
650  this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<U8>() == 0)
651  ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
652  : static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
654 }
655 DirectiveError FpySequencer::op_fpext() {
656  // convert F32 to F64
657  if (this->m_runtime.stack.size < sizeof(F32)) {
659  }
660  this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<F32>()));
662 }
663 DirectiveError FpySequencer::op_fptrunc() {
664  // convert F64 to F32
665  if (this->m_runtime.stack.size < sizeof(F64)) {
667  }
668  this->m_runtime.stack.push(static_cast<F32>(this->m_runtime.stack.pop<F64>()));
670 }
671 DirectiveError FpySequencer::op_fptosi() {
672  if (this->m_runtime.stack.size < sizeof(F64)) {
674  }
675  this->m_runtime.stack.push(static_cast<I64>(this->m_runtime.stack.pop<F64>()));
677 }
678 DirectiveError FpySequencer::op_sitofp() {
679  if (this->m_runtime.stack.size < sizeof(I64)) {
681  }
682  this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<I64>()));
684 }
685 DirectiveError FpySequencer::op_fptoui() {
686  if (this->m_runtime.stack.size < sizeof(F64)) {
688  }
689  this->m_runtime.stack.push(static_cast<U64>(this->m_runtime.stack.pop<F64>()));
691 }
692 DirectiveError FpySequencer::op_uitofp() {
693  if (this->m_runtime.stack.size < sizeof(U64)) {
695  }
696  this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<U64>()));
698 }
699 DirectiveError FpySequencer::op_add() {
700  if (this->m_runtime.stack.size < sizeof(I64) * 2) {
702  }
703  I64 rhs = this->m_runtime.stack.pop<I64>();
704  I64 lhs = this->m_runtime.stack.pop<I64>();
705  // Check for overflow and underflow and return the appropriate error code
706  // Overflow can only occur with both operands positive and occurs when one operand is greater than the maximum value
707  // less the other operand. If either operand is negative or zero, overflow cannot occur.
708  if ((rhs > 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() - rhs) < lhs)) {
710  }
711  // Underflow can only occur with both operands negative and occurs when one operand is less than the minimum value
712  // minus the other operand. If either operand is positive or zero, underflow cannot occur.
713  else if ((rhs < 0) && (lhs < 0) && ((std::numeric_limits<I64>::min() - rhs) > lhs)) {
715  }
716  this->m_runtime.stack.push(static_cast<I64>(lhs + rhs));
718 }
719 DirectiveError FpySequencer::op_sub() {
720  if (this->m_runtime.stack.size < sizeof(I64) * 2) {
722  }
723  I64 rhs = this->m_runtime.stack.pop<I64>();
724  I64 lhs = this->m_runtime.stack.pop<I64>();
725  // Check for overflow and underflow and return the appropriate error code
726  // Overflow can only occur when the left operand is positive and the right operand is negative. It occurs when the
727  // left (positive) operand is greater than the maximum value plus the other (negative) operand. If the right
728  // operand is positive or zero, overflow cannot occur.
729  if ((rhs < 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() + rhs) < lhs)) {
731  }
732  // Underflow can only occur when the left operand is negative and the right operand is positive. It occurs when the
733  // left (negative) operand is less than the minimum value plus the other (positive) operand. If the right operand
734  // is negative or zero, underflow cannot occur.
735  else if ((rhs > 0) && (lhs < 0) && ((std::numeric_limits<I64>::min() + rhs) > lhs)) {
737  }
738  this->m_runtime.stack.push(static_cast<I64>(lhs - rhs));
740 }
741 DirectiveError FpySequencer::op_mul() {
742  if (this->m_runtime.stack.size < sizeof(I64) * 2) {
744  }
745  I64 rhs = this->m_runtime.stack.pop<I64>();
746  I64 lhs = this->m_runtime.stack.pop<I64>();
747  // Check for overflow and underflow and return the appropriate error code
748  // Overflow can only occur with operands of matching signs and occurs when one operand is greater (or less) than the
749  // maximum value divided by the other operand. Either operand being zero precludes overflow.
750  // Check the both positive case.
751  if ((rhs > 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() / rhs) < lhs)) {
753  }
754  // Check the both negative case
755  else if ((rhs < 0) && (lhs < 0) && ((std::numeric_limits<I64>::max() / (-1 * rhs)) < (-1 * lhs))) {
757  }
758  // Underflow can occur with operands of differing signs and occurs when one operand is less than the minimum value
759  // divided by the other operand. Either operand being zero precludes underflow.
760  // Check the case where lhs is positive.
761  else if ((rhs < 0) && (lhs > 0) && ((std::numeric_limits<I64>::min() / lhs) > rhs)) {
763  }
764  // Check the case where rhs is positive.
765  else if ((rhs > 0) && (lhs < 0) && ((std::numeric_limits<I64>::min() / rhs) > lhs)) {
767  }
768  this->m_runtime.stack.push(static_cast<I64>(lhs * rhs));
770 }
771 DirectiveError FpySequencer::op_udiv() {
772  if (this->m_runtime.stack.size < sizeof(U64) * 2) {
774  }
775  U64 rhs = this->m_runtime.stack.pop<U64>();
776  U64 lhs = this->m_runtime.stack.pop<U64>();
777  // Prevent division by zero
778  if (rhs == 0) {
780  }
781  this->m_runtime.stack.push(static_cast<U64>(lhs / rhs));
783 }
784 DirectiveError FpySequencer::op_sdiv() {
785  if (this->m_runtime.stack.size < sizeof(I64) * 2) {
787  }
788 
789  I64 rhs = this->m_runtime.stack.pop<I64>();
790  I64 lhs = this->m_runtime.stack.pop<I64>();
791  // Prevent division by zero
792  if (rhs == 0) {
794  }
795  // Prevent signed overflow: INT64_MIN / -1 is undefined behavior (SIGFPE on x86)
796  if ((lhs == std::numeric_limits<I64>::min()) && (rhs == -1)) {
798  }
799  this->m_runtime.stack.push(static_cast<I64>(lhs / rhs));
801 }
802 DirectiveError FpySequencer::op_umod() {
803  if (this->m_runtime.stack.size < sizeof(U64) * 2) {
805  }
806  U64 rhs = this->m_runtime.stack.pop<U64>();
807  if (rhs == 0) {
809  }
810  U64 lhs = this->m_runtime.stack.pop<U64>();
811  this->m_runtime.stack.push(static_cast<U64>(lhs % rhs));
813 }
814 DirectiveError FpySequencer::op_smod() {
815  if (this->m_runtime.stack.size < sizeof(I64) * 2) {
817  }
818  I64 rhs = this->m_runtime.stack.pop<I64>();
819  if (rhs == 0) {
821  }
822  I64 lhs = this->m_runtime.stack.pop<I64>();
823  // Prevent signed overflow: INT64_MIN % -1 is undefined behavior (SIGFPE on x86)
824  if ((lhs == std::numeric_limits<I64>::min()) && (rhs == -1)) {
826  }
827  I64 res = static_cast<I64>(lhs % rhs);
828  // in order to match Python's behavior,
829  // if the signs of the remainder and divisor differ, adjust the result.
830  // this happens when the result should be positive but is negative, or vice-versa.
831  // credit Gemini 2.5 pro
832  if ((res > 0 && rhs < 0) || (res < 0 && rhs > 0)) {
833  res += rhs;
834  }
835  this->m_runtime.stack.push(res);
837 }
838 DirectiveError FpySequencer::op_fadd() {
839  if (this->m_runtime.stack.size < sizeof(F64) * 2) {
841  }
842  F64 rhs = this->m_runtime.stack.pop<F64>();
843  F64 lhs = this->m_runtime.stack.pop<F64>();
844  this->m_runtime.stack.push(static_cast<F64>(lhs + rhs));
846 }
847 DirectiveError FpySequencer::op_fsub() {
848  if (this->m_runtime.stack.size < sizeof(F64) * 2) {
850  }
851  F64 rhs = this->m_runtime.stack.pop<F64>();
852  F64 lhs = this->m_runtime.stack.pop<F64>();
853  this->m_runtime.stack.push(static_cast<F64>(lhs - rhs));
855 }
856 DirectiveError FpySequencer::op_fmul() {
857  if (this->m_runtime.stack.size < sizeof(F64) * 2) {
859  }
860  F64 rhs = this->m_runtime.stack.pop<F64>();
861  F64 lhs = this->m_runtime.stack.pop<F64>();
862  this->m_runtime.stack.push(static_cast<F64>(lhs * rhs));
864 }
865 DirectiveError FpySequencer::op_fdiv() {
866  if (this->m_runtime.stack.size < sizeof(F64) * 2) {
868  }
869  F64 rhs = this->m_runtime.stack.pop<F64>();
870  F64 lhs = this->m_runtime.stack.pop<F64>();
871  this->m_runtime.stack.push(static_cast<F64>(lhs / rhs));
873 }
874 DirectiveError FpySequencer::op_fpow() {
875  if (this->m_runtime.stack.size < sizeof(F64) * 2) {
877  }
878  F64 rhs = this->m_runtime.stack.pop<F64>();
879  F64 lhs = this->m_runtime.stack.pop<F64>();
880  this->m_runtime.stack.push(static_cast<F64>(pow(lhs, rhs)));
882 }
883 DirectiveError FpySequencer::op_flog() {
884  if (this->m_runtime.stack.size < sizeof(F64)) {
886  }
887  F64 val = this->m_runtime.stack.pop<F64>();
888  if (val <= 0.0) {
890  }
891  this->m_runtime.stack.push(static_cast<F64>(log(val)));
893 }
894 DirectiveError FpySequencer::op_fmod() {
895  if (this->m_runtime.stack.size < sizeof(F64) * 2) {
897  }
898  F64 rhs = this->m_runtime.stack.pop<F64>();
899  F64 lhs = this->m_runtime.stack.pop<F64>();
900  // std::fmod computes the exact truncated remainder (sign of lhs) with no
901  // intermediate rounding. A zero divisor yields NaN, matching Rust and C#.
902  F64 res = std::fmod(lhs, rhs);
903  // Adjust to match Python's floored-modulo semantics: if the signs of the
904  // remainder and divisor differ, add the divisor once. This mirrors op_smod
905  // and is the exact frem + fadd the VM model computes (at most one rounded add).
906  if ((res > 0 && rhs < 0) || (res < 0 && rhs > 0)) {
907  res += rhs;
908  }
909  this->m_runtime.stack.push(res);
911 }
912 DirectiveError FpySequencer::op_siext_8_64() {
913  if (this->m_runtime.stack.size < sizeof(I8)) {
915  }
916  I8 src = this->m_runtime.stack.pop<I8>();
917  this->m_runtime.stack.push(static_cast<I64>(src));
919 }
920 DirectiveError FpySequencer::op_siext_16_64() {
921  if (this->m_runtime.stack.size < sizeof(I16)) {
923  }
924  I16 src = this->m_runtime.stack.pop<I16>();
925  this->m_runtime.stack.push(static_cast<I64>(src));
927 }
928 DirectiveError FpySequencer::op_siext_32_64() {
929  if (this->m_runtime.stack.size < sizeof(I32)) {
931  }
932  I32 src = this->m_runtime.stack.pop<I32>();
933  this->m_runtime.stack.push(static_cast<I64>(src));
935 }
936 DirectiveError FpySequencer::op_ziext_8_64() {
937  if (this->m_runtime.stack.size < sizeof(U8)) {
939  }
940  U8 src = this->m_runtime.stack.pop<U8>();
941  this->m_runtime.stack.push(static_cast<U64>(src));
943 }
944 DirectiveError FpySequencer::op_ziext_16_64() {
945  if (this->m_runtime.stack.size < sizeof(U16)) {
947  }
948  U16 src = this->m_runtime.stack.pop<U16>();
949  this->m_runtime.stack.push(static_cast<U64>(src));
951 }
952 DirectiveError FpySequencer::op_ziext_32_64() {
953  if (this->m_runtime.stack.size < sizeof(U32)) {
955  }
956  U32 src = this->m_runtime.stack.pop<U32>();
957  this->m_runtime.stack.push(static_cast<U64>(src));
959 }
960 DirectiveError FpySequencer::op_itrunc_64_8() {
961  if (this->m_runtime.stack.size < sizeof(U64)) {
963  }
964  U64 src = this->m_runtime.stack.pop<U64>();
965  this->m_runtime.stack.push(static_cast<U8>(src));
967 }
968 DirectiveError FpySequencer::op_itrunc_64_16() {
969  if (this->m_runtime.stack.size < sizeof(U64)) {
971  }
972  U64 src = this->m_runtime.stack.pop<U64>();
973  this->m_runtime.stack.push(static_cast<U16>(src));
975 }
976 DirectiveError FpySequencer::op_itrunc_64_32() {
977  if (this->m_runtime.stack.size < sizeof(U64)) {
979  }
980  U64 src = this->m_runtime.stack.pop<U64>();
981  this->m_runtime.stack.push(static_cast<U32>(src));
983 }
984 Signal FpySequencer::stackOp_directiveHandler(const FpySequencer_StackOpDirective& directive, DirectiveError& error) {
985  // coding error, should not have gotten to this stack op handler
986  FW_ASSERT(directive.get__op() >= Fpy::DirectiveId::OR && directive.get__op() <= Fpy::DirectiveId::ITRUNC_64_32,
987  static_cast<FwAssertArgType>(directive.get__op()));
988 
989  switch (directive.get__op()) {
991  error = this->op_or();
992  break;
994  error = this->op_and();
995  break;
997  error = this->op_ieq();
998  break;
1000  error = this->op_ine();
1001  break;
1002  case Fpy::DirectiveId::ULT:
1003  error = this->op_ult();
1004  break;
1005  case Fpy::DirectiveId::ULE:
1006  error = this->op_ule();
1007  break;
1008  case Fpy::DirectiveId::UGT:
1009  error = this->op_ugt();
1010  break;
1011  case Fpy::DirectiveId::UGE:
1012  error = this->op_uge();
1013  break;
1014  case Fpy::DirectiveId::SLT:
1015  error = this->op_slt();
1016  break;
1017  case Fpy::DirectiveId::SLE:
1018  error = this->op_sle();
1019  break;
1020  case Fpy::DirectiveId::SGT:
1021  error = this->op_sgt();
1022  break;
1023  case Fpy::DirectiveId::SGE:
1024  error = this->op_sge();
1025  break;
1026  case Fpy::DirectiveId::FEQ:
1027  error = this->op_feq();
1028  break;
1029  case Fpy::DirectiveId::FNE:
1030  error = this->op_fne();
1031  break;
1032  case Fpy::DirectiveId::FLT:
1033  error = this->op_flt();
1034  break;
1035  case Fpy::DirectiveId::FLE:
1036  error = this->op_fle();
1037  break;
1038  case Fpy::DirectiveId::FGT:
1039  error = this->op_fgt();
1040  break;
1041  case Fpy::DirectiveId::FGE:
1042  error = this->op_fge();
1043  break;
1044  case Fpy::DirectiveId::NOT:
1045  error = this->op_not();
1046  break;
1048  error = this->op_fpext();
1049  break;
1051  error = this->op_fptrunc();
1052  break;
1054  error = this->op_fptosi();
1055  break;
1057  error = this->op_fptoui();
1058  break;
1060  error = this->op_sitofp();
1061  break;
1063  error = this->op_uitofp();
1064  break;
1065  case Fpy::DirectiveId::ADD:
1066  error = this->op_add();
1067  break;
1068  case Fpy::DirectiveId::SUB:
1069  error = this->op_sub();
1070  break;
1071  case Fpy::DirectiveId::MUL:
1072  error = this->op_mul();
1073  break;
1075  error = this->op_udiv();
1076  break;
1078  error = this->op_sdiv();
1079  break;
1081  error = this->op_umod();
1082  break;
1084  error = this->op_smod();
1085  break;
1087  error = this->op_fadd();
1088  break;
1090  error = this->op_fsub();
1091  break;
1093  error = this->op_fmul();
1094  break;
1096  error = this->op_fdiv();
1097  break;
1099  error = this->op_fpow();
1100  break;
1102  error = this->op_flog();
1103  break;
1105  error = this->op_fmod();
1106  break;
1108  error = this->op_siext_8_64();
1109  break;
1111  error = this->op_siext_16_64();
1112  break;
1114  error = this->op_siext_32_64();
1115  break;
1117  error = this->op_ziext_8_64();
1118  break;
1120  error = this->op_ziext_16_64();
1121  break;
1123  error = this->op_ziext_32_64();
1124  break;
1126  error = this->op_itrunc_64_8();
1127  break;
1129  error = this->op_itrunc_64_16();
1130  break;
1132  error = this->op_itrunc_64_32();
1133  break;
1134  default:
1135  FW_ASSERT(false, directive.get__op());
1136  break;
1137  }
1138  if (error != DirectiveError::NO_ERROR) {
1140  }
1142 }
1143 
1144 Signal FpySequencer::exit_directiveHandler(const FpySequencer_ExitDirective& directive, DirectiveError& error) {
1145  if (this->m_runtime.stack.size < 1) {
1148  }
1149  U8 errorCode = this->m_runtime.stack.pop<U8>();
1150  // exit(0), no error
1151  if (errorCode == 0) {
1152  // just goto the end of the sequence
1153  this->m_runtime.nextStatementIndex = this->m_sequenceObj.get_header().get_statementCount();
1155  }
1156  // otherwise, kill the sequence here
1157  // raise the user defined error code as an event
1158  this->log_WARNING_HI_SequenceExitedWithError(this->m_sequenceFilePath, errorCode);
1161 }
1162 
1163 Signal FpySequencer::allocate_directiveHandler(const FpySequencer_AllocateDirective& directive, DirectiveError& error) {
1164  if (directive.get_size() > Fpy::MAX_STACK_SIZE - this->m_runtime.stack.size) {
1167  }
1168  this->m_runtime.stack.pushZeroes(directive.get_size());
1170 }
1171 
1173 Signal FpySequencer::storeHelper(Fpy::StackSizeType destOffset, Fpy::StackSizeType size, DirectiveError& error) {
1174  if (this->m_runtime.stack.size < size) {
1177  }
1178  // After popping the value, would the write go out of bounds?
1179  Fpy::StackSizeType newStackSize = this->m_runtime.stack.size - size;
1180  // Overflow-safe check: destOffset + size > newStackSize
1181  // Rewritten as: check destOffset <= newStackSize first, then size > newStackSize - destOffset
1182  if (destOffset > newStackSize || size > newStackSize - destOffset) {
1185  }
1186  // Copy value to the destination location
1187  this->m_runtime.stack.copy(destOffset, this->m_runtime.stack.size - size, size);
1188  this->m_runtime.stack.size = newStackSize;
1190 }
1191 
1193 Signal FpySequencer::loadHelper(Fpy::StackSizeType srcOffset, Fpy::StackSizeType size, DirectiveError& error) {
1194  if (size > Fpy::MAX_STACK_SIZE - this->m_runtime.stack.size) {
1197  }
1198  // Overflow-safe check: srcOffset + size > stack.size
1199  // Rewritten as: check srcOffset <= stack.size first, then size > stack.size - srcOffset
1200  if (srcOffset > this->m_runtime.stack.size || size > this->m_runtime.stack.size - srcOffset) {
1203  }
1204  // Copy from source location to top of stack
1205  this->m_runtime.stack.copy(this->m_runtime.stack.size, srcOffset, size);
1206  this->m_runtime.stack.size += size;
1208 }
1209 
1210 Signal FpySequencer::storeRelConstOffset_directiveHandler(const FpySequencer_StoreRelConstOffsetDirective& directive,
1211  DirectiveError& error) {
1212  I64 addr = static_cast<I64>(this->m_runtime.stack.currentFrameStart) + directive.get_lvarOffset();
1213  if (addr < 0 || addr > Fpy::MAX_STACK_SIZE) {
1216  }
1217  return this->storeHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1218 }
1219 
1220 Signal FpySequencer::loadRel_directiveHandler(const FpySequencer_LoadRelDirective& directive, DirectiveError& error) {
1221  I64 addr = static_cast<I64>(this->m_runtime.stack.currentFrameStart) + directive.get_lvarOffset();
1222  if (addr < 0 || addr > Fpy::MAX_STACK_SIZE) {
1225  }
1226  return this->loadHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1227 }
1228 
1229 Signal FpySequencer::pushVal_directiveHandler(const FpySequencer_PushValDirective& directive, DirectiveError& error) {
1230  if (directive.get__valSize() > Fpy::MAX_STACK_SIZE - this->m_runtime.stack.size) {
1233  }
1234  // copy from the bytearray in the directive to the stack, add to stack size.
1235  this->m_runtime.stack.push(const_cast<U8*>(directive.get_val()),
1236  static_cast<Fpy::StackSizeType>(directive.get__valSize()));
1238 }
1239 
1240 Signal FpySequencer::discard_directiveHandler(const FpySequencer_DiscardDirective& directive, DirectiveError& error) {
1241  if (this->m_runtime.stack.size < directive.get_size()) {
1244  }
1245  // drop the specified amount of bytes off the stack. simple as.
1246  this->m_runtime.stack.size -= directive.get_size();
1248 }
1249 
1250 Signal FpySequencer::memCmp_directiveHandler(const FpySequencer_MemCmpDirective& directive, DirectiveError& error) {
1251  // Overflow-safe check: we need size * 2 bytes on the stack
1252  // First check that size * 2 doesn't overflow: size > MAX/2 would overflow
1253  // MAX_STACK_SIZE is the upper bound for stack.size, so if size > MAX_STACK_SIZE/2, we definitely don't have enough
1254  if (directive.get_size() > Fpy::MAX_STACK_SIZE / 2) {
1257  }
1258  // Now safe to compute size * 2
1259  if (this->m_runtime.stack.size < directive.get_size() * 2) {
1262  }
1263 
1264  // find the starting offsets of the two byte arrays
1265  U64 lhsOffset = this->m_runtime.stack.size - directive.get_size() * 2;
1266  U64 rhsOffset = this->m_runtime.stack.size - directive.get_size();
1267 
1268  // "officially" remove them from the stack
1269  // you have to do this before pushing to the stack, otherwise the result would get placed
1270  // after the byte arrays
1271  this->m_runtime.stack.size -= directive.get_size() * 2;
1272 
1273  // memcmp the two byte arrays, push FW_SERIALIZE_TRUE_VALUE if they were equal, FW_SERIALIZE_FALSE_VALUE otherwise
1274  if (memcmp(this->m_runtime.stack.bytes + lhsOffset, this->m_runtime.stack.bytes + rhsOffset,
1275  directive.get_size()) == 0) {
1276  this->m_runtime.stack.push<U8>(static_cast<U8>(FW_SERIALIZE_TRUE_VALUE));
1277  } else {
1278  this->m_runtime.stack.push<U8>(static_cast<U8>(FW_SERIALIZE_FALSE_VALUE));
1279  }
1281 }
1282 
1283 Signal FpySequencer::stackCmd_directiveHandler(const FpySequencer_StackCmdDirective& directive, DirectiveError& error) {
1284  // Overflow-safe check: need argsSize + sizeof(FwOpcodeType) bytes
1285  // Check stack.size >= sizeof(FwOpcodeType) first, then stack.size - sizeof(FwOpcodeType) >= argsSize
1286  if (this->m_runtime.stack.size < sizeof(FwOpcodeType) ||
1287  this->m_runtime.stack.size - sizeof(FwOpcodeType) < directive.get_argsSize()) {
1290  }
1291 
1292  // pop the opcode of the cmd off the stack
1293  // note this means that, unlike the actual byte array that the dispatcher gets,
1294  // these cmds have opcode after the argument buffer
1295  FwOpcodeType opcode = this->m_runtime.stack.pop<FwOpcodeType>();
1296  U64 argBufOffset = this->m_runtime.stack.size - directive.get_argsSize();
1297 
1298  // update the opcode of the cmd we will await
1299  this->m_runtime.currentCmdOpcode = opcode;
1300 
1301  // also pop the args off the stack
1302  this->m_runtime.stack.size -= directive.get_argsSize();
1303 
1304  // the cmd response code will be pushed to the stack when it comes back, so make sure
1305  // there is room for it now, before the cmd is dispatched. popping the opcode above
1306  // frees some room, but FwOpcodeType is configurable so it may not be enough
1307  if (Fpy::MAX_STACK_SIZE - sizeof(Fw::CmdResponse::SerialType) < this->m_runtime.stack.size) {
1310  }
1311 
1312  if (this->sendCmd(opcode, this->m_runtime.stack.bytes + argBufOffset, directive.get_argsSize()) ==
1315  } else {
1316  // now tell the SM to wait some more until we get the cmd response back
1317  // if we've already got the response back this should be harmless
1319  }
1320 
1322 }
1323 
1324 Signal FpySequencer::pushTime_directiveHandler(const FpySequencer_PushTimeDirective& directive, DirectiveError& error) {
1325  if (Fpy::MAX_STACK_SIZE - Fw::Time::SERIALIZED_SIZE < this->m_runtime.stack.size) {
1328  }
1329 
1330  Fw::Time currentTime = this->getTime();
1331 
1332  U8 currentTimeBuf[Fw::Time::SERIALIZED_SIZE] = {};
1333  Fw::ExternalSerializeBuffer timeEsb(currentTimeBuf, Fw::Time::SERIALIZED_SIZE);
1334  Fw::SerializeStatus stat = timeEsb.serializeFrom(currentTime);
1335 
1336  // coding error if this failed, we should have enough space
1337  FW_ASSERT(stat == Fw::SerializeStatus::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
1338 
1339  // push time to end of stack
1340  this->m_runtime.stack.push(timeEsb.getBuffAddr(), static_cast<Fpy::StackSizeType>(timeEsb.getSize()));
1342 }
1343 
1344 Signal FpySequencer::setSeed_directiveHandler(const FpySequencer_SetSeedDirective& directive, DirectiveError& error) {
1345  if (this->m_runtime.stack.size < sizeof(U32)) {
1348  }
1349 
1350  U32 seed = this->m_runtime.stack.pop<U32>();
1351  this->m_runtime.rng.seed(seed);
1352  this->m_runtime.rngSeeded = true;
1354 }
1355 
1356 Signal FpySequencer::pushRand_directiveHandler(const FpySequencer_PushRandDirective& directive, DirectiveError& error) {
1357  if (Fpy::MAX_STACK_SIZE - sizeof(U32) < this->m_runtime.stack.size) {
1360  }
1361 
1362  if (!this->m_runtime.rngSeeded) {
1363  Fw::Time currentTime = this->getTime();
1364  std::seed_seq seedSeq{static_cast<U32>(currentTime.getTimeBase()), static_cast<U32>(currentTime.getContext()),
1365  currentTime.getSeconds(), currentTime.getUSeconds()};
1366  this->m_runtime.rng.seed(seedSeq);
1367  this->m_runtime.rngSeeded = true;
1368  }
1369 
1370  U32 randVal = static_cast<U32>(this->m_runtime.rng());
1371  this->m_runtime.stack.push(randVal);
1373 }
1374 
1375 Signal FpySequencer::getField_directiveHandler(const FpySequencer_GetFieldDirective& directive, DirectiveError& error) {
1376  // Need sizeof(StackSizeType) for the offset AND parentSize for the parent data
1377  // Check we have enough for the offset first
1378  if (this->m_runtime.stack.size < sizeof(Fpy::StackSizeType)) {
1381  }
1382  // After popping the offset, we need at least parentSize bytes remaining
1383  if (this->m_runtime.stack.size - sizeof(Fpy::StackSizeType) < directive.get_parentSize()) {
1386  }
1387 
1388  Fpy::StackSizeType offset = this->m_runtime.stack.pop<Fpy::StackSizeType>();
1389 
1390  // Overflow-safe check: offset + memberSize > parentSize
1391  // Rewritten as: check offset <= parentSize first, then memberSize > parentSize - offset
1392  if (offset > directive.get_parentSize() || directive.get_memberSize() > directive.get_parentSize() - offset) {
1393  // i think it's somewhat ambiguous whether this is a stack access out of bounds
1394  // but there isn't really an error code that better reflects this, and i guess
1395  // it's technically true
1398  }
1399 
1400  // the resulting bytes should move to the start of the parent array
1401 
1402  // Calculate the offset of the parent start in the stack
1403  Fpy::StackSizeType parentStartOffset = this->m_runtime.stack.size - directive.get_parentSize();
1404  // Overflow-safe: parentStartOffset + offset cannot overflow since offset <= parentSize
1405  // and parentStartOffset + parentSize == stack.size (which is bounded)
1406  this->m_runtime.stack.move(parentStartOffset, parentStartOffset + offset, directive.get_memberSize());
1407  // adjust stack size by the diff between the member and the parent
1408  this->m_runtime.stack.size -= (directive.get_parentSize() - directive.get_memberSize());
1410 }
1411 
1412 Signal FpySequencer::peek_directiveHandler(const FpySequencer_PeekDirective& directive, DirectiveError& error) {
1413  // must have at least two StackSizeType on stack
1414  if (this->m_runtime.stack.size < sizeof(Fpy::StackSizeType) * 2) {
1417  }
1418 
1419  Fpy::StackSizeType offset = this->m_runtime.stack.pop<Fpy::StackSizeType>();
1420  Fpy::StackSizeType byteCount = this->m_runtime.stack.pop<Fpy::StackSizeType>();
1421 
1422  // Check offset doesn't exceed stack size (after both pops)
1423  if (offset > this->m_runtime.stack.size) {
1424  // would access past the bottom of the stack
1425  // note we allow the equals case because the byteCount might be 0
1428  }
1429  if (byteCount > Fpy::MAX_STACK_SIZE - this->m_runtime.stack.size) {
1430  // we would overflow the stack if we pushed this many bytes to it
1433  }
1434  // Overflow-safe check: byteCount + offset > stack.size
1435  // Rewritten as: check offset <= stack.size (done above), then byteCount > stack.size - offset
1436  if (byteCount > this->m_runtime.stack.size - offset) {
1437  // would access past the bottom of the stack
1440  }
1441  // start copying from the lowest byte of the src array
1442  U8* src = this->m_runtime.stack.top() - offset - byteCount;
1443  this->m_runtime.stack.push(src, byteCount);
1445 }
1446 
1447 Signal FpySequencer::storeRel_directiveHandler(const FpySequencer_StoreRelDirective& directive, DirectiveError& error) {
1448  // Need enough bytes for the value and the offset (SignedStackSizeType = 4 bytes)
1449  // Overflow-safe: check stack.size >= sizeof(SignedStackSizeType) first, then stack.size -
1450  // sizeof(SignedStackSizeType) >= size
1451  if (this->m_runtime.stack.size < sizeof(Fpy::SignedStackSizeType) ||
1452  this->m_runtime.stack.size - sizeof(Fpy::SignedStackSizeType) < directive.get_size()) {
1455  }
1456 
1457  // Pop the signed offset from the stack
1458  Fpy::SignedStackSizeType lvarOffset = this->m_runtime.stack.pop<Fpy::SignedStackSizeType>();
1459 
1460  I64 addr = static_cast<I64>(this->m_runtime.stack.currentFrameStart) + lvarOffset;
1461  if (addr < 0 || addr > Fpy::MAX_STACK_SIZE) {
1464  }
1465  return this->storeHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1466 }
1467 
1468 Signal FpySequencer::call_directiveHandler(const FpySequencer_CallDirective& directive, DirectiveError& error) {
1469  // Need at least 4 bytes for the target address
1470  if (this->m_runtime.stack.size < sizeof(U32)) {
1473  }
1474 
1475  // Pop the target directive index from the stack
1476  U32 target = this->m_runtime.stack.pop<U32>();
1477 
1478  // Check if we have space to push return address and saved frame pointer (8 bytes total)
1479  if (this->m_runtime.stack.size + sizeof(Fpy::StackSizeType) + sizeof(U32) > Fpy::MAX_STACK_SIZE) {
1482  }
1483 
1484  // Check target is within bounds (will also be checked at execution time)
1485  if (target > m_sequenceObj.get_header().get_statementCount()) {
1488  }
1489 
1490  // Save the return address (next instruction after CALL)
1491  U32 returnAddr = this->m_runtime.nextStatementIndex;
1492 
1493  // Set the next instruction to the target
1494  this->m_runtime.nextStatementIndex = target;
1495 
1496  // Push the return address to the stack
1497  this->m_runtime.stack.push<U32>(returnAddr);
1498 
1499  // Push the current frame pointer to the stack
1500  this->m_runtime.stack.push<Fpy::StackSizeType>(this->m_runtime.stack.currentFrameStart);
1501 
1502  // Set the new frame pointer to the current top of stack
1503  this->m_runtime.stack.currentFrameStart = this->m_runtime.stack.size;
1504 
1506 }
1507 
1508 Signal FpySequencer::return_directiveHandler(const FpySequencer_ReturnDirective& directive, DirectiveError& error) {
1509  Fpy::StackSizeType returnValSize = directive.get_returnValSize();
1510  Fpy::StackSizeType callArgsSize = directive.get_callArgsSize();
1511 
1512  // Check we have enough bytes for the return value
1513  if (this->m_runtime.stack.size < returnValSize) {
1516  }
1517 
1518  // returnValSize is guaranteed to be less than Fpy::MAX_STACK_SIZE because it's less than the stack.size
1519  // thus the memcpy won't fail
1520 
1521  // Save the return value if there is one
1522  U8 returnValue[Fpy::MAX_STACK_SIZE] = {};
1523  if (returnValSize > 0) {
1524  (void)memcpy(returnValue, this->m_runtime.stack.top() - returnValSize, returnValSize);
1525  }
1526 
1527  // Truncate the stack to stack_frame_start (discard all local variables)
1528  if (this->m_runtime.stack.currentFrameStart > this->m_runtime.stack.size) {
1531  }
1532  this->m_runtime.stack.size = this->m_runtime.stack.currentFrameStart;
1533 
1534  // Check we have enough bytes for saved frame pointer and return address
1535  if (this->m_runtime.stack.size < sizeof(Fpy::StackSizeType) + sizeof(U32)) {
1538  }
1539 
1540  // Pop the saved frame pointer
1541  Fpy::StackSizeType savedFramePtr = this->m_runtime.stack.pop<Fpy::StackSizeType>();
1542 
1543  // Pop the return address
1544  U32 returnAddr = this->m_runtime.stack.pop<U32>();
1545 
1546  // Restore the frame pointer
1547  if (savedFramePtr > this->m_runtime.stack.size) {
1550  }
1551  this->m_runtime.stack.currentFrameStart = savedFramePtr;
1552 
1553  // Validate the return address is within bounds
1554  if (returnAddr > m_sequenceObj.get_header().get_statementCount()) {
1557  }
1558 
1559  // Set the next instruction to the return address
1560  this->m_runtime.nextStatementIndex = returnAddr;
1561 
1562  // Check that we have enough bytes for the call arguments
1563  if (this->m_runtime.stack.size < callArgsSize) {
1566  }
1567  // Discard the function arguments
1568  this->m_runtime.stack.size -= callArgsSize;
1569 
1570  // Push the return value
1571  if (returnValSize > Fpy::MAX_STACK_SIZE - this->m_runtime.stack.size) {
1574  }
1575  this->m_runtime.stack.push(returnValue, returnValSize);
1576 
1578 }
1579 
1580 Signal FpySequencer::loadAbs_directiveHandler(const FpySequencer_LoadAbsDirective& directive, DirectiveError& error) {
1581  return this->loadHelper(directive.get_globalOffset(), directive.get_size(), error);
1582 }
1583 
1584 Signal FpySequencer::storeAbs_directiveHandler(const FpySequencer_StoreAbsDirective& directive, DirectiveError& error) {
1585  Fpy::StackSizeType size = directive.get_size();
1586 
1587  // Need enough bytes for the value and the offset
1588  // Overflow-safe: check stack.size >= sizeof(StackSizeType) first, then stack.size - sizeof >= size
1589  if (this->m_runtime.stack.size < sizeof(Fpy::StackSizeType) ||
1590  this->m_runtime.stack.size - sizeof(Fpy::StackSizeType) < size) {
1593  }
1594 
1595  // Pop the global offset from the stack
1596  Fpy::StackSizeType globalOffset = this->m_runtime.stack.pop<Fpy::StackSizeType>();
1597 
1598  return this->storeHelper(globalOffset, size, error);
1599 }
1600 
1601 Signal FpySequencer::storeAbsConstOffset_directiveHandler(const FpySequencer_StoreAbsConstOffsetDirective& directive,
1602  DirectiveError& error) {
1603  return this->storeHelper(directive.get_globalOffset(), directive.get_size(), error);
1604 }
1605 
1606 Signal FpySequencer::popEvent_directiveHandler(const FpySequencer_PopEventDirective& directive, DirectiveError& error) {
1607  // Pop messageSize from the stack
1608  if (this->m_runtime.stack.size < sizeof(Fpy::StackSizeType)) {
1611  }
1612  Fpy::StackSizeType messageSize = this->m_runtime.stack.pop<Fpy::StackSizeType>();
1613 
1614  const Fpy::StackSizeType severitySize = static_cast<Fpy::StackSizeType>(sizeof(Fw::LogSeverity::SerialType));
1615 
1616  // Need message_size bytes + sizeof(LogSeverity serial type) for severity
1617  if (this->m_runtime.stack.size < severitySize || this->m_runtime.stack.size - severitySize < messageSize) {
1620  }
1621 
1622  // Pop message bytes first
1623  U8 messageBuf[FW_LOG_STRING_MAX_SIZE] = {};
1624  // don't read in more than (log string size) - 1 bytes
1625  Fpy::StackSizeType clampedSize = std::min(messageSize, static_cast<Fpy::StackSizeType>(FW_LOG_STRING_MAX_SIZE - 1));
1626  // If message is larger than buffer, discard the excess bytes first (from top of stack, which is the end of the
1627  // message)
1628  if (messageSize > clampedSize) {
1629  Fpy::StackSizeType excess = messageSize - clampedSize;
1630  FW_ASSERT(this->m_runtime.stack.size >= excess, static_cast<FwAssertArgType>(this->m_runtime.stack.size),
1631  static_cast<FwAssertArgType>(excess));
1632  this->m_runtime.stack.size -= excess;
1633  }
1634  this->m_runtime.stack.pop(messageBuf, clampedSize);
1635  messageBuf[clampedSize] = '\0';
1636 
1637  // Pop severity
1638  Fw::LogSeverity::SerialType severity = this->m_runtime.stack.pop<Fw::LogSeverity::SerialType>();
1639 
1640  // Construct the message string
1641  Fw::String messageStr(reinterpret_cast<const char*>(messageBuf));
1642 
1643  // Emit the appropriate event based on severity
1644  switch (severity) {
1646  this->log_FATAL_LogFatal(this->m_sequenceFilePath, messageStr);
1647  break;
1649  this->log_WARNING_HI_LogWarningHi(this->m_sequenceFilePath, messageStr);
1650  break;
1652  this->log_WARNING_LO_LogWarningLo(this->m_sequenceFilePath, messageStr);
1653  break;
1655  this->log_COMMAND_LogCommand(this->m_sequenceFilePath, messageStr);
1656  break;
1658  this->log_ACTIVITY_HI_LogActivityHi(this->m_sequenceFilePath, messageStr);
1659  break;
1661  this->log_ACTIVITY_LO_LogActivityLo(this->m_sequenceFilePath, messageStr);
1662  break;
1664  this->log_DIAGNOSTIC_LogDiagnostic(this->m_sequenceFilePath, messageStr);
1665  break;
1666  default:
1669  }
1670 
1672 }
1673 
1674 Signal FpySequencer::popSerializable_directiveHandler(const FpySequencer_PopSerializableDirective& directive,
1675  DirectiveError& error) {
1676  FW_ASSERT(directive.get_size() <= Fpy::MAX_STACK_SIZE, static_cast<FwAssertArgType>(directive.get_size()));
1677 
1678  // Validate port index is in range (using enum constant value)
1679  constexpr FwIndexType MAX_PORTS = static_cast<FwIndexType>(Svc::Fpy::SerialPortIndex::MAX_SERIAL_PORTS);
1680  const FwIndexType portIndex = directive.get_portIndex();
1681 
1682  // Check for negative port index or out of bounds
1683  if (portIndex < 0 || portIndex >= MAX_PORTS) {
1686  }
1687 
1688  // Check port is connected
1689  if (!this->isConnected_serialOut_OutputPort(portIndex)) {
1692  }
1693 
1694  // Validate data size on stack
1695  if (this->m_runtime.stack.size < directive.get_size()) {
1698  }
1699 
1700  // Create external buffer referencing stack data (no copy)
1701  U8* dataPtr = this->m_runtime.stack.top() - directive.get_size();
1702  Fw::ExternalSerializeBuffer buf(dataPtr, directive.get_size());
1703 
1704  // Set buffer length and verify success
1705  Fw::SerializeStatus stat = buf.setBuffLen(directive.get_size());
1706  FW_ASSERT(stat == Fw::SerializeStatus::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
1707 
1708  // Call output port and verify serialization succeeds
1709  Fw::SerializeStatus portStatus = this->serialOut_out(portIndex, buf);
1710  FW_ASSERT(portStatus == Fw::SerializeStatus::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(portStatus));
1711 
1712  // Pop data from stack
1713  this->m_runtime.stack.size -= directive.get_size();
1714 
1716 }
1717 
1718 } // namespace Svc
void directive_storeRelConstOffset_internalInterfaceHandler(const Svc::FpySequencer_StoreRelConstOffsetDirective &directive) override
Internal interface handler for directive_storeRelConstOffset.
void cmdOut_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context) const
Invoke output port cmdOut.
void directive_storeRel_internalInterfaceHandler(const Svc::FpySequencer_StoreRelDirective &directive) override
Internal interface handler for directive_storeRel.
Serialization/Deserialization operation was successful.
void directive_return_internalInterfaceHandler(const Svc::FpySequencer_ReturnDirective &directive) override
Internal interface handler for directive_return.
sets the index of the next directive to execute
void directive_call_internalInterfaceHandler(const Svc::FpySequencer_CallDirective &directive) override
Internal interface handler for directive_call.
bool isConnected_getTlmChan_OutputPort(FwIndexType portNum) const
FwIdType FwOpcodeType
The type of a command opcode.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
U16 get_statementCount() const
Get member statementCount.
branches based off of the top byte of the stack
void directive_if_internalInterfaceHandler(const Svc::FpySequencer_IfDirective &directive) override
Internal interface handler for directive_if.
Representing success.
void directive_setSeed_internalInterfaceHandler(const Svc::FpySequencer_SetSeedDirective &directive) override
Internal interface handler for directive_setSeed.
PlatformSizeType FwSizeType
stores a value to an absolute address in the stack (for global variables), offset from stack ...
void directive_loadAbs_internalInterfaceHandler(const Svc::FpySequencer_LoadAbsDirective &directive) override
Internal interface handler for directive_loadAbs.
void directive_stackOp_internalInterfaceHandler(const Svc::FpySequencer_StackOpDirective &directive) override
Internal interface handler for directive_stackOp.
called when statement successfully executed. only raised in the RUNNING.AWAITING_CMD_RESPONSE state ...
void directive_getField_internalInterfaceHandler(const Svc::FpySequencer_GetFieldDirective &directive) override
Internal interface handler for directive_getField.
I32 SignedStackSizeType
signed version of StackSizeType, used for relative offsets that can be negative
Serializable::SizeType getSize() const override
Get current buffer size.
void log_WARNING_HI_SequenceExitedWithError(const Fw::StringBase &filePath, U8 errorCode) const
Log event SequenceExitedWithError.
void directive_pushTlmValAndTime_internalInterfaceHandler(const Svc::FpySequencer_PushTlmValAndTimeDirective &directive) override
Internal interface handler for directive_pushTlmValAndTime.
int8_t I8
8-bit signed integer
Definition: BasicTypes.h:51
stores a value to a local variable at a compile-time-known offset relative to the current stack frame...
Fw::SerializeStatus serialOut_out(FwIndexType portNum, Fw::LinearBufferBase &buffer)
Invoke output port serialOut.
void directive_constCmd_internalInterfaceHandler(const Svc::FpySequencer_ConstCmdDirective &directive) override
Internal interface handler for directive_constCmd.
Fw::ParamValid getParam_out(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val) const
Invoke output port getParam.
bool isConnected_prmGet_OutputPort(FwIndexType portNum) const
pop an opcode and arg buf off the stack, send to cmd dispatcher and await response ...
void directive_peek_internalInterfaceHandler(const Svc::FpySequencer_PeekDirective &directive) override
Internal interface handler for directive_peek.
TimeBase getTimeBase() const
Definition: Time.cpp:126
void sequencer_sendSignal_stmtResponse_success()
Send signal stmtResponse_success to state machine sequencer.
void directive_loadRel_internalInterfaceHandler(const Svc::FpySequencer_LoadRelDirective &directive) override
Internal interface handler for directive_loadRel.
void directive_memCmp_internalInterfaceHandler(const Svc::FpySequencer_MemCmpDirective &directive) override
Internal interface handler for directive_memCmp.
void directive_pushVal_internalInterfaceHandler(const Svc::FpySequencer_PushValDirective &directive) override
Internal interface handler for directive_pushVal.
void directive_pushPrm_internalInterfaceHandler(const Svc::FpySequencer_PushPrmDirective &directive) override
Internal interface handler for directive_pushPrm.
REQUIRED: Maximum number of serial ports. This sentinel value MUST be named.
pops bytes off the top of the stack and does nothing with them
void directive_pushTime_internalInterfaceHandler(const Svc::FpySequencer_PushTimeDirective &directive) override
Internal interface handler for directive_pushTime.
void log_DIAGNOSTIC_LogDiagnostic(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogDiagnostic.
void log_COMMAND_LogCommand(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogCommand.
U8 FwTimeContextStoreType
The type used to serialize a time context value.
Software diagnostic events.
void directive_pushRand_internalInterfaceHandler(const Svc::FpySequencer_PushRandDirective &directive) override
Internal interface handler for directive_pushRand.
void log_ACTIVITY_LO_LogActivityLo(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogActivityLo.
SerializeStatus
forward declaration for string
float F32
32-bit floating point
Definition: BasicTypes.h:84
Fpy::DirectiveErrorCode DirectiveError
void directive_allocate_internalInterfaceHandler(const Svc::FpySequencer_AllocateDirective &directive) override
Internal interface handler for directive_allocate.
void directive_waitRel_internalInterfaceHandler(const FpySequencer_WaitRelDirective &directive) override
Internal interface handler for directive_waitRel.
void directive_noOp_internalInterfaceHandler(const Svc::FpySequencer_NoOpDirective &directive) override
Internal interface handler for directive_noOp.
loads a value from a local variable at a compile-time-known offset relative to the current stack fram...
void directive_stackCmd_internalInterfaceHandler(const Svc::FpySequencer_StackCmdDirective &directive) override
Internal interface handler for directive_stackCmd.
void log_ACTIVITY_HI_LogActivityHi(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogActivityHi.
void directive_discard_internalInterfaceHandler(const Svc::FpySequencer_DiscardDirective &directive) override
Internal interface handler for directive_discard.
pop two byte arrays off the top of the stack, call memcmp, push 1 if they were equal, 0 otherwise
Svc::Fpy::Header & get_header()
Get member header.
Less important informational events.
pops a severity and message from the stack and emits an F Prime event
An activity related to commanding.
A less serious but recoverable event.
Omit length from serialization.
void directive_exit_internalInterfaceHandler(const Svc::FpySequencer_ExitDirective &directive) override
Internal interface handler for directive_exit.
stores a value to an absolute address in the stack (for global variables), const offset ...
External serialize buffer with no copy semantics.
U32 getSeconds() const
Definition: Time.cpp:118
Svc::Fpy::DirectiveId::T get__op() const
Get member _op.
U8 SerialType
The serial representation type.
void directive_waitAbs_internalInterfaceHandler(const FpySequencer_WaitAbsDirective &directive) override
Internal interface handler for directive_waitAbs.
void log_WARNING_HI_LogWarningHi(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogWarningHi.
void directive_goto_internalInterfaceHandler(const Svc::FpySequencer_GotoDirective &directive) override
Internal interface handler for directive_goto.
peeks at N bytes from the stack, starting from an offset relative to the top of the stack ...
void sequencer_sendSignal_stmtResponse_failure()
Send signal stmtResponse_failure to state machine sequencer.
A serious but recoverable event.
void sequencer_sendSignal_stmtResponse_beginSleep()
Send signal stmtResponse_beginSleep to state machine sequencer.
void directive_popSerializable_internalInterfaceHandler(const Svc::FpySequencer_PopSerializableDirective &directive) override
Internal interface handler for directive_popSerializable.
Representing failure.
void directive_storeAbsConstOffset_internalInterfaceHandler(const Svc::FpySequencer_StoreAbsConstOffsetDirective &directive) override
Internal interface handler for directive_storeAbsConstOffset.
sleeps for a relative duration from the current time
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
bool isConnected_serialOut_OutputPort(FwIndexType portNum) const
void directive_popEvent_internalInterfaceHandler(const Svc::FpySequencer_PopEventDirective &directive) override
Internal interface handler for directive_popEvent.
Important informational events.
static U32 min(const U32 a, const U32 b)
Definition: Checksum.cpp:16
U8 SerialType
The serial representation type.
static Time add(const Time &a, const Time &b)
Definition: Time.cpp:164
void sequencer_sendSignal_stmtResponse_keepWaiting()
Send signal stmtResponse_keepWaiting to state machine sequencer.
FwTimeContextStoreType getContext() const
Definition: Time.cpp:130
U32 getUSeconds() const
Definition: Time.cpp:122
called when the statement unsuccessfully executed. only raised in the RUNNING.AWAITING_CMD_RESPONSE s...
loads a value from an absolute address in the stack (for global variables)
PlatformIndexType FwIndexType
pops a U32 from the stack and uses it to seed the RNG used by PushRandDirective
double F64
64-bit floating point (double). Required for compiler-supplied double promotion.
Definition: BasicTypes.h:86
pops serialized data from stack and sends to serial output port
A fatal non-recoverable event.
void log_WARNING_LO_LogWarningLo(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogWarningLo.
stores a value to a local variable at a runtime-determined offset relative to the current stack frame...
RateGroupDivider component implementation.
U8 * getBuffAddr() override
Get buffer address for data filling (non-const version)
Enum representing parameter validity.
void log_FATAL_LogFatal(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogFatal.
void directive_storeAbs_internalInterfaceHandler(const Svc::FpySequencer_StoreAbsDirective &directive) override
Internal interface handler for directive_storeAbs.
U16 FwTimeBaseStoreType
The type used to serialize a time base value.
pushes the current Fw.Time struct to the stack
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
called when the statement is telling the sequencer to await a later stmt response ...
FpySequencer_SequencerStateMachineStateMachineBase::Signal Signal
Fw::TlmValid getTlmChan_out(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke output port getTlmChan.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
Success/Failure.
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.
U32 StackSizeType
the type which everything referencing a size or offset on the stack is represented in ...
void directive_pushTlmVal_internalInterfaceHandler(const Svc::FpySequencer_PushTlmValDirective &directive) override
Internal interface handler for directive_pushTlmVal.
#define U64(C)
Definition: sha.h:181