F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
DpWriterComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title DpWriterComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for DpWriter component base class
5 // ======================================================================
6 
7 #include "Fw/Types/Assert.hpp"
9 #if FW_ENABLE_TEXT_LOGGING
10 #include "Fw/Types/String.hpp"
11 #endif
13 
14 namespace Svc {
15 
16  namespace {
17  enum MsgTypeEnum {
18  DPWRITER_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  BUFFERSENDIN_BUFFERSEND,
20  SCHEDIN_SCHED,
21  CMD_CLEAR_EVENT_THROTTLE,
22  };
23 
24  // Get the max size by constructing a union of the async input, command, and
25  // internal port serialization sizes
26  union BuffUnion {
27  BYTE bufferSendInPortSize[Fw::BufferSendPortBuffer::CAPACITY];
28  BYTE schedInPortSize[Svc::SchedPortBuffer::CAPACITY];
29  BYTE cmdPortSize[Fw::CmdPortBuffer::CAPACITY];
30  };
31 
32  // Define a message buffer class large enough to handle all the
33  // asynchronous inputs to the component
34  class ComponentIpcSerializableBuffer :
36  {
37 
38  public:
39 
40  enum {
41  // Offset into data in buffer: Size of message ID and port number
42  DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
43  // Max data size
44  MAX_DATA_SIZE = sizeof(BuffUnion),
45  // Max message size: Size of message id + size of port + max data size
46  SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
47  };
48 
49  Fw::Serializable::SizeType getCapacity() const {
50  return sizeof(m_buff);
51  }
52 
53  U8* getBuffAddr() {
54  return m_buff;
55  }
56 
57  const U8* getBuffAddr() const {
58  return m_buff;
59  }
60 
61  private:
62  // Should be the max of all the input ports serialized sizes...
63  U8 m_buff[SERIALIZATION_SIZE];
64 
65  };
66  }
67 
68  // ----------------------------------------------------------------------
69  // Component initialization
70  // ----------------------------------------------------------------------
71 
74  FwSizeType queueDepth,
75  FwEnumStoreType instance
76  )
77  {
78  // Initialize base class
80 
81 #if !FW_DIRECT_PORT_CALLS
82  // Connect input port cmdIn
83  for (
84  FwIndexType port = 0;
85  port < static_cast<FwIndexType>(this->getNum_cmdIn_InputPorts());
86  port++
87  ) {
88  this->m_cmdIn_InputPort[port].init();
89  this->m_cmdIn_InputPort[port].addCallComp(
90  this,
91  m_p_cmdIn_in
92  );
93  this->m_cmdIn_InputPort[port].setPortNum(port);
94 
95 #if FW_OBJECT_NAMES == 1
96  Fw::ObjectName portName;
97  portName.format(
98  "%s_cmdIn_InputPort[%" PRI_FwIndexType "]",
99  this->m_objName.toChar(),
100  port
101  );
102  this->m_cmdIn_InputPort[port].setObjName(portName.toChar());
103 #endif
104  }
105 #endif
106 
107 #if !FW_DIRECT_PORT_CALLS
108  // Connect input port bufferSendIn
109  for (
110  FwIndexType port = 0;
111  port < static_cast<FwIndexType>(this->getNum_bufferSendIn_InputPorts());
112  port++
113  ) {
114  this->m_bufferSendIn_InputPort[port].init();
115  this->m_bufferSendIn_InputPort[port].addCallComp(
116  this,
117  m_p_bufferSendIn_in
118  );
119  this->m_bufferSendIn_InputPort[port].setPortNum(port);
120 
121 #if FW_OBJECT_NAMES == 1
122  Fw::ObjectName portName;
123  portName.format(
124  "%s_bufferSendIn_InputPort[%" PRI_FwIndexType "]",
125  this->m_objName.toChar(),
126  port
127  );
128  this->m_bufferSendIn_InputPort[port].setObjName(portName.toChar());
129 #endif
130  }
131 #endif
132 
133 #if !FW_DIRECT_PORT_CALLS
134  // Connect input port schedIn
135  for (
136  FwIndexType port = 0;
137  port < static_cast<FwIndexType>(this->getNum_schedIn_InputPorts());
138  port++
139  ) {
140  this->m_schedIn_InputPort[port].init();
141  this->m_schedIn_InputPort[port].addCallComp(
142  this,
143  m_p_schedIn_in
144  );
145  this->m_schedIn_InputPort[port].setPortNum(port);
146 
147 #if FW_OBJECT_NAMES == 1
148  Fw::ObjectName portName;
149  portName.format(
150  "%s_schedIn_InputPort[%" PRI_FwIndexType "]",
151  this->m_objName.toChar(),
152  port
153  );
154  this->m_schedIn_InputPort[port].setObjName(portName.toChar());
155 #endif
156  }
157 #endif
158 
159 #if !FW_DIRECT_PORT_CALLS
160  // Connect output port cmdRegIn
161  for (
162  FwIndexType port = 0;
163  port < static_cast<FwIndexType>(this->getNum_cmdRegIn_OutputPorts());
164  port++
165  ) {
166  this->m_cmdRegIn_OutputPort[port].init();
167 
168 #if FW_OBJECT_NAMES == 1
169  Fw::ObjectName portName;
170  portName.format(
171  "%s_cmdRegIn_OutputPort[%" PRI_FwIndexType "]",
172  this->m_objName.toChar(),
173  port
174  );
175  this->m_cmdRegIn_OutputPort[port].setObjName(portName.toChar());
176 #endif
177  }
178 #endif
179 
180 #if !FW_DIRECT_PORT_CALLS
181  // Connect output port cmdResponseOut
182  for (
183  FwIndexType port = 0;
184  port < static_cast<FwIndexType>(this->getNum_cmdResponseOut_OutputPorts());
185  port++
186  ) {
187  this->m_cmdResponseOut_OutputPort[port].init();
188 
189 #if FW_OBJECT_NAMES == 1
190  Fw::ObjectName portName;
191  portName.format(
192  "%s_cmdResponseOut_OutputPort[%" PRI_FwIndexType "]",
193  this->m_objName.toChar(),
194  port
195  );
196  this->m_cmdResponseOut_OutputPort[port].setObjName(portName.toChar());
197 #endif
198  }
199 #endif
200 
201 #if !FW_DIRECT_PORT_CALLS
202  // Connect output port eventOut
203  for (
204  FwIndexType port = 0;
205  port < static_cast<FwIndexType>(this->getNum_eventOut_OutputPorts());
206  port++
207  ) {
208  this->m_eventOut_OutputPort[port].init();
209 
210 #if FW_OBJECT_NAMES == 1
211  Fw::ObjectName portName;
212  portName.format(
213  "%s_eventOut_OutputPort[%" PRI_FwIndexType "]",
214  this->m_objName.toChar(),
215  port
216  );
217  this->m_eventOut_OutputPort[port].setObjName(portName.toChar());
218 #endif
219  }
220 #endif
221 
222 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
223  // Connect output port textEventOut
224  for (
225  FwIndexType port = 0;
226  port < static_cast<FwIndexType>(this->getNum_textEventOut_OutputPorts());
227  port++
228  ) {
229  this->m_textEventOut_OutputPort[port].init();
230 
231 #if FW_OBJECT_NAMES == 1
232  Fw::ObjectName portName;
233  portName.format(
234  "%s_textEventOut_OutputPort[%" PRI_FwIndexType "]",
235  this->m_objName.toChar(),
236  port
237  );
238  this->m_textEventOut_OutputPort[port].setObjName(portName.toChar());
239 #endif
240  }
241 #endif
242 
243 #if !FW_DIRECT_PORT_CALLS
244  // Connect output port timeGetOut
245  for (
246  FwIndexType port = 0;
247  port < static_cast<FwIndexType>(this->getNum_timeGetOut_OutputPorts());
248  port++
249  ) {
250  this->m_timeGetOut_OutputPort[port].init();
251 
252 #if FW_OBJECT_NAMES == 1
253  Fw::ObjectName portName;
254  portName.format(
255  "%s_timeGetOut_OutputPort[%" PRI_FwIndexType "]",
256  this->m_objName.toChar(),
257  port
258  );
259  this->m_timeGetOut_OutputPort[port].setObjName(portName.toChar());
260 #endif
261  }
262 #endif
263 
264 #if !FW_DIRECT_PORT_CALLS
265  // Connect output port tlmOut
266  for (
267  FwIndexType port = 0;
268  port < static_cast<FwIndexType>(this->getNum_tlmOut_OutputPorts());
269  port++
270  ) {
271  this->m_tlmOut_OutputPort[port].init();
272 
273 #if FW_OBJECT_NAMES == 1
274  Fw::ObjectName portName;
275  portName.format(
276  "%s_tlmOut_OutputPort[%" PRI_FwIndexType "]",
277  this->m_objName.toChar(),
278  port
279  );
280  this->m_tlmOut_OutputPort[port].setObjName(portName.toChar());
281 #endif
282  }
283 #endif
284 
285 #if !FW_DIRECT_PORT_CALLS
286  // Connect output port deallocBufferSendOut
287  for (
288  FwIndexType port = 0;
289  port < static_cast<FwIndexType>(this->getNum_deallocBufferSendOut_OutputPorts());
290  port++
291  ) {
292  this->m_deallocBufferSendOut_OutputPort[port].init();
293 
294 #if FW_OBJECT_NAMES == 1
295  Fw::ObjectName portName;
296  portName.format(
297  "%s_deallocBufferSendOut_OutputPort[%" PRI_FwIndexType "]",
298  this->m_objName.toChar(),
299  port
300  );
301  this->m_deallocBufferSendOut_OutputPort[port].setObjName(portName.toChar());
302 #endif
303  }
304 #endif
305 
306 #if !FW_DIRECT_PORT_CALLS
307  // Connect output port dpWrittenOut
308  for (
309  FwIndexType port = 0;
310  port < static_cast<FwIndexType>(this->getNum_dpWrittenOut_OutputPorts());
311  port++
312  ) {
313  this->m_dpWrittenOut_OutputPort[port].init();
314 
315 #if FW_OBJECT_NAMES == 1
316  Fw::ObjectName portName;
317  portName.format(
318  "%s_dpWrittenOut_OutputPort[%" PRI_FwIndexType "]",
319  this->m_objName.toChar(),
320  port
321  );
322  this->m_dpWrittenOut_OutputPort[port].setObjName(portName.toChar());
323 #endif
324  }
325 #endif
326 
327 #if !FW_DIRECT_PORT_CALLS
328  // Connect output port procBufferSendOut
329  for (
330  FwIndexType port = 0;
331  port < static_cast<FwIndexType>(this->getNum_procBufferSendOut_OutputPorts());
332  port++
333  ) {
334  this->m_procBufferSendOut_OutputPort[port].init();
335 
336 #if FW_OBJECT_NAMES == 1
337  Fw::ObjectName portName;
338  portName.format(
339  "%s_procBufferSendOut_OutputPort[%" PRI_FwIndexType "]",
340  this->m_objName.toChar(),
341  port
342  );
343  this->m_procBufferSendOut_OutputPort[port].setObjName(portName.toChar());
344 #endif
345  }
346 #endif
347 
348  // Create the queue
349  Os::Queue::Status qStat = this->createQueue(
350  queueDepth,
351  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
352  );
353  FW_ASSERT(
354  Os::Queue::Status::OP_OK == qStat,
355  static_cast<FwAssertArgType>(qStat)
356  );
357  }
358 
359 #if !FW_DIRECT_PORT_CALLS
360 
361  // ----------------------------------------------------------------------
362  // Getters for special input ports
363  // ----------------------------------------------------------------------
364 
367  {
368  FW_ASSERT(
369  (0 <= portNum) && (portNum < this->getNum_cmdIn_InputPorts()),
370  static_cast<FwAssertArgType>(portNum)
371  );
372 
373  return &this->m_cmdIn_InputPort[portNum];
374  }
375 
376 #endif
377 
378 #if !FW_DIRECT_PORT_CALLS
379 
380  // ----------------------------------------------------------------------
381  // Getters for typed input ports
382  // ----------------------------------------------------------------------
383 
386  {
387  FW_ASSERT(
388  (0 <= portNum) && (portNum < this->getNum_bufferSendIn_InputPorts()),
389  static_cast<FwAssertArgType>(portNum)
390  );
391 
392  return &this->m_bufferSendIn_InputPort[portNum];
393  }
394 
397  {
398  FW_ASSERT(
399  (0 <= portNum) && (portNum < this->getNum_schedIn_InputPorts()),
400  static_cast<FwAssertArgType>(portNum)
401  );
402 
403  return &this->m_schedIn_InputPort[portNum];
404  }
405 
406 #endif
407 
408 #if !FW_DIRECT_PORT_CALLS
409 
410  // ----------------------------------------------------------------------
411  // Connect input ports to special output ports
412  // ----------------------------------------------------------------------
413 
416  FwIndexType portNum,
417  Fw::InputCmdRegPort* port
418  )
419  {
420  FW_ASSERT(
421  (0 <= portNum) && (portNum < this->getNum_cmdRegIn_OutputPorts()),
422  static_cast<FwAssertArgType>(portNum)
423  );
424 
425  this->m_cmdRegIn_OutputPort[portNum].addCallPort(port);
426  }
427 
430  FwIndexType portNum,
432  )
433  {
434  FW_ASSERT(
435  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
436  static_cast<FwAssertArgType>(portNum)
437  );
438 
439  this->m_cmdResponseOut_OutputPort[portNum].addCallPort(port);
440  }
441 
444  FwIndexType portNum,
445  Fw::InputLogPort* port
446  )
447  {
448  FW_ASSERT(
449  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
450  static_cast<FwAssertArgType>(portNum)
451  );
452 
453  this->m_eventOut_OutputPort[portNum].addCallPort(port);
454  }
455 
456 #if FW_ENABLE_TEXT_LOGGING == 1
457 
458  void DpWriterComponentBase ::
459  set_textEventOut_OutputPort(
460  FwIndexType portNum,
462  )
463  {
464  FW_ASSERT(
465  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
466  static_cast<FwAssertArgType>(portNum)
467  );
468 
469  this->m_textEventOut_OutputPort[portNum].addCallPort(port);
470  }
471 
472 #endif
473 
476  FwIndexType portNum,
477  Fw::InputTimePort* port
478  )
479  {
480  FW_ASSERT(
481  (0 <= portNum) && (portNum < this->getNum_timeGetOut_OutputPorts()),
482  static_cast<FwAssertArgType>(portNum)
483  );
484 
485  this->m_timeGetOut_OutputPort[portNum].addCallPort(port);
486  }
487 
490  FwIndexType portNum,
491  Fw::InputTlmPort* port
492  )
493  {
494  FW_ASSERT(
495  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
496  static_cast<FwAssertArgType>(portNum)
497  );
498 
499  this->m_tlmOut_OutputPort[portNum].addCallPort(port);
500  }
501 
502 #endif
503 
504 #if !FW_DIRECT_PORT_CALLS
505 
506  // ----------------------------------------------------------------------
507  // Connect typed input ports to typed output ports
508  // ----------------------------------------------------------------------
509 
512  FwIndexType portNum,
514  )
515  {
516  FW_ASSERT(
517  (0 <= portNum) && (portNum < this->getNum_deallocBufferSendOut_OutputPorts()),
518  static_cast<FwAssertArgType>(portNum)
519  );
520 
521  this->m_deallocBufferSendOut_OutputPort[portNum].addCallPort(port);
522  }
523 
526  FwIndexType portNum,
528  )
529  {
530  FW_ASSERT(
531  (0 <= portNum) && (portNum < this->getNum_dpWrittenOut_OutputPorts()),
532  static_cast<FwAssertArgType>(portNum)
533  );
534 
535  this->m_dpWrittenOut_OutputPort[portNum].addCallPort(port);
536  }
537 
540  FwIndexType portNum,
542  )
543  {
544  FW_ASSERT(
545  (0 <= portNum) && (portNum < this->getNum_procBufferSendOut_OutputPorts()),
546  static_cast<FwAssertArgType>(portNum)
547  );
548 
549  this->m_procBufferSendOut_OutputPort[portNum].addCallPort(port);
550  }
551 
552 #endif
553 
554 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
555 
556  // ----------------------------------------------------------------------
557  // Connect serial input ports to special output ports
558  // ----------------------------------------------------------------------
559 
562  FwIndexType portNum,
563  Fw::InputSerializePort* port
564  )
565  {
566  FW_ASSERT(
567  (0 <= portNum) && (portNum < this->getNum_cmdRegIn_OutputPorts()),
568  static_cast<FwAssertArgType>(portNum)
569  );
570 
571  this->m_cmdRegIn_OutputPort[portNum].registerSerialPort(port);
572  }
573 
576  FwIndexType portNum,
577  Fw::InputSerializePort* port
578  )
579  {
580  FW_ASSERT(
581  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
582  static_cast<FwAssertArgType>(portNum)
583  );
584 
585  this->m_cmdResponseOut_OutputPort[portNum].registerSerialPort(port);
586  }
587 
590  FwIndexType portNum,
591  Fw::InputSerializePort* port
592  )
593  {
594  FW_ASSERT(
595  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
596  static_cast<FwAssertArgType>(portNum)
597  );
598 
599  this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
600  }
601 
602 #if FW_ENABLE_TEXT_LOGGING == 1
603 
604  void DpWriterComponentBase ::
605  set_textEventOut_OutputPort(
606  FwIndexType portNum,
607  Fw::InputSerializePort* port
608  )
609  {
610  FW_ASSERT(
611  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
612  static_cast<FwAssertArgType>(portNum)
613  );
614 
615  this->m_textEventOut_OutputPort[portNum].registerSerialPort(port);
616  }
617 
618 #endif
619 
622  FwIndexType portNum,
623  Fw::InputSerializePort* port
624  )
625  {
626  FW_ASSERT(
627  (0 <= portNum) && (portNum < this->getNum_timeGetOut_OutputPorts()),
628  static_cast<FwAssertArgType>(portNum)
629  );
630 
631  this->m_timeGetOut_OutputPort[portNum].registerSerialPort(port);
632  }
633 
636  FwIndexType portNum,
637  Fw::InputSerializePort* port
638  )
639  {
640  FW_ASSERT(
641  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
642  static_cast<FwAssertArgType>(portNum)
643  );
644 
645  this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
646  }
647 
648 #endif
649 
650 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
651 
652  // ----------------------------------------------------------------------
653  // Connect serial input ports to typed output ports
654  // ----------------------------------------------------------------------
655 
658  FwIndexType portNum,
659  Fw::InputSerializePort* port
660  )
661  {
662  FW_ASSERT(
663  (0 <= portNum) && (portNum < this->getNum_deallocBufferSendOut_OutputPorts()),
664  static_cast<FwAssertArgType>(portNum)
665  );
666 
667  this->m_deallocBufferSendOut_OutputPort[portNum].registerSerialPort(port);
668  }
669 
672  FwIndexType portNum,
673  Fw::InputSerializePort* port
674  )
675  {
676  FW_ASSERT(
677  (0 <= portNum) && (portNum < this->getNum_dpWrittenOut_OutputPorts()),
678  static_cast<FwAssertArgType>(portNum)
679  );
680 
681  this->m_dpWrittenOut_OutputPort[portNum].registerSerialPort(port);
682  }
683 
686  FwIndexType portNum,
687  Fw::InputSerializePort* port
688  )
689  {
690  FW_ASSERT(
691  (0 <= portNum) && (portNum < this->getNum_procBufferSendOut_OutputPorts()),
692  static_cast<FwAssertArgType>(portNum)
693  );
694 
695  this->m_procBufferSendOut_OutputPort[portNum].registerSerialPort(port);
696  }
697 
698 #endif
699 
700  // ----------------------------------------------------------------------
701  // Command registration
702  // ----------------------------------------------------------------------
703 
706  {
708 
709  this->cmdRegIn_out(
710  0,
712  );
713  }
714 
715  // ----------------------------------------------------------------------
716  // Component construction and destruction
717  // ----------------------------------------------------------------------
718 
720  DpWriterComponentBase(const char* compName) :
721  Fw::ActiveComponentBase(compName)
722  {
723  this->m_InvalidBufferThrottle = 0;
724  this->m_BufferTooSmallForPacketThrottle = 0;
725  this->m_InvalidHeaderHashThrottle = 0;
726  this->m_InvalidHeaderThrottle = 0;
727  this->m_BufferTooSmallForDataThrottle = 0;
728  this->m_FileOpenErrorThrottle = 0;
729  this->m_FileWriteErrorThrottle = 0;
730  }
731 
734  {
735 
736  }
737 
738 #if !FW_DIRECT_PORT_CALLS
739 
740  // ----------------------------------------------------------------------
741  // Connection status queries for special output ports
742  // ----------------------------------------------------------------------
743 
746  {
747  FW_ASSERT(
748  (0 <= portNum) && (portNum < this->getNum_cmdRegIn_OutputPorts()),
749  static_cast<FwAssertArgType>(portNum)
750  );
751 
752  return this->m_cmdRegIn_OutputPort[portNum].isConnected();
753  }
754 
757  {
758  FW_ASSERT(
759  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
760  static_cast<FwAssertArgType>(portNum)
761  );
762 
763  return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
764  }
765 
768  {
769  FW_ASSERT(
770  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
771  static_cast<FwAssertArgType>(portNum)
772  );
773 
774  return this->m_eventOut_OutputPort[portNum].isConnected();
775  }
776 
777 #if FW_ENABLE_TEXT_LOGGING == 1
778 
779  bool DpWriterComponentBase ::
780  isConnected_textEventOut_OutputPort(FwIndexType portNum) const
781  {
782  FW_ASSERT(
783  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
784  static_cast<FwAssertArgType>(portNum)
785  );
786 
787  return this->m_textEventOut_OutputPort[portNum].isConnected();
788  }
789 
790 #endif
791 
794  {
795  FW_ASSERT(
796  (0 <= portNum) && (portNum < this->getNum_timeGetOut_OutputPorts()),
797  static_cast<FwAssertArgType>(portNum)
798  );
799 
800  return this->m_timeGetOut_OutputPort[portNum].isConnected();
801  }
802 
805  {
806  FW_ASSERT(
807  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
808  static_cast<FwAssertArgType>(portNum)
809  );
810 
811  return this->m_tlmOut_OutputPort[portNum].isConnected();
812  }
813 
814 #endif
815 
816 #if !FW_DIRECT_PORT_CALLS
817 
818  // ----------------------------------------------------------------------
819  // Connection status queries for typed output ports
820  // ----------------------------------------------------------------------
821 
824  {
825  FW_ASSERT(
826  (0 <= portNum) && (portNum < this->getNum_deallocBufferSendOut_OutputPorts()),
827  static_cast<FwAssertArgType>(portNum)
828  );
829 
830  return this->m_deallocBufferSendOut_OutputPort[portNum].isConnected();
831  }
832 
835  {
836  FW_ASSERT(
837  (0 <= portNum) && (portNum < this->getNum_dpWrittenOut_OutputPorts()),
838  static_cast<FwAssertArgType>(portNum)
839  );
840 
841  return this->m_dpWrittenOut_OutputPort[portNum].isConnected();
842  }
843 
846  {
847  FW_ASSERT(
848  (0 <= portNum) && (portNum < this->getNum_procBufferSendOut_OutputPorts()),
849  static_cast<FwAssertArgType>(portNum)
850  );
851 
852  return this->m_procBufferSendOut_OutputPort[portNum].isConnected();
853  }
854 
855 #endif
856 
857  // ----------------------------------------------------------------------
858  // Port handler base-class functions for special input ports
859  //
860  // Call these functions directly to bypass the corresponding ports
861  // ----------------------------------------------------------------------
862 
865  FwIndexType portNum,
866  FwOpcodeType opCode,
867  U32 cmdSeq,
868  Fw::CmdArgBuffer& args
869  )
870  {
871 
872  const U32 idBase = this->getIdBase();
873  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
874 
875  // Select base class function based on opcode
876  switch (opCode - idBase) {
879  opCode,
880  cmdSeq,
881  args
882  );
883  break;
884  }
885  default:
886  // Unknown opcode: ignore it
887  break;
888  }
889  }
890 
891  // ----------------------------------------------------------------------
892  // Port handler base-class functions for typed input ports
893  //
894  // Call these functions directly to bypass the corresponding ports
895  // ----------------------------------------------------------------------
896 
899  FwIndexType portNum,
900  Fw::Buffer& fwBuffer
901  )
902  {
903  // Make sure port number is valid
904  FW_ASSERT(
905  (0 <= portNum) && (portNum < this->getNum_bufferSendIn_InputPorts()),
906  static_cast<FwAssertArgType>(portNum)
907  );
908 
909  // Call pre-message hook
911  portNum,
912  fwBuffer
913  );
914  ComponentIpcSerializableBuffer msg;
916 
917  // Serialize message ID
918  _status = msg.serializeFrom(
919  static_cast<FwEnumStoreType>(BUFFERSENDIN_BUFFERSEND)
920  );
921  FW_ASSERT(
922  _status == Fw::FW_SERIALIZE_OK,
923  static_cast<FwAssertArgType>(_status)
924  );
925 
926  // Serialize port number
927  _status = msg.serializeFrom(portNum);
928  FW_ASSERT(
929  _status == Fw::FW_SERIALIZE_OK,
930  static_cast<FwAssertArgType>(_status)
931  );
932 
933  // Serialize argument fwBuffer
934  _status = msg.serializeFrom(fwBuffer);
935  FW_ASSERT(
936  _status == Fw::FW_SERIALIZE_OK,
937  static_cast<FwAssertArgType>(_status)
938  );
939 
940  // Send message
942  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
943 
944  FW_ASSERT(
945  qStatus == Os::Queue::OP_OK,
946  static_cast<FwAssertArgType>(qStatus)
947  );
948  }
949 
952  FwIndexType portNum,
953  U32 context
954  )
955  {
956  // Make sure port number is valid
957  FW_ASSERT(
958  (0 <= portNum) && (portNum < this->getNum_schedIn_InputPorts()),
959  static_cast<FwAssertArgType>(portNum)
960  );
961 
962  // Call pre-message hook
964  portNum,
965  context
966  );
967  ComponentIpcSerializableBuffer msg;
969 
970  // Serialize message ID
971  _status = msg.serializeFrom(
972  static_cast<FwEnumStoreType>(SCHEDIN_SCHED)
973  );
974  FW_ASSERT(
975  _status == Fw::FW_SERIALIZE_OK,
976  static_cast<FwAssertArgType>(_status)
977  );
978 
979  // Serialize port number
980  _status = msg.serializeFrom(portNum);
981  FW_ASSERT(
982  _status == Fw::FW_SERIALIZE_OK,
983  static_cast<FwAssertArgType>(_status)
984  );
985 
986  // Serialize argument context
987  _status = msg.serializeFrom(context);
988  FW_ASSERT(
989  _status == Fw::FW_SERIALIZE_OK,
990  static_cast<FwAssertArgType>(_status)
991  );
992 
993  // Send message
995  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
996 
997  FW_ASSERT(
998  qStatus == Os::Queue::OP_OK,
999  static_cast<FwAssertArgType>(qStatus)
1000  );
1001  }
1002 
1003  // ----------------------------------------------------------------------
1004  // Pre-message hooks for typed async input ports
1005  //
1006  // Each of these functions is invoked just before processing a message
1007  // on the corresponding port. By default, they do nothing. You can
1008  // override them to provide specific pre-message behavior.
1009  // ----------------------------------------------------------------------
1010 
1013  FwIndexType portNum,
1014  Fw::Buffer& fwBuffer
1015  )
1016  {
1017  // Default: no-op
1018  }
1019 
1022  FwIndexType portNum,
1023  U32 context
1024  )
1025  {
1026  // Default: no-op
1027  }
1028 
1029 #if !FW_DIRECT_PORT_CALLS
1030 
1031  // ----------------------------------------------------------------------
1032  // Invocation functions for typed output ports
1033  // ----------------------------------------------------------------------
1034 
1037  FwIndexType portNum,
1038  Fw::Buffer& fwBuffer
1039  ) const
1040  {
1041  FW_ASSERT(
1042  (0 <= portNum) && (portNum < this->getNum_deallocBufferSendOut_OutputPorts()),
1043  static_cast<FwAssertArgType>(portNum)
1044  );
1045 
1046  FW_ASSERT(
1047  this->m_deallocBufferSendOut_OutputPort[portNum].isConnected(),
1048  static_cast<FwAssertArgType>(portNum)
1049  );
1050  this->m_deallocBufferSendOut_OutputPort[portNum].invoke(
1051  fwBuffer
1052  );
1053  }
1054 
1057  FwIndexType portNum,
1058  const Fw::StringBase& fileName,
1059  FwDpPriorityType priority,
1060  FwSizeType size
1061  ) const
1062  {
1063  FW_ASSERT(
1064  (0 <= portNum) && (portNum < this->getNum_dpWrittenOut_OutputPorts()),
1065  static_cast<FwAssertArgType>(portNum)
1066  );
1067 
1068  FW_ASSERT(
1069  this->m_dpWrittenOut_OutputPort[portNum].isConnected(),
1070  static_cast<FwAssertArgType>(portNum)
1071  );
1072  this->m_dpWrittenOut_OutputPort[portNum].invoke(
1073  fileName,
1074  priority,
1075  size
1076  );
1077  }
1078 
1081  FwIndexType portNum,
1082  Fw::Buffer& fwBuffer
1083  ) const
1084  {
1085  FW_ASSERT(
1086  (0 <= portNum) && (portNum < this->getNum_procBufferSendOut_OutputPorts()),
1087  static_cast<FwAssertArgType>(portNum)
1088  );
1089 
1090  FW_ASSERT(
1091  this->m_procBufferSendOut_OutputPort[portNum].isConnected(),
1092  static_cast<FwAssertArgType>(portNum)
1093  );
1094  this->m_procBufferSendOut_OutputPort[portNum].invoke(
1095  fwBuffer
1096  );
1097  }
1098 
1099 #endif
1100 
1101  // ----------------------------------------------------------------------
1102  // Command response
1103  // ----------------------------------------------------------------------
1104 
1107  FwOpcodeType opCode,
1108  U32 cmdSeq,
1109  Fw::CmdResponse response
1110  )
1111  {
1113  this->cmdResponseOut_out(0, opCode, cmdSeq, response);
1114  }
1115 
1116  // ----------------------------------------------------------------------
1117  // Command handler base-class functions
1118  //
1119  // Call these functions directly to bypass the command input port
1120  // ----------------------------------------------------------------------
1121 
1124  FwOpcodeType opCode,
1125  U32 cmdSeq,
1126  Fw::CmdArgBuffer& args
1127  )
1128  {
1129  // Call pre-message hook
1130  this->CLEAR_EVENT_THROTTLE_preMsgHook(opCode,cmdSeq);
1131 
1132  // Defer deserializing arguments to the message dispatcher
1133  // to avoid deserializing and reserializing just for IPC
1134  ComponentIpcSerializableBuffer msg;
1136 
1137  // Serialize for IPC
1138  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_CLEAR_EVENT_THROTTLE));
1139  FW_ASSERT (
1140  _status == Fw::FW_SERIALIZE_OK,
1141  static_cast<FwAssertArgType>(_status)
1142  );
1143 
1144  // Fake port number to make message dequeue work
1145  FwIndexType port = 0;
1146 
1147  _status = msg.serializeFrom(port);
1148  FW_ASSERT (
1149  _status == Fw::FW_SERIALIZE_OK,
1150  static_cast<FwAssertArgType>(_status)
1151  );
1152 
1153  _status = msg.serializeFrom(opCode);
1154  FW_ASSERT (
1155  _status == Fw::FW_SERIALIZE_OK,
1156  static_cast<FwAssertArgType>(_status)
1157  );
1158 
1159  _status = msg.serializeFrom(cmdSeq);
1160  FW_ASSERT (
1161  _status == Fw::FW_SERIALIZE_OK,
1162  static_cast<FwAssertArgType>(_status)
1163  );
1164 
1165  _status = msg.serializeFrom(args);
1166  FW_ASSERT (
1167  _status == Fw::FW_SERIALIZE_OK,
1168  static_cast<FwAssertArgType>(_status)
1169  );
1170 
1171  // Send message
1173  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1174 
1175  FW_ASSERT(
1176  qStatus == Os::Queue::OP_OK,
1177  static_cast<FwAssertArgType>(qStatus)
1178  );
1179  }
1180 
1181  // ----------------------------------------------------------------------
1182  // Pre-message hooks for async commands
1183  //
1184  // Each of these functions is invoked just before processing the
1185  // corresponding command. By default they do nothing. You can
1186  // override them to provide specific pre-command behavior.
1187  // ----------------------------------------------------------------------
1188 
1191  FwOpcodeType opCode,
1192  U32 cmdSeq
1193  )
1194  {
1195  // Defaults to no-op; can be overridden
1196  (void) opCode;
1197  (void) cmdSeq;
1198  }
1199 
1200  // ----------------------------------------------------------------------
1201  // Event logging functions
1202  // ----------------------------------------------------------------------
1203 
1206  {
1207  // Check throttle value
1208  if (this->m_InvalidBufferThrottle >= EVENTID_INVALIDBUFFER_THROTTLE) {
1209  return;
1210  }
1211  else {
1212  this->m_InvalidBufferThrottle++;
1213  }
1214 
1215  // Get the time
1216  Fw::Time _logTime;
1217  if (this->isConnected_timeGetOut_OutputPort(0)) {
1218  this->timeGetOut_out(0, _logTime);
1219  }
1220 
1221  const FwEventIdType _id = this->getIdBase() + EVENTID_INVALIDBUFFER;
1222 
1223  // Emit the event on the log port
1224  if (this->isConnected_eventOut_OutputPort(0)) {
1225  Fw::LogBuffer _logBuff;
1226 
1227 #if FW_AMPCS_COMPATIBLE
1229  // Serialize the number of arguments
1230  _status = _logBuff.serializeFrom(static_cast<U8>(0));
1231  FW_ASSERT(
1232  _status == Fw::FW_SERIALIZE_OK,
1233  static_cast<FwAssertArgType>(_status)
1234  );
1235 #endif
1236 
1237  this->eventOut_out(
1238  0,
1239  _id,
1240  _logTime,
1242  _logBuff
1243  );
1244  }
1245 
1246  // Emit the event on the text log port
1247 #if FW_ENABLE_TEXT_LOGGING
1248  if (this->isConnected_textEventOut_OutputPort(0)) {
1249 #if FW_OBJECT_NAMES == 1
1250  const char* _formatString =
1251  "(%s) %s: Received buffer is invalid";
1252 #else
1253  const char* _formatString =
1254  "%s: Received buffer is invalid";
1255 #endif
1256 
1257  Fw::TextLogString _logString;
1258  _logString.format(
1259  _formatString,
1260 #if FW_OBJECT_NAMES == 1
1261  this->m_objName.toChar(),
1262 #endif
1263  "InvalidBuffer "
1264  );
1265 
1266  this->textEventOut_out(
1267  0,
1268  _id,
1269  _logTime,
1271  _logString
1272  );
1273  }
1274 #endif
1275  }
1276 
1279  FwSizeType bufferSize,
1280  U32 minSize
1281  )
1282  {
1283  // Check throttle value
1284  if (this->m_BufferTooSmallForPacketThrottle >= EVENTID_BUFFERTOOSMALLFORPACKET_THROTTLE) {
1285  return;
1286  }
1287  else {
1288  this->m_BufferTooSmallForPacketThrottle++;
1289  }
1290 
1291  // Get the time
1292  Fw::Time _logTime;
1293  if (this->isConnected_timeGetOut_OutputPort(0)) {
1294  this->timeGetOut_out(0, _logTime);
1295  }
1296 
1298 
1299  // Emit the event on the log port
1300  if (this->isConnected_eventOut_OutputPort(0)) {
1301  Fw::LogBuffer _logBuff;
1303 
1304 #if FW_AMPCS_COMPATIBLE
1305  // Serialize the number of arguments
1306  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1307  FW_ASSERT(
1308  _status == Fw::FW_SERIALIZE_OK,
1309  static_cast<FwAssertArgType>(_status)
1310  );
1311 #endif
1312 
1313 #if FW_AMPCS_COMPATIBLE
1314  // Serialize the argument size
1315  _status = _logBuff.serializeFrom(
1316  static_cast<U8>(sizeof(FwSizeType))
1317  );
1318  FW_ASSERT(
1319  _status == Fw::FW_SERIALIZE_OK,
1320  static_cast<FwAssertArgType>(_status)
1321  );
1322 #endif
1323  _status = _logBuff.serializeFrom(bufferSize);
1324  FW_ASSERT(
1325  _status == Fw::FW_SERIALIZE_OK,
1326  static_cast<FwAssertArgType>(_status)
1327  );
1328 
1329 #if FW_AMPCS_COMPATIBLE
1330  // Serialize the argument size
1331  _status = _logBuff.serializeFrom(
1332  static_cast<U8>(sizeof(U32))
1333  );
1334  FW_ASSERT(
1335  _status == Fw::FW_SERIALIZE_OK,
1336  static_cast<FwAssertArgType>(_status)
1337  );
1338 #endif
1339  _status = _logBuff.serializeFrom(minSize);
1340  FW_ASSERT(
1341  _status == Fw::FW_SERIALIZE_OK,
1342  static_cast<FwAssertArgType>(_status)
1343  );
1344 
1345  this->eventOut_out(
1346  0,
1347  _id,
1348  _logTime,
1350  _logBuff
1351  );
1352  }
1353 
1354  // Emit the event on the text log port
1355 #if FW_ENABLE_TEXT_LOGGING
1356  if (this->isConnected_textEventOut_OutputPort(0)) {
1357 #if FW_OBJECT_NAMES == 1
1358  const char* _formatString =
1359  "(%s) %s: Received buffer has size %" PRIu64 "; minimum required size is %" PRIu32 "";
1360 #else
1361  const char* _formatString =
1362  "%s: Received buffer has size %" PRIu64 "; minimum required size is %" PRIu32 "";
1363 #endif
1364 
1365  Fw::TextLogString _logString;
1366  _logString.format(
1367  _formatString,
1368 #if FW_OBJECT_NAMES == 1
1369  this->m_objName.toChar(),
1370 #endif
1371  "BufferTooSmallForPacket ",
1372  bufferSize,
1373  minSize
1374  );
1375 
1376  this->textEventOut_out(
1377  0,
1378  _id,
1379  _logTime,
1381  _logString
1382  );
1383  }
1384 #endif
1385  }
1386 
1389  FwSizeType bufferSize,
1390  U32 storedHash,
1391  U32 computedHash
1392  )
1393  {
1394  // Check throttle value
1395  if (this->m_InvalidHeaderHashThrottle >= EVENTID_INVALIDHEADERHASH_THROTTLE) {
1396  return;
1397  }
1398  else {
1399  this->m_InvalidHeaderHashThrottle++;
1400  }
1401 
1402  // Get the time
1403  Fw::Time _logTime;
1404  if (this->isConnected_timeGetOut_OutputPort(0)) {
1405  this->timeGetOut_out(0, _logTime);
1406  }
1407 
1408  const FwEventIdType _id = this->getIdBase() + EVENTID_INVALIDHEADERHASH;
1409 
1410  // Emit the event on the log port
1411  if (this->isConnected_eventOut_OutputPort(0)) {
1412  Fw::LogBuffer _logBuff;
1414 
1415 #if FW_AMPCS_COMPATIBLE
1416  // Serialize the number of arguments
1417  _status = _logBuff.serializeFrom(static_cast<U8>(3));
1418  FW_ASSERT(
1419  _status == Fw::FW_SERIALIZE_OK,
1420  static_cast<FwAssertArgType>(_status)
1421  );
1422 #endif
1423 
1424 #if FW_AMPCS_COMPATIBLE
1425  // Serialize the argument size
1426  _status = _logBuff.serializeFrom(
1427  static_cast<U8>(sizeof(FwSizeType))
1428  );
1429  FW_ASSERT(
1430  _status == Fw::FW_SERIALIZE_OK,
1431  static_cast<FwAssertArgType>(_status)
1432  );
1433 #endif
1434  _status = _logBuff.serializeFrom(bufferSize);
1435  FW_ASSERT(
1436  _status == Fw::FW_SERIALIZE_OK,
1437  static_cast<FwAssertArgType>(_status)
1438  );
1439 
1440 #if FW_AMPCS_COMPATIBLE
1441  // Serialize the argument size
1442  _status = _logBuff.serializeFrom(
1443  static_cast<U8>(sizeof(U32))
1444  );
1445  FW_ASSERT(
1446  _status == Fw::FW_SERIALIZE_OK,
1447  static_cast<FwAssertArgType>(_status)
1448  );
1449 #endif
1450  _status = _logBuff.serializeFrom(storedHash);
1451  FW_ASSERT(
1452  _status == Fw::FW_SERIALIZE_OK,
1453  static_cast<FwAssertArgType>(_status)
1454  );
1455 
1456 #if FW_AMPCS_COMPATIBLE
1457  // Serialize the argument size
1458  _status = _logBuff.serializeFrom(
1459  static_cast<U8>(sizeof(U32))
1460  );
1461  FW_ASSERT(
1462  _status == Fw::FW_SERIALIZE_OK,
1463  static_cast<FwAssertArgType>(_status)
1464  );
1465 #endif
1466  _status = _logBuff.serializeFrom(computedHash);
1467  FW_ASSERT(
1468  _status == Fw::FW_SERIALIZE_OK,
1469  static_cast<FwAssertArgType>(_status)
1470  );
1471 
1472  this->eventOut_out(
1473  0,
1474  _id,
1475  _logTime,
1477  _logBuff
1478  );
1479  }
1480 
1481  // Emit the event on the text log port
1482 #if FW_ENABLE_TEXT_LOGGING
1483  if (this->isConnected_textEventOut_OutputPort(0)) {
1484 #if FW_OBJECT_NAMES == 1
1485  const char* _formatString =
1486  "(%s) %s: Received a buffer of size %" PRIu64 " with an invalid header hash (stored %" PRIx32 ", computed %" PRIx32 ")";
1487 #else
1488  const char* _formatString =
1489  "%s: Received a buffer of size %" PRIu64 " with an invalid header hash (stored %" PRIx32 ", computed %" PRIx32 ")";
1490 #endif
1491 
1492  Fw::TextLogString _logString;
1493  _logString.format(
1494  _formatString,
1495 #if FW_OBJECT_NAMES == 1
1496  this->m_objName.toChar(),
1497 #endif
1498  "InvalidHeaderHash ",
1499  bufferSize,
1500  storedHash,
1501  computedHash
1502  );
1503 
1504  this->textEventOut_out(
1505  0,
1506  _id,
1507  _logTime,
1509  _logString
1510  );
1511  }
1512 #endif
1513  }
1514 
1517  FwSizeType bufferSize,
1518  U32 errorCode
1519  )
1520  {
1521  // Check throttle value
1522  if (this->m_InvalidHeaderThrottle >= EVENTID_INVALIDHEADER_THROTTLE) {
1523  return;
1524  }
1525  else {
1526  this->m_InvalidHeaderThrottle++;
1527  }
1528 
1529  // Get the time
1530  Fw::Time _logTime;
1531  if (this->isConnected_timeGetOut_OutputPort(0)) {
1532  this->timeGetOut_out(0, _logTime);
1533  }
1534 
1535  const FwEventIdType _id = this->getIdBase() + EVENTID_INVALIDHEADER;
1536 
1537  // Emit the event on the log port
1538  if (this->isConnected_eventOut_OutputPort(0)) {
1539  Fw::LogBuffer _logBuff;
1541 
1542 #if FW_AMPCS_COMPATIBLE
1543  // Serialize the number of arguments
1544  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1545  FW_ASSERT(
1546  _status == Fw::FW_SERIALIZE_OK,
1547  static_cast<FwAssertArgType>(_status)
1548  );
1549 #endif
1550 
1551 #if FW_AMPCS_COMPATIBLE
1552  // Serialize the argument size
1553  _status = _logBuff.serializeFrom(
1554  static_cast<U8>(sizeof(FwSizeType))
1555  );
1556  FW_ASSERT(
1557  _status == Fw::FW_SERIALIZE_OK,
1558  static_cast<FwAssertArgType>(_status)
1559  );
1560 #endif
1561  _status = _logBuff.serializeFrom(bufferSize);
1562  FW_ASSERT(
1563  _status == Fw::FW_SERIALIZE_OK,
1564  static_cast<FwAssertArgType>(_status)
1565  );
1566 
1567 #if FW_AMPCS_COMPATIBLE
1568  // Serialize the argument size
1569  _status = _logBuff.serializeFrom(
1570  static_cast<U8>(sizeof(U32))
1571  );
1572  FW_ASSERT(
1573  _status == Fw::FW_SERIALIZE_OK,
1574  static_cast<FwAssertArgType>(_status)
1575  );
1576 #endif
1577  _status = _logBuff.serializeFrom(errorCode);
1578  FW_ASSERT(
1579  _status == Fw::FW_SERIALIZE_OK,
1580  static_cast<FwAssertArgType>(_status)
1581  );
1582 
1583  this->eventOut_out(
1584  0,
1585  _id,
1586  _logTime,
1588  _logBuff
1589  );
1590  }
1591 
1592  // Emit the event on the text log port
1593 #if FW_ENABLE_TEXT_LOGGING
1594  if (this->isConnected_textEventOut_OutputPort(0)) {
1595 #if FW_OBJECT_NAMES == 1
1596  const char* _formatString =
1597  "(%s) %s: Received buffer of size %" PRIu64 "; deserialization of packet header failed with error code %" PRIu32 "";
1598 #else
1599  const char* _formatString =
1600  "%s: Received buffer of size %" PRIu64 "; deserialization of packet header failed with error code %" PRIu32 "";
1601 #endif
1602 
1603  Fw::TextLogString _logString;
1604  _logString.format(
1605  _formatString,
1606 #if FW_OBJECT_NAMES == 1
1607  this->m_objName.toChar(),
1608 #endif
1609  "InvalidHeader ",
1610  bufferSize,
1611  errorCode
1612  );
1613 
1614  this->textEventOut_out(
1615  0,
1616  _id,
1617  _logTime,
1619  _logString
1620  );
1621  }
1622 #endif
1623  }
1624 
1627  FwSizeType bufferSize,
1628  U32 minSize
1629  )
1630  {
1631  // Check throttle value
1632  if (this->m_BufferTooSmallForDataThrottle >= EVENTID_BUFFERTOOSMALLFORDATA_THROTTLE) {
1633  return;
1634  }
1635  else {
1636  this->m_BufferTooSmallForDataThrottle++;
1637  }
1638 
1639  // Get the time
1640  Fw::Time _logTime;
1641  if (this->isConnected_timeGetOut_OutputPort(0)) {
1642  this->timeGetOut_out(0, _logTime);
1643  }
1644 
1646 
1647  // Emit the event on the log port
1648  if (this->isConnected_eventOut_OutputPort(0)) {
1649  Fw::LogBuffer _logBuff;
1651 
1652 #if FW_AMPCS_COMPATIBLE
1653  // Serialize the number of arguments
1654  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1655  FW_ASSERT(
1656  _status == Fw::FW_SERIALIZE_OK,
1657  static_cast<FwAssertArgType>(_status)
1658  );
1659 #endif
1660 
1661 #if FW_AMPCS_COMPATIBLE
1662  // Serialize the argument size
1663  _status = _logBuff.serializeFrom(
1664  static_cast<U8>(sizeof(FwSizeType))
1665  );
1666  FW_ASSERT(
1667  _status == Fw::FW_SERIALIZE_OK,
1668  static_cast<FwAssertArgType>(_status)
1669  );
1670 #endif
1671  _status = _logBuff.serializeFrom(bufferSize);
1672  FW_ASSERT(
1673  _status == Fw::FW_SERIALIZE_OK,
1674  static_cast<FwAssertArgType>(_status)
1675  );
1676 
1677 #if FW_AMPCS_COMPATIBLE
1678  // Serialize the argument size
1679  _status = _logBuff.serializeFrom(
1680  static_cast<U8>(sizeof(U32))
1681  );
1682  FW_ASSERT(
1683  _status == Fw::FW_SERIALIZE_OK,
1684  static_cast<FwAssertArgType>(_status)
1685  );
1686 #endif
1687  _status = _logBuff.serializeFrom(minSize);
1688  FW_ASSERT(
1689  _status == Fw::FW_SERIALIZE_OK,
1690  static_cast<FwAssertArgType>(_status)
1691  );
1692 
1693  this->eventOut_out(
1694  0,
1695  _id,
1696  _logTime,
1698  _logBuff
1699  );
1700  }
1701 
1702  // Emit the event on the text log port
1703 #if FW_ENABLE_TEXT_LOGGING
1704  if (this->isConnected_textEventOut_OutputPort(0)) {
1705 #if FW_OBJECT_NAMES == 1
1706  const char* _formatString =
1707  "(%s) %s: Received buffer has size %" PRIu64 "; minimum required size is %" PRIu32 "";
1708 #else
1709  const char* _formatString =
1710  "%s: Received buffer has size %" PRIu64 "; minimum required size is %" PRIu32 "";
1711 #endif
1712 
1713  Fw::TextLogString _logString;
1714  _logString.format(
1715  _formatString,
1716 #if FW_OBJECT_NAMES == 1
1717  this->m_objName.toChar(),
1718 #endif
1719  "BufferTooSmallForData ",
1720  bufferSize,
1721  minSize
1722  );
1723 
1724  this->textEventOut_out(
1725  0,
1726  _id,
1727  _logTime,
1729  _logString
1730  );
1731  }
1732 #endif
1733  }
1734 
1737  U32 status,
1738  const Fw::StringBase& file
1739  )
1740  {
1741  // Check throttle value
1742  if (this->m_FileOpenErrorThrottle >= EVENTID_FILEOPENERROR_THROTTLE) {
1743  return;
1744  }
1745  else {
1746  this->m_FileOpenErrorThrottle++;
1747  }
1748 
1749  // Get the time
1750  Fw::Time _logTime;
1751  if (this->isConnected_timeGetOut_OutputPort(0)) {
1752  this->timeGetOut_out(0, _logTime);
1753  }
1754 
1755  const FwEventIdType _id = this->getIdBase() + EVENTID_FILEOPENERROR;
1756 
1757  // Emit the event on the log port
1758  if (this->isConnected_eventOut_OutputPort(0)) {
1759  Fw::LogBuffer _logBuff;
1761 
1762 #if FW_AMPCS_COMPATIBLE
1763  // Serialize the number of arguments
1764  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1765  FW_ASSERT(
1766  _status == Fw::FW_SERIALIZE_OK,
1767  static_cast<FwAssertArgType>(_status)
1768  );
1769 #endif
1770 
1771 #if FW_AMPCS_COMPATIBLE
1772  // Serialize the argument size
1773  _status = _logBuff.serializeFrom(
1774  static_cast<U8>(sizeof(U32))
1775  );
1776  FW_ASSERT(
1777  _status == Fw::FW_SERIALIZE_OK,
1778  static_cast<FwAssertArgType>(_status)
1779  );
1780 #endif
1781  _status = _logBuff.serializeFrom(status);
1782  FW_ASSERT(
1783  _status == Fw::FW_SERIALIZE_OK,
1784  static_cast<FwAssertArgType>(_status)
1785  );
1786 
1787  _status = file.serializeTo(
1788  _logBuff,
1789  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1790  );
1791  FW_ASSERT(
1792  _status == Fw::FW_SERIALIZE_OK,
1793  static_cast<FwAssertArgType>(_status)
1794  );
1795 
1796  this->eventOut_out(
1797  0,
1798  _id,
1799  _logTime,
1801  _logBuff
1802  );
1803  }
1804 
1805  // Emit the event on the text log port
1806 #if FW_ENABLE_TEXT_LOGGING
1807  if (this->isConnected_textEventOut_OutputPort(0)) {
1808 #if FW_OBJECT_NAMES == 1
1809  const char* _formatString =
1810  "(%s) %s: Error %" PRIu32 " opening file %s";
1811 #else
1812  const char* _formatString =
1813  "%s: Error %" PRIu32 " opening file %s";
1814 #endif
1815 
1816  Fw::TextLogString _logString;
1817  _logString.format(
1818  _formatString,
1819 #if FW_OBJECT_NAMES == 1
1820  this->m_objName.toChar(),
1821 #endif
1822  "FileOpenError ",
1823  status,
1824  file.toChar()
1825  );
1826 
1827  this->textEventOut_out(
1828  0,
1829  _id,
1830  _logTime,
1832  _logString
1833  );
1834  }
1835 #endif
1836  }
1837 
1840  U32 status,
1841  U32 bytesWritten,
1842  U32 bytesToWrite,
1843  const Fw::StringBase& file
1844  )
1845  {
1846  // Check throttle value
1847  if (this->m_FileWriteErrorThrottle >= EVENTID_FILEWRITEERROR_THROTTLE) {
1848  return;
1849  }
1850  else {
1851  this->m_FileWriteErrorThrottle++;
1852  }
1853 
1854  // Get the time
1855  Fw::Time _logTime;
1856  if (this->isConnected_timeGetOut_OutputPort(0)) {
1857  this->timeGetOut_out(0, _logTime);
1858  }
1859 
1860  const FwEventIdType _id = this->getIdBase() + EVENTID_FILEWRITEERROR;
1861 
1862  // Emit the event on the log port
1863  if (this->isConnected_eventOut_OutputPort(0)) {
1864  Fw::LogBuffer _logBuff;
1866 
1867 #if FW_AMPCS_COMPATIBLE
1868  // Serialize the number of arguments
1869  _status = _logBuff.serializeFrom(static_cast<U8>(4));
1870  FW_ASSERT(
1871  _status == Fw::FW_SERIALIZE_OK,
1872  static_cast<FwAssertArgType>(_status)
1873  );
1874 #endif
1875 
1876 #if FW_AMPCS_COMPATIBLE
1877  // Serialize the argument size
1878  _status = _logBuff.serializeFrom(
1879  static_cast<U8>(sizeof(U32))
1880  );
1881  FW_ASSERT(
1882  _status == Fw::FW_SERIALIZE_OK,
1883  static_cast<FwAssertArgType>(_status)
1884  );
1885 #endif
1886  _status = _logBuff.serializeFrom(status);
1887  FW_ASSERT(
1888  _status == Fw::FW_SERIALIZE_OK,
1889  static_cast<FwAssertArgType>(_status)
1890  );
1891 
1892 #if FW_AMPCS_COMPATIBLE
1893  // Serialize the argument size
1894  _status = _logBuff.serializeFrom(
1895  static_cast<U8>(sizeof(U32))
1896  );
1897  FW_ASSERT(
1898  _status == Fw::FW_SERIALIZE_OK,
1899  static_cast<FwAssertArgType>(_status)
1900  );
1901 #endif
1902  _status = _logBuff.serializeFrom(bytesWritten);
1903  FW_ASSERT(
1904  _status == Fw::FW_SERIALIZE_OK,
1905  static_cast<FwAssertArgType>(_status)
1906  );
1907 
1908 #if FW_AMPCS_COMPATIBLE
1909  // Serialize the argument size
1910  _status = _logBuff.serializeFrom(
1911  static_cast<U8>(sizeof(U32))
1912  );
1913  FW_ASSERT(
1914  _status == Fw::FW_SERIALIZE_OK,
1915  static_cast<FwAssertArgType>(_status)
1916  );
1917 #endif
1918  _status = _logBuff.serializeFrom(bytesToWrite);
1919  FW_ASSERT(
1920  _status == Fw::FW_SERIALIZE_OK,
1921  static_cast<FwAssertArgType>(_status)
1922  );
1923 
1924  _status = file.serializeTo(
1925  _logBuff,
1926  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1927  );
1928  FW_ASSERT(
1929  _status == Fw::FW_SERIALIZE_OK,
1930  static_cast<FwAssertArgType>(_status)
1931  );
1932 
1933  this->eventOut_out(
1934  0,
1935  _id,
1936  _logTime,
1938  _logBuff
1939  );
1940  }
1941 
1942  // Emit the event on the text log port
1943 #if FW_ENABLE_TEXT_LOGGING
1944  if (this->isConnected_textEventOut_OutputPort(0)) {
1945 #if FW_OBJECT_NAMES == 1
1946  const char* _formatString =
1947  "(%s) %s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1948 #else
1949  const char* _formatString =
1950  "%s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1951 #endif
1952 
1953  Fw::TextLogString _logString;
1954  _logString.format(
1955  _formatString,
1956 #if FW_OBJECT_NAMES == 1
1957  this->m_objName.toChar(),
1958 #endif
1959  "FileWriteError ",
1960  status,
1961  bytesWritten,
1962  bytesToWrite,
1963  file.toChar()
1964  );
1965 
1966  this->textEventOut_out(
1967  0,
1968  _id,
1969  _logTime,
1971  _logString
1972  );
1973  }
1974 #endif
1975  }
1976 
1979  U32 bytes,
1980  const Fw::StringBase& file
1981  ) const
1982  {
1983  // Get the time
1984  Fw::Time _logTime;
1985  if (this->isConnected_timeGetOut_OutputPort(0)) {
1986  this->timeGetOut_out(0, _logTime);
1987  }
1988 
1989  const FwEventIdType _id = this->getIdBase() + EVENTID_FILEWRITTEN;
1990 
1991  // Emit the event on the log port
1992  if (this->isConnected_eventOut_OutputPort(0)) {
1993  Fw::LogBuffer _logBuff;
1995 
1996 #if FW_AMPCS_COMPATIBLE
1997  // Serialize the number of arguments
1998  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1999  FW_ASSERT(
2000  _status == Fw::FW_SERIALIZE_OK,
2001  static_cast<FwAssertArgType>(_status)
2002  );
2003 #endif
2004 
2005 #if FW_AMPCS_COMPATIBLE
2006  // Serialize the argument size
2007  _status = _logBuff.serializeFrom(
2008  static_cast<U8>(sizeof(U32))
2009  );
2010  FW_ASSERT(
2011  _status == Fw::FW_SERIALIZE_OK,
2012  static_cast<FwAssertArgType>(_status)
2013  );
2014 #endif
2015  _status = _logBuff.serializeFrom(bytes);
2016  FW_ASSERT(
2017  _status == Fw::FW_SERIALIZE_OK,
2018  static_cast<FwAssertArgType>(_status)
2019  );
2020 
2021  _status = file.serializeTo(
2022  _logBuff,
2023  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
2024  );
2025  FW_ASSERT(
2026  _status == Fw::FW_SERIALIZE_OK,
2027  static_cast<FwAssertArgType>(_status)
2028  );
2029 
2030  this->eventOut_out(
2031  0,
2032  _id,
2033  _logTime,
2035  _logBuff
2036  );
2037  }
2038 
2039  // Emit the event on the text log port
2040 #if FW_ENABLE_TEXT_LOGGING
2041  if (this->isConnected_textEventOut_OutputPort(0)) {
2042 #if FW_OBJECT_NAMES == 1
2043  const char* _formatString =
2044  "(%s) %s: Wrote %" PRIu32 " bytes to file %s";
2045 #else
2046  const char* _formatString =
2047  "%s: Wrote %" PRIu32 " bytes to file %s";
2048 #endif
2049 
2050  Fw::TextLogString _logString;
2051  _logString.format(
2052  _formatString,
2053 #if FW_OBJECT_NAMES == 1
2054  this->m_objName.toChar(),
2055 #endif
2056  "FileWritten ",
2057  bytes,
2058  file.toChar()
2059  );
2060 
2061  this->textEventOut_out(
2062  0,
2063  _id,
2064  _logTime,
2066  _logString
2067  );
2068  }
2069 #endif
2070  }
2071 
2072  // ----------------------------------------------------------------------
2073  // Event throttle reset functions
2074  // ----------------------------------------------------------------------
2075 
2078  {
2079  // Reset throttle counter
2080  this->m_InvalidBufferThrottle = 0;
2081  }
2082 
2085  {
2086  // Reset throttle counter
2087  this->m_BufferTooSmallForPacketThrottle = 0;
2088  }
2089 
2092  {
2093  // Reset throttle counter
2094  this->m_InvalidHeaderHashThrottle = 0;
2095  }
2096 
2099  {
2100  // Reset throttle counter
2101  this->m_InvalidHeaderThrottle = 0;
2102  }
2103 
2106  {
2107  // Reset throttle counter
2108  this->m_BufferTooSmallForDataThrottle = 0;
2109  }
2110 
2113  {
2114  // Reset throttle counter
2115  this->m_FileOpenErrorThrottle = 0;
2116  }
2117 
2120  {
2121  // Reset throttle counter
2122  this->m_FileWriteErrorThrottle = 0;
2123  }
2124 
2125  // ----------------------------------------------------------------------
2126  // Telemetry serialized write
2127  // ----------------------------------------------------------------------
2128 
2131  FwChanIdType id,
2132  Fw::TlmBuffer& _tlmBuff,
2133  Fw::Time _tlmTime
2134  ) const
2135  {
2136  if (this->isConnected_tlmOut_OutputPort(0)) {
2137  if (
2139  (_tlmTime == Fw::ZERO_TIME)
2140  ) {
2141  this->timeGetOut_out(0, _tlmTime);
2142  }
2143 
2144  FwChanIdType _id;
2145  _id = this->getIdBase() + id;
2146 
2147  this->tlmOut_out(
2148  0,
2149  _id,
2150  _tlmTime,
2151  _tlmBuff
2152  );
2153  }
2154  }
2155 
2156  // ----------------------------------------------------------------------
2157  // Telemetry write functions
2158  // ----------------------------------------------------------------------
2159 
2162  U32 arg,
2163  Fw::Time _tlmTime
2164  )
2165  {
2166  // Check to see if it is the first time
2167  if (not this->m_first_update_NumBuffersReceived) {
2168  // Check to see if value has changed. If not, don't write it.
2169  if (arg == this->m_last_NumBuffersReceived) {
2170  return;
2171  }
2172  else {
2173  this->m_last_NumBuffersReceived = arg;
2174  }
2175  }
2176  else {
2177  this->m_first_update_NumBuffersReceived = false;
2178  this->m_last_NumBuffersReceived = arg;
2179  }
2180 
2181  if (this->isConnected_tlmOut_OutputPort(0)) {
2182  Fw::TlmBuffer _tlmBuff;
2183  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2184  FW_ASSERT(
2185  _stat == Fw::FW_SERIALIZE_OK,
2186  static_cast<FwAssertArgType>(_stat)
2187  );
2188 
2189  this->tlmWrite(
2191  _tlmBuff,
2192  _tlmTime
2193  );
2194  }
2195  }
2196 
2199  U64 arg,
2200  Fw::Time _tlmTime
2201  )
2202  {
2203  // Check to see if it is the first time
2204  if (not this->m_first_update_NumBytesWritten) {
2205  // Check to see if value has changed. If not, don't write it.
2206  if (arg == this->m_last_NumBytesWritten) {
2207  return;
2208  }
2209  else {
2210  this->m_last_NumBytesWritten = arg;
2211  }
2212  }
2213  else {
2214  this->m_first_update_NumBytesWritten = false;
2215  this->m_last_NumBytesWritten = arg;
2216  }
2217 
2218  if (this->isConnected_tlmOut_OutputPort(0)) {
2219  Fw::TlmBuffer _tlmBuff;
2220  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2221  FW_ASSERT(
2222  _stat == Fw::FW_SERIALIZE_OK,
2223  static_cast<FwAssertArgType>(_stat)
2224  );
2225 
2226  this->tlmWrite(
2228  _tlmBuff,
2229  _tlmTime
2230  );
2231  }
2232  }
2233 
2236  U32 arg,
2237  Fw::Time _tlmTime
2238  )
2239  {
2240  // Check to see if it is the first time
2241  if (not this->m_first_update_NumSuccessfulWrites) {
2242  // Check to see if value has changed. If not, don't write it.
2243  if (arg == this->m_last_NumSuccessfulWrites) {
2244  return;
2245  }
2246  else {
2247  this->m_last_NumSuccessfulWrites = arg;
2248  }
2249  }
2250  else {
2251  this->m_first_update_NumSuccessfulWrites = false;
2252  this->m_last_NumSuccessfulWrites = arg;
2253  }
2254 
2255  if (this->isConnected_tlmOut_OutputPort(0)) {
2256  Fw::TlmBuffer _tlmBuff;
2257  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2258  FW_ASSERT(
2259  _stat == Fw::FW_SERIALIZE_OK,
2260  static_cast<FwAssertArgType>(_stat)
2261  );
2262 
2263  this->tlmWrite(
2265  _tlmBuff,
2266  _tlmTime
2267  );
2268  }
2269  }
2270 
2273  U32 arg,
2274  Fw::Time _tlmTime
2275  )
2276  {
2277  // Check to see if it is the first time
2278  if (not this->m_first_update_NumFailedWrites) {
2279  // Check to see if value has changed. If not, don't write it.
2280  if (arg == this->m_last_NumFailedWrites) {
2281  return;
2282  }
2283  else {
2284  this->m_last_NumFailedWrites = arg;
2285  }
2286  }
2287  else {
2288  this->m_first_update_NumFailedWrites = false;
2289  this->m_last_NumFailedWrites = arg;
2290  }
2291 
2292  if (this->isConnected_tlmOut_OutputPort(0)) {
2293  Fw::TlmBuffer _tlmBuff;
2294  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2295  FW_ASSERT(
2296  _stat == Fw::FW_SERIALIZE_OK,
2297  static_cast<FwAssertArgType>(_stat)
2298  );
2299 
2300  this->tlmWrite(
2302  _tlmBuff,
2303  _tlmTime
2304  );
2305  }
2306  }
2307 
2310  U32 arg,
2311  Fw::Time _tlmTime
2312  )
2313  {
2314  // Check to see if it is the first time
2315  if (not this->m_first_update_NumErrors) {
2316  // Check to see if value has changed. If not, don't write it.
2317  if (arg == this->m_last_NumErrors) {
2318  return;
2319  }
2320  else {
2321  this->m_last_NumErrors = arg;
2322  }
2323  }
2324  else {
2325  this->m_first_update_NumErrors = false;
2326  this->m_last_NumErrors = arg;
2327  }
2328 
2329  if (this->isConnected_tlmOut_OutputPort(0)) {
2330  Fw::TlmBuffer _tlmBuff;
2331  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2332  FW_ASSERT(
2333  _stat == Fw::FW_SERIALIZE_OK,
2334  static_cast<FwAssertArgType>(_stat)
2335  );
2336 
2337  this->tlmWrite(
2339  _tlmBuff,
2340  _tlmTime
2341  );
2342  }
2343  }
2344 
2345  // ----------------------------------------------------------------------
2346  // Time
2347  // ----------------------------------------------------------------------
2348 
2350  getTime() const
2351  {
2352  if (this->isConnected_timeGetOut_OutputPort(0)) {
2353  Fw::Time _time;
2354  this->timeGetOut_out(0, _time);
2355  return _time;
2356  }
2357  else {
2358  return Fw::Time(TimeBase::TB_NONE, 0, 0);
2359  }
2360  }
2361 
2362  // ----------------------------------------------------------------------
2363  // Message dispatch functions
2364  // ----------------------------------------------------------------------
2365 
2366  Fw::QueuedComponentBase::MsgDispatchStatus DpWriterComponentBase ::
2367  doDispatch()
2368  {
2369  ComponentIpcSerializableBuffer _msg;
2370  FwQueuePriorityType _priority = 0;
2371 
2372  Os::Queue::Status _msgStatus = this->m_queue.receive(
2373  _msg,
2375  _priority
2376  );
2377  FW_ASSERT(
2378  _msgStatus == Os::Queue::OP_OK,
2379  static_cast<FwAssertArgType>(_msgStatus)
2380  );
2381 
2382  // Reset to beginning of buffer
2383  _msg.resetDeser();
2384 
2385  FwEnumStoreType _desMsg = 0;
2386  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
2387  FW_ASSERT(
2388  _deserStatus == Fw::FW_SERIALIZE_OK,
2389  static_cast<FwAssertArgType>(_deserStatus)
2390  );
2391 
2392  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
2393 
2394  if (_msgType == DPWRITER_COMPONENT_EXIT) {
2395  return MSG_DISPATCH_EXIT;
2396  }
2397 
2398  FwIndexType portNum = 0;
2399  _deserStatus = _msg.deserializeTo(portNum);
2400  FW_ASSERT(
2401  _deserStatus == Fw::FW_SERIALIZE_OK,
2402  static_cast<FwAssertArgType>(_deserStatus)
2403  );
2404 
2405  switch (_msgType) {
2406  // Handle async input port bufferSendIn
2407  case BUFFERSENDIN_BUFFERSEND: {
2408  // Deserialize argument fwBuffer
2409  Fw::Buffer fwBuffer;
2410  _deserStatus = _msg.deserializeTo(fwBuffer);
2411  FW_ASSERT(
2412  _deserStatus == Fw::FW_SERIALIZE_OK,
2413  static_cast<FwAssertArgType>(_deserStatus)
2414  );
2415  // Call handler function
2416  this->bufferSendIn_handler(
2417  portNum,
2418  fwBuffer
2419  );
2420 
2421  break;
2422  }
2423 
2424  // Handle async input port schedIn
2425  case SCHEDIN_SCHED: {
2426  // Deserialize argument context
2427  U32 context;
2428  _deserStatus = _msg.deserializeTo(context);
2429  FW_ASSERT(
2430  _deserStatus == Fw::FW_SERIALIZE_OK,
2431  static_cast<FwAssertArgType>(_deserStatus)
2432  );
2433  // Call handler function
2434  this->schedIn_handler(
2435  portNum,
2436  context
2437  );
2438 
2439  break;
2440  }
2441 
2442  // Handle command CLEAR_EVENT_THROTTLE
2443  case CMD_CLEAR_EVENT_THROTTLE: {
2444  // Deserialize opcode
2445  FwOpcodeType _opCode = 0;
2446  _deserStatus = _msg.deserializeTo(_opCode);
2447  FW_ASSERT (
2448  _deserStatus == Fw::FW_SERIALIZE_OK,
2449  static_cast<FwAssertArgType>(_deserStatus)
2450  );
2451 
2452  // Deserialize command sequence
2453  U32 _cmdSeq = 0;
2454  _deserStatus = _msg.deserializeTo(_cmdSeq);
2455  FW_ASSERT (
2456  _deserStatus == Fw::FW_SERIALIZE_OK,
2457  static_cast<FwAssertArgType>(_deserStatus)
2458  );
2459 
2460  // Deserialize command argument buffer
2461  Fw::CmdArgBuffer args;
2462  _deserStatus = _msg.deserializeTo(args);
2463  FW_ASSERT (
2464  _deserStatus == Fw::FW_SERIALIZE_OK,
2465  static_cast<FwAssertArgType>(_deserStatus)
2466  );
2467 
2468  // Reset buffer
2469  args.resetDeser();
2470 
2471  // Make sure there was no data left over.
2472  // That means the argument buffer size was incorrect.
2473 #if FW_CMD_CHECK_RESIDUAL
2474  if (args.getDeserializeSizeLeft() != 0) {
2476  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2477  }
2478  // Don't crash the task if bad arguments were passed from the ground
2479  break;
2480  }
2481 #endif
2482 
2483  // Call handler function
2484  this->CLEAR_EVENT_THROTTLE_cmdHandler(_opCode, _cmdSeq);
2485 
2486  break;
2487  }
2488 
2489  default:
2490  return MSG_DISPATCH_ERROR;
2491  }
2492 
2493  return MSG_DISPATCH_OK;
2494  }
2495 
2496  // ----------------------------------------------------------------------
2497  // Calls for messages received on special input ports
2498  // ----------------------------------------------------------------------
2499 
2500  void DpWriterComponentBase ::
2501  m_p_cmdIn_in(
2502  Fw::PassiveComponentBase* callComp,
2503  FwIndexType portNum,
2504  FwOpcodeType opCode,
2505  U32 cmdSeq,
2506  Fw::CmdArgBuffer& args
2507  )
2508  {
2509  FW_ASSERT(callComp);
2510  DpWriterComponentBase* compPtr = static_cast<DpWriterComponentBase*>(callComp);
2511  compPtr->cmdIn_handlerBase(
2512  portNum,
2513  opCode,
2514  cmdSeq,
2515  args
2516  );
2517  }
2518 
2519  // ----------------------------------------------------------------------
2520  // Calls for messages received on typed input ports
2521  // ----------------------------------------------------------------------
2522 
2523  void DpWriterComponentBase ::
2524  m_p_bufferSendIn_in(
2525  Fw::PassiveComponentBase* callComp,
2526  FwIndexType portNum,
2527  Fw::Buffer& fwBuffer
2528  )
2529  {
2530  FW_ASSERT(callComp);
2531  DpWriterComponentBase* compPtr = static_cast<DpWriterComponentBase*>(callComp);
2532  compPtr->bufferSendIn_handlerBase(
2533  portNum,
2534  fwBuffer
2535  );
2536  }
2537 
2538  void DpWriterComponentBase ::
2539  m_p_schedIn_in(
2540  Fw::PassiveComponentBase* callComp,
2541  FwIndexType portNum,
2542  U32 context
2543  )
2544  {
2545  FW_ASSERT(callComp);
2546  DpWriterComponentBase* compPtr = static_cast<DpWriterComponentBase*>(callComp);
2547  compPtr->schedIn_handlerBase(
2548  portNum,
2549  context
2550  );
2551  }
2552 
2553 #if !FW_DIRECT_PORT_CALLS
2554 
2555  // ----------------------------------------------------------------------
2556  // Invocation functions for special output ports
2557  // ----------------------------------------------------------------------
2558 
2559  void DpWriterComponentBase ::
2560  cmdRegIn_out(
2561  FwIndexType portNum,
2562  FwOpcodeType opCode
2563  ) const
2564  {
2565  FW_ASSERT(
2566  (0 <= portNum) && (portNum < this->getNum_cmdRegIn_OutputPorts()),
2567  static_cast<FwAssertArgType>(portNum)
2568  );
2569 
2570  FW_ASSERT(
2571  this->m_cmdRegIn_OutputPort[portNum].isConnected(),
2572  static_cast<FwAssertArgType>(portNum)
2573  );
2574  this->m_cmdRegIn_OutputPort[portNum].invoke(
2575  opCode
2576  );
2577  }
2578 
2579  void DpWriterComponentBase ::
2580  cmdResponseOut_out(
2581  FwIndexType portNum,
2582  FwOpcodeType opCode,
2583  U32 cmdSeq,
2584  const Fw::CmdResponse& response
2585  ) const
2586  {
2587  FW_ASSERT(
2588  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
2589  static_cast<FwAssertArgType>(portNum)
2590  );
2591 
2592  FW_ASSERT(
2593  this->m_cmdResponseOut_OutputPort[portNum].isConnected(),
2594  static_cast<FwAssertArgType>(portNum)
2595  );
2596  this->m_cmdResponseOut_OutputPort[portNum].invoke(
2597  opCode,
2598  cmdSeq,
2599  response
2600  );
2601  }
2602 
2603  void DpWriterComponentBase ::
2604  eventOut_out(
2605  FwIndexType portNum,
2606  FwEventIdType id,
2607  Fw::Time& timeTag,
2608  const Fw::LogSeverity& severity,
2609  Fw::LogBuffer& args
2610  ) const
2611  {
2612  FW_ASSERT(
2613  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
2614  static_cast<FwAssertArgType>(portNum)
2615  );
2616 
2617  FW_ASSERT(
2618  this->m_eventOut_OutputPort[portNum].isConnected(),
2619  static_cast<FwAssertArgType>(portNum)
2620  );
2621  this->m_eventOut_OutputPort[portNum].invoke(
2622  id,
2623  timeTag,
2624  severity,
2625  args
2626  );
2627  }
2628 
2629 #if FW_ENABLE_TEXT_LOGGING
2630 
2631  void DpWriterComponentBase ::
2632  textEventOut_out(
2633  FwIndexType portNum,
2634  FwEventIdType id,
2635  Fw::Time& timeTag,
2636  const Fw::LogSeverity& severity,
2637  Fw::TextLogString& text
2638  ) const
2639  {
2640  FW_ASSERT(
2641  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
2642  static_cast<FwAssertArgType>(portNum)
2643  );
2644 
2645  FW_ASSERT(
2646  this->m_textEventOut_OutputPort[portNum].isConnected(),
2647  static_cast<FwAssertArgType>(portNum)
2648  );
2649  this->m_textEventOut_OutputPort[portNum].invoke(
2650  id,
2651  timeTag,
2652  severity,
2653  text
2654  );
2655  }
2656 
2657 #endif
2658 
2659  void DpWriterComponentBase ::
2660  timeGetOut_out(
2661  FwIndexType portNum,
2662  Fw::Time& time
2663  ) const
2664  {
2665  FW_ASSERT(
2666  (0 <= portNum) && (portNum < this->getNum_timeGetOut_OutputPorts()),
2667  static_cast<FwAssertArgType>(portNum)
2668  );
2669 
2670  FW_ASSERT(
2671  this->m_timeGetOut_OutputPort[portNum].isConnected(),
2672  static_cast<FwAssertArgType>(portNum)
2673  );
2674  this->m_timeGetOut_OutputPort[portNum].invoke(
2675  time
2676  );
2677  }
2678 
2679  void DpWriterComponentBase ::
2680  tlmOut_out(
2681  FwIndexType portNum,
2682  FwChanIdType id,
2683  Fw::Time& timeTag,
2684  Fw::TlmBuffer& val
2685  ) const
2686  {
2687  FW_ASSERT(
2688  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
2689  static_cast<FwAssertArgType>(portNum)
2690  );
2691 
2692  FW_ASSERT(
2693  this->m_tlmOut_OutputPort[portNum].isConnected(),
2694  static_cast<FwAssertArgType>(portNum)
2695  );
2696  this->m_tlmOut_OutputPort[portNum].invoke(
2697  id,
2698  timeTag,
2699  val
2700  );
2701  }
2702 
2703 #endif
2704 
2705 }
Serialization/Deserialization operation was successful.
static constexpr FwIndexType getNum_bufferSendIn_InputPorts()
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
virtual ~DpWriterComponentBase()
Destroy DpWriterComponentBase object.
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum) const
static constexpr FwSizeType CAPACITY
Definition: CmdPortAc.hpp:36
FwIdType FwOpcodeType
The type of a command opcode.
void log_WARNING_HI_BufferTooSmallForData(FwSizeType bufferSize, U32 minSize)
Operation succeeded.
Definition: Os.hpp:27
void invoke(const Fw::StringBase &fileName, FwDpPriorityType priority, FwSizeType size) const
Invoke a port connection.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
void schedIn_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port schedIn.
virtual void CLEAR_EVENT_THROTTLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
PlatformSizeType FwSizeType
static constexpr FwIndexType getNum_cmdResponseOut_OutputPorts()
bool isConnected_cmdRegIn_OutputPort(FwIndexType portNum) const
U32 FwDpPriorityType
The type of a data product priority.
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
Definition: Queue.cpp:71
void addCallPort(InputDpWrittenPort *callPort)
Register an input port.
I32 FwEnumStoreType
static constexpr FwIndexType getNum_eventOut_OutputPorts()
Status
status returned from the queue send function
Definition: Queue.hpp:30
void init()
Initialization function.
Definition: SchedPortAc.cpp:73
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void set_dpWrittenOut_OutputPort(FwIndexType portNum, Svc::InputDpWrittenPort *port)
Connect port to dpWrittenOut[portNum].
An error occurred when writing to a file.
void init()
Initialization function.
Definition: CmdPortAc.cpp:89
static constexpr FwSizeType CAPACITY
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
virtual const CHAR * toChar() const =0
Convert to a C-style char*.
const Time ZERO_TIME
Definition: Time.cpp:5
bool isConnected_timeGetOut_OutputPort(FwIndexType portNum) const
void init()
Initialization function.
Definition: TlmPortAc.cpp:171
Enum representing a command response.
virtual void bufferSendIn_preMsgHook(FwIndexType portNum, Fw::Buffer &fwBuffer)
Pre-message hook for async input port bufferSendIn.
static constexpr FwIndexType getNum_schedIn_InputPorts()
No time base has been established (Required)
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
static constexpr FwIndexType getNum_timeGetOut_OutputPorts()
void cmdIn_handlerBase(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Handler base-class function for input port cmdIn.
static constexpr FwIndexType getNum_deallocBufferSendOut_OutputPorts()
Os::Queue m_queue
queue object for active component
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:177
void tlmWrite_NumErrors(U32 arg, Fw::Time _tlmTime=Fw::Time())
void init()
Object initializer.
Definition: ObjBase.cpp:24
bool isConnected_dpWrittenOut_OutputPort(FwIndexType portNum) const
SerializeStatus
forward declaration for string
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CmdPortAc.cpp:95
Fw::InputBufferSendPort * get_bufferSendIn_InputPort(FwIndexType portNum)
Message will block until space is available.
Definition: Queue.hpp:47
bool isConnected_deallocBufferSendOut_OutputPort(FwIndexType portNum) const
void deallocBufferSendOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port deallocBufferSendOut.
void log_WARNING_HI_InvalidBuffer_ThrottleClear()
Reset throttle value for InvalidBuffer.
FwIdType FwEventIdType
The type of an event identifier.
void tlmWrite_NumFailedWrites(U32 arg, Fw::Time _tlmTime=Fw::Time())
void log_WARNING_HI_FileWriteError_ThrottleClear()
Reset throttle value for FileWriteError.
void invoke(FwOpcodeType opCode) const
Invoke a port connection.
An error occurred when opening a file.
void CLEAR_EVENT_THROTTLE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:40
void init()
Initialization function.
Definition: TimePortAc.cpp:151
void tlmWrite(FwChanIdType id, Fw::TlmBuffer &_tlmBuff, Fw::Time _tlmTime=Fw::Time()) const
Less important informational events.
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
#define FW_MIN(a, b)
MIN macro (deprecated in C++, use std::min)
Definition: BasicTypes.h:99
void invoke(Fw::Buffer &fwBuffer) const
Invoke a port connection.
void init()
Initialization function.
void addCallPort(InputBufferSendPort *callPort)
Register an input port.
void dpWrittenOut_out(FwIndexType portNum, const Fw::StringBase &fileName, FwDpPriorityType priority, FwSizeType size) const
Invoke output port dpWrittenOut.
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
Fw::InputCmdPort * get_cmdIn_InputPort(FwIndexType portNum)
void log_WARNING_HI_InvalidHeaderHash(FwSizeType bufferSize, U32 storedHash, U32 computedHash)
Serializable::SizeType getDeserializeSizeLeft() const override
Get remaining deserialization buffer size.
void set_deallocBufferSendOut_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to deallocBufferSendOut[portNum].
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke a port connection.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
FwSizeType SizeType
void tlmWrite_NumBuffersReceived(U32 arg, Fw::Time _tlmTime=Fw::Time())
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
Definition: Queue.cpp:54
static constexpr FwIndexType getNum_procBufferSendOut_OutputPorts()
void procBufferSendOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port procBufferSendOut.
void resetDeser() override
Reset deserialization pointer to beginning of buffer.
void log_WARNING_HI_BufferTooSmallForData_ThrottleClear()
Reset throttle value for BufferTooSmallForData.
void log_WARNING_HI_FileOpenError_ThrottleClear()
Reset throttle value for FileOpenError.
The received buffer has an invalid header hash.
static constexpr FwIndexType getNum_tlmOut_OutputPorts()
A serious but recoverable event.
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke a port connection.
Definition: TlmPortAc.cpp:190
DpWriterComponentBase(const char *compName="")
Construct DpWriterComponentBase object.
const char * toChar() const
Convert to a C-style char*.
bool isConnected() const
Definition: PortBase.cpp:38
void log_WARNING_HI_FileOpenError(U32 status, const Fw::StringBase &file)
void log_WARNING_HI_InvalidHeader_ThrottleClear()
Reset throttle value for InvalidHeader.
Enum representing event severity.
#define PRI_FwIndexType
void log_WARNING_HI_InvalidHeaderHash_ThrottleClear()
Reset throttle value for InvalidHeaderHash.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
void init()
Initialization function.
Definition: LogPortAc.cpp:180
bool isConnected_procBufferSendOut_OutputPort(FwIndexType portNum) const
void setPortNum(FwIndexType portNum)
Received buffer is too small to hold the data specified in the header.
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
void log_WARNING_HI_BufferTooSmallForPacket(FwSizeType bufferSize, U32 minSize)
BlockingType
message type
Definition: Queue.hpp:46
void regCommands()
Register commands with the Command Dispatcher.
Error occurred when deserializing the packet header.
Command failed to deserialize.
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
void init()
Initialization function.
void set_tlmOut_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to tlmOut[portNum].
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: SchedPortAc.cpp:79
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port connection.
Definition: LogPortAc.cpp:199
bool isConnected_eventOut_OutputPort(FwIndexType portNum) const
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
void log_ACTIVITY_LO_FileWritten(U32 bytes, const Fw::StringBase &file) const
static constexpr FwIndexType getNum_cmdRegIn_OutputPorts()
A message was sent requesting an exit of the loop.
virtual void CLEAR_EVENT_THROTTLE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command CLEAR_EVENT_THROTTLE.
virtual void schedIn_handler(FwIndexType portNum, U32 context)=0
Handler for input port schedIn.
PlatformIndexType FwIndexType
static constexpr FwIndexType getNum_dpWrittenOut_OutputPorts()
void set_eventOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
bool isConnected_tlmOut_OutputPort(FwIndexType portNum) const
message to exit active component task
virtual void bufferSendIn_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port bufferSendIn.
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:186
void log_WARNING_HI_FileWriteError(U32 status, U32 bytesWritten, U32 bytesToWrite, const Fw::StringBase &file)
void init()
Initialization function.
void set_timeGetOut_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeGetOut[portNum].
RateGroupDivider component implementation.
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:57
void bufferSendIn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferSendIn.
void tlmWrite_NumBytesWritten(U64 arg, Fw::Time _tlmTime=Fw::Time())
virtual void schedIn_preMsgHook(FwIndexType portNum, U32 context)
Pre-message hook for async input port schedIn.
void log_WARNING_HI_InvalidHeader(FwSizeType bufferSize, U32 errorCode)
void tlmWrite_NumSuccessfulWrites(U32 arg, Fw::Time _tlmTime=Fw::Time())
void log_WARNING_HI_BufferTooSmallForPacket_ThrottleClear()
Reset throttle value for BufferTooSmallForPacket.
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
Implementation of malloc based allocator.
void set_procBufferSendOut_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to procBufferSendOut[portNum].
void init()
Initialization function.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void init()
Initialization function.
Svc::InputSchedPort * get_schedIn_InputPort(FwIndexType portNum)
Received buffer is too small to hold a data product packet.
static constexpr FwSizeType CAPACITY
Definition: SchedPortAc.hpp:34
void set_cmdRegIn_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegIn[portNum].
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
static constexpr FwIndexType getNum_cmdIn_InputPorts()
SerializeStatus serializeTo(SerialBufferBase &buffer, Endianness mode=Endianness::BIG) const override
Serialize the contents of this object to a buffer.
#define U64(C)
Definition: sha.h:181