F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
BufferLoggerComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title BufferLoggerComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for BufferLogger component base class
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
10 #if FW_ENABLE_TEXT_LOGGING
11 #include "Fw/Types/String.hpp"
12 #endif
13 
14 namespace Svc {
15 
16  namespace {
17  enum MsgTypeEnum {
18  BUFFERLOGGER_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  BUFFERSENDIN_BUFFERSEND,
20  COMIN_COM,
21  PINGIN_PING,
22  SCHEDIN_SCHED,
23  CMD_BL_OPENFILE,
24  CMD_BL_CLOSEFILE,
25  CMD_BL_SETLOGGING,
26  CMD_BL_FLUSHFILE,
27  };
28 
29  // Get the max size by constructing a union of the async input, command, and
30  // internal port serialization sizes
31  union BuffUnion {
32  BYTE bufferSendInPortSize[Fw::InputBufferSendPort::SERIALIZED_SIZE];
37  };
38 
39  // Define a message buffer class large enough to handle all the
40  // asynchronous inputs to the component
41  class ComponentIpcSerializableBuffer :
43  {
44 
45  public:
46 
47  enum {
48  // Offset into data in buffer: Size of message ID and port number
49  DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
50  // Max data size
51  MAX_DATA_SIZE = sizeof(BuffUnion),
52  // Max message size: Size of message id + size of port + max data size
53  SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
54  };
55 
56  Fw::Serializable::SizeType getBuffCapacity() const {
57  return sizeof(m_buff);
58  }
59 
60  U8* getBuffAddr() {
61  return m_buff;
62  }
63 
64  const U8* getBuffAddr() const {
65  return m_buff;
66  }
67 
68  private:
69  // Should be the max of all the input ports serialized sizes...
70  U8 m_buff[SERIALIZATION_SIZE];
71 
72  };
73  }
74 
75  // ----------------------------------------------------------------------
76  // Component initialization
77  // ----------------------------------------------------------------------
78 
81  FwSizeType queueDepth,
82  FwEnumStoreType instance
83  )
84  {
85  // Initialize base class
87 
88  // Connect input port cmdIn
89  for (
90  FwIndexType port = 0;
91  port < static_cast<FwIndexType>(this->getNum_cmdIn_InputPorts());
92  port++
93  ) {
94  this->m_cmdIn_InputPort[port].init();
95  this->m_cmdIn_InputPort[port].addCallComp(
96  this,
97  m_p_cmdIn_in
98  );
99  this->m_cmdIn_InputPort[port].setPortNum(port);
100 
101 #if FW_OBJECT_NAMES == 1
102  Fw::ObjectName portName;
103  portName.format(
104  "%s_cmdIn_InputPort[%" PRI_PlatformIntType "]",
105  this->m_objName.toChar(),
106  port
107  );
108  this->m_cmdIn_InputPort[port].setObjName(portName.toChar());
109 #endif
110  }
111 
112  // Connect input port bufferSendIn
113  for (
114  FwIndexType port = 0;
115  port < static_cast<FwIndexType>(this->getNum_bufferSendIn_InputPorts());
116  port++
117  ) {
118  this->m_bufferSendIn_InputPort[port].init();
119  this->m_bufferSendIn_InputPort[port].addCallComp(
120  this,
121  m_p_bufferSendIn_in
122  );
123  this->m_bufferSendIn_InputPort[port].setPortNum(port);
124 
125 #if FW_OBJECT_NAMES == 1
126  Fw::ObjectName portName;
127  portName.format(
128  "%s_bufferSendIn_InputPort[%" PRI_PlatformIntType "]",
129  this->m_objName.toChar(),
130  port
131  );
132  this->m_bufferSendIn_InputPort[port].setObjName(portName.toChar());
133 #endif
134  }
135 
136  // Connect input port comIn
137  for (
138  FwIndexType port = 0;
139  port < static_cast<FwIndexType>(this->getNum_comIn_InputPorts());
140  port++
141  ) {
142  this->m_comIn_InputPort[port].init();
143  this->m_comIn_InputPort[port].addCallComp(
144  this,
145  m_p_comIn_in
146  );
147  this->m_comIn_InputPort[port].setPortNum(port);
148 
149 #if FW_OBJECT_NAMES == 1
150  Fw::ObjectName portName;
151  portName.format(
152  "%s_comIn_InputPort[%" PRI_PlatformIntType "]",
153  this->m_objName.toChar(),
154  port
155  );
156  this->m_comIn_InputPort[port].setObjName(portName.toChar());
157 #endif
158  }
159 
160  // Connect input port pingIn
161  for (
162  FwIndexType port = 0;
163  port < static_cast<FwIndexType>(this->getNum_pingIn_InputPorts());
164  port++
165  ) {
166  this->m_pingIn_InputPort[port].init();
167  this->m_pingIn_InputPort[port].addCallComp(
168  this,
169  m_p_pingIn_in
170  );
171  this->m_pingIn_InputPort[port].setPortNum(port);
172 
173 #if FW_OBJECT_NAMES == 1
174  Fw::ObjectName portName;
175  portName.format(
176  "%s_pingIn_InputPort[%" PRI_PlatformIntType "]",
177  this->m_objName.toChar(),
178  port
179  );
180  this->m_pingIn_InputPort[port].setObjName(portName.toChar());
181 #endif
182  }
183 
184  // Connect input port schedIn
185  for (
186  FwIndexType port = 0;
187  port < static_cast<FwIndexType>(this->getNum_schedIn_InputPorts());
188  port++
189  ) {
190  this->m_schedIn_InputPort[port].init();
191  this->m_schedIn_InputPort[port].addCallComp(
192  this,
193  m_p_schedIn_in
194  );
195  this->m_schedIn_InputPort[port].setPortNum(port);
196 
197 #if FW_OBJECT_NAMES == 1
198  Fw::ObjectName portName;
199  portName.format(
200  "%s_schedIn_InputPort[%" PRI_PlatformIntType "]",
201  this->m_objName.toChar(),
202  port
203  );
204  this->m_schedIn_InputPort[port].setObjName(portName.toChar());
205 #endif
206  }
207 
208  // Connect output port cmdRegOut
209  for (
210  FwIndexType port = 0;
211  port < static_cast<FwIndexType>(this->getNum_cmdRegOut_OutputPorts());
212  port++
213  ) {
214  this->m_cmdRegOut_OutputPort[port].init();
215 
216 #if FW_OBJECT_NAMES == 1
217  Fw::ObjectName portName;
218  portName.format(
219  "%s_cmdRegOut_OutputPort[%" PRI_PlatformIntType "]",
220  this->m_objName.toChar(),
221  port
222  );
223  this->m_cmdRegOut_OutputPort[port].setObjName(portName.toChar());
224 #endif
225  }
226 
227  // Connect output port cmdResponseOut
228  for (
229  FwIndexType port = 0;
230  port < static_cast<FwIndexType>(this->getNum_cmdResponseOut_OutputPorts());
231  port++
232  ) {
233  this->m_cmdResponseOut_OutputPort[port].init();
234 
235 #if FW_OBJECT_NAMES == 1
236  Fw::ObjectName portName;
237  portName.format(
238  "%s_cmdResponseOut_OutputPort[%" PRI_PlatformIntType "]",
239  this->m_objName.toChar(),
240  port
241  );
242  this->m_cmdResponseOut_OutputPort[port].setObjName(portName.toChar());
243 #endif
244  }
245 
246  // Connect output port eventOut
247  for (
248  FwIndexType port = 0;
249  port < static_cast<FwIndexType>(this->getNum_eventOut_OutputPorts());
250  port++
251  ) {
252  this->m_eventOut_OutputPort[port].init();
253 
254 #if FW_OBJECT_NAMES == 1
255  Fw::ObjectName portName;
256  portName.format(
257  "%s_eventOut_OutputPort[%" PRI_PlatformIntType "]",
258  this->m_objName.toChar(),
259  port
260  );
261  this->m_eventOut_OutputPort[port].setObjName(portName.toChar());
262 #endif
263  }
264 
265 #if FW_ENABLE_TEXT_LOGGING == 1
266  // Connect output port eventOutText
267  for (
268  FwIndexType port = 0;
269  port < static_cast<FwIndexType>(this->getNum_eventOutText_OutputPorts());
270  port++
271  ) {
272  this->m_eventOutText_OutputPort[port].init();
273 
274 #if FW_OBJECT_NAMES == 1
275  Fw::ObjectName portName;
276  portName.format(
277  "%s_eventOutText_OutputPort[%" PRI_PlatformIntType "]",
278  this->m_objName.toChar(),
279  port
280  );
281  this->m_eventOutText_OutputPort[port].setObjName(portName.toChar());
282 #endif
283  }
284 #endif
285 
286  // Connect output port timeCaller
287  for (
288  FwIndexType port = 0;
289  port < static_cast<FwIndexType>(this->getNum_timeCaller_OutputPorts());
290  port++
291  ) {
292  this->m_timeCaller_OutputPort[port].init();
293 
294 #if FW_OBJECT_NAMES == 1
295  Fw::ObjectName portName;
296  portName.format(
297  "%s_timeCaller_OutputPort[%" PRI_PlatformIntType "]",
298  this->m_objName.toChar(),
299  port
300  );
301  this->m_timeCaller_OutputPort[port].setObjName(portName.toChar());
302 #endif
303  }
304 
305  // Connect output port tlmOut
306  for (
307  FwIndexType port = 0;
308  port < static_cast<FwIndexType>(this->getNum_tlmOut_OutputPorts());
309  port++
310  ) {
311  this->m_tlmOut_OutputPort[port].init();
312 
313 #if FW_OBJECT_NAMES == 1
314  Fw::ObjectName portName;
315  portName.format(
316  "%s_tlmOut_OutputPort[%" PRI_PlatformIntType "]",
317  this->m_objName.toChar(),
318  port
319  );
320  this->m_tlmOut_OutputPort[port].setObjName(portName.toChar());
321 #endif
322  }
323 
324  // Connect output port bufferSendOut
325  for (
326  FwIndexType port = 0;
327  port < static_cast<FwIndexType>(this->getNum_bufferSendOut_OutputPorts());
328  port++
329  ) {
330  this->m_bufferSendOut_OutputPort[port].init();
331 
332 #if FW_OBJECT_NAMES == 1
333  Fw::ObjectName portName;
334  portName.format(
335  "%s_bufferSendOut_OutputPort[%" PRI_PlatformIntType "]",
336  this->m_objName.toChar(),
337  port
338  );
339  this->m_bufferSendOut_OutputPort[port].setObjName(portName.toChar());
340 #endif
341  }
342 
343  // Connect output port pingOut
344  for (
345  FwIndexType port = 0;
346  port < static_cast<FwIndexType>(this->getNum_pingOut_OutputPorts());
347  port++
348  ) {
349  this->m_pingOut_OutputPort[port].init();
350 
351 #if FW_OBJECT_NAMES == 1
352  Fw::ObjectName portName;
353  portName.format(
354  "%s_pingOut_OutputPort[%" PRI_PlatformIntType "]",
355  this->m_objName.toChar(),
356  port
357  );
358  this->m_pingOut_OutputPort[port].setObjName(portName.toChar());
359 #endif
360  }
361 
362  // Create the queue
363  Os::Queue::Status qStat = this->createQueue(
364  queueDepth,
365  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
366  );
367  FW_ASSERT(
368  Os::Queue::Status::OP_OK == qStat,
369  static_cast<FwAssertArgType>(qStat)
370  );
371  }
372 
373  // ----------------------------------------------------------------------
374  // Getters for special input ports
375  // ----------------------------------------------------------------------
376 
379  {
380  FW_ASSERT(
381  portNum < this->getNum_cmdIn_InputPorts(),
382  static_cast<FwAssertArgType>(portNum)
383  );
384 
385  return &this->m_cmdIn_InputPort[portNum];
386  }
387 
388  // ----------------------------------------------------------------------
389  // Getters for typed input ports
390  // ----------------------------------------------------------------------
391 
394  {
395  FW_ASSERT(
396  portNum < this->getNum_bufferSendIn_InputPorts(),
397  static_cast<FwAssertArgType>(portNum)
398  );
399 
400  return &this->m_bufferSendIn_InputPort[portNum];
401  }
402 
405  {
406  FW_ASSERT(
407  portNum < this->getNum_comIn_InputPorts(),
408  static_cast<FwAssertArgType>(portNum)
409  );
410 
411  return &this->m_comIn_InputPort[portNum];
412  }
413 
416  {
417  FW_ASSERT(
418  portNum < this->getNum_pingIn_InputPorts(),
419  static_cast<FwAssertArgType>(portNum)
420  );
421 
422  return &this->m_pingIn_InputPort[portNum];
423  }
424 
427  {
428  FW_ASSERT(
429  portNum < this->getNum_schedIn_InputPorts(),
430  static_cast<FwAssertArgType>(portNum)
431  );
432 
433  return &this->m_schedIn_InputPort[portNum];
434  }
435 
436  // ----------------------------------------------------------------------
437  // Connect input ports to special output ports
438  // ----------------------------------------------------------------------
439 
442  FwIndexType portNum,
443  Fw::InputCmdRegPort* port
444  )
445  {
446  FW_ASSERT(
447  portNum < this->getNum_cmdRegOut_OutputPorts(),
448  static_cast<FwAssertArgType>(portNum)
449  );
450 
451  this->m_cmdRegOut_OutputPort[portNum].addCallPort(port);
452  }
453 
456  FwIndexType portNum,
458  )
459  {
460  FW_ASSERT(
461  portNum < this->getNum_cmdResponseOut_OutputPorts(),
462  static_cast<FwAssertArgType>(portNum)
463  );
464 
465  this->m_cmdResponseOut_OutputPort[portNum].addCallPort(port);
466  }
467 
470  FwIndexType portNum,
471  Fw::InputLogPort* port
472  )
473  {
474  FW_ASSERT(
475  portNum < this->getNum_eventOut_OutputPorts(),
476  static_cast<FwAssertArgType>(portNum)
477  );
478 
479  this->m_eventOut_OutputPort[portNum].addCallPort(port);
480  }
481 
482 #if FW_ENABLE_TEXT_LOGGING == 1
483 
484  void BufferLoggerComponentBase ::
485  set_eventOutText_OutputPort(
486  FwIndexType portNum,
488  )
489  {
490  FW_ASSERT(
491  portNum < this->getNum_eventOutText_OutputPorts(),
492  static_cast<FwAssertArgType>(portNum)
493  );
494 
495  this->m_eventOutText_OutputPort[portNum].addCallPort(port);
496  }
497 
498 #endif
499 
502  FwIndexType portNum,
503  Fw::InputTimePort* port
504  )
505  {
506  FW_ASSERT(
507  portNum < this->getNum_timeCaller_OutputPorts(),
508  static_cast<FwAssertArgType>(portNum)
509  );
510 
511  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
512  }
513 
516  FwIndexType portNum,
517  Fw::InputTlmPort* port
518  )
519  {
520  FW_ASSERT(
521  portNum < this->getNum_tlmOut_OutputPorts(),
522  static_cast<FwAssertArgType>(portNum)
523  );
524 
525  this->m_tlmOut_OutputPort[portNum].addCallPort(port);
526  }
527 
528  // ----------------------------------------------------------------------
529  // Connect typed input ports to typed output ports
530  // ----------------------------------------------------------------------
531 
534  FwIndexType portNum,
536  )
537  {
538  FW_ASSERT(
539  portNum < this->getNum_bufferSendOut_OutputPorts(),
540  static_cast<FwAssertArgType>(portNum)
541  );
542 
543  this->m_bufferSendOut_OutputPort[portNum].addCallPort(port);
544  }
545 
548  FwIndexType portNum,
549  Svc::InputPingPort* port
550  )
551  {
552  FW_ASSERT(
553  portNum < this->getNum_pingOut_OutputPorts(),
554  static_cast<FwAssertArgType>(portNum)
555  );
556 
557  this->m_pingOut_OutputPort[portNum].addCallPort(port);
558  }
559 
560 #if FW_PORT_SERIALIZATION
561 
562  // ----------------------------------------------------------------------
563  // Connect serial input ports to special output ports
564  // ----------------------------------------------------------------------
565 
568  FwIndexType portNum,
569  Fw::InputSerializePort* port
570  )
571  {
572  FW_ASSERT(
573  portNum < this->getNum_cmdRegOut_OutputPorts(),
574  static_cast<FwAssertArgType>(portNum)
575  );
576 
577  this->m_cmdRegOut_OutputPort[portNum].registerSerialPort(port);
578  }
579 
582  FwIndexType portNum,
583  Fw::InputSerializePort* port
584  )
585  {
586  FW_ASSERT(
587  portNum < this->getNum_cmdResponseOut_OutputPorts(),
588  static_cast<FwAssertArgType>(portNum)
589  );
590 
591  this->m_cmdResponseOut_OutputPort[portNum].registerSerialPort(port);
592  }
593 
596  FwIndexType portNum,
597  Fw::InputSerializePort* port
598  )
599  {
600  FW_ASSERT(
601  portNum < this->getNum_eventOut_OutputPorts(),
602  static_cast<FwAssertArgType>(portNum)
603  );
604 
605  this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
606  }
607 
608 #if FW_ENABLE_TEXT_LOGGING == 1
609 
610  void BufferLoggerComponentBase ::
611  set_eventOutText_OutputPort(
612  FwIndexType portNum,
613  Fw::InputSerializePort* port
614  )
615  {
616  FW_ASSERT(
617  portNum < this->getNum_eventOutText_OutputPorts(),
618  static_cast<FwAssertArgType>(portNum)
619  );
620 
621  this->m_eventOutText_OutputPort[portNum].registerSerialPort(port);
622  }
623 
624 #endif
625 
628  FwIndexType portNum,
629  Fw::InputSerializePort* port
630  )
631  {
632  FW_ASSERT(
633  portNum < this->getNum_timeCaller_OutputPorts(),
634  static_cast<FwAssertArgType>(portNum)
635  );
636 
637  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
638  }
639 
642  FwIndexType portNum,
643  Fw::InputSerializePort* port
644  )
645  {
646  FW_ASSERT(
647  portNum < this->getNum_tlmOut_OutputPorts(),
648  static_cast<FwAssertArgType>(portNum)
649  );
650 
651  this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
652  }
653 
654 #endif
655 
656 #if FW_PORT_SERIALIZATION
657 
658  // ----------------------------------------------------------------------
659  // Connect serial input ports to typed output ports
660  // ----------------------------------------------------------------------
661 
664  FwIndexType portNum,
665  Fw::InputSerializePort* port
666  )
667  {
668  FW_ASSERT(
669  portNum < this->getNum_bufferSendOut_OutputPorts(),
670  static_cast<FwAssertArgType>(portNum)
671  );
672 
673  this->m_bufferSendOut_OutputPort[portNum].registerSerialPort(port);
674  }
675 
678  FwIndexType portNum,
679  Fw::InputSerializePort* port
680  )
681  {
682  FW_ASSERT(
683  portNum < this->getNum_pingOut_OutputPorts(),
684  static_cast<FwAssertArgType>(portNum)
685  );
686 
687  this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
688  }
689 
690 #endif
691 
692  // ----------------------------------------------------------------------
693  // Command registration
694  // ----------------------------------------------------------------------
695 
698  {
699  FW_ASSERT(this->m_cmdRegOut_OutputPort[0].isConnected());
700 
701  this->m_cmdRegOut_OutputPort[0].invoke(
702  this->getIdBase() + OPCODE_BL_OPENFILE
703  );
704 
705  this->m_cmdRegOut_OutputPort[0].invoke(
707  );
708 
709  this->m_cmdRegOut_OutputPort[0].invoke(
711  );
712 
713  this->m_cmdRegOut_OutputPort[0].invoke(
715  );
716  }
717 
718  // ----------------------------------------------------------------------
719  // Component construction and destruction
720  // ----------------------------------------------------------------------
721 
723  BufferLoggerComponentBase(const char* compName) :
724  Fw::ActiveComponentBase(compName)
725  {
726 
727  }
728 
731  {
732 
733  }
734 
735  // ----------------------------------------------------------------------
736  // Getters for numbers of special input ports
737  // ----------------------------------------------------------------------
738 
741  {
742  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdIn_InputPort));
743  }
744 
745  // ----------------------------------------------------------------------
746  // Getters for numbers of typed input ports
747  // ----------------------------------------------------------------------
748 
751  {
752  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferSendIn_InputPort));
753  }
754 
757  {
758  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_comIn_InputPort));
759  }
760 
763  {
764  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_pingIn_InputPort));
765  }
766 
769  {
770  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_schedIn_InputPort));
771  }
772 
773  // ----------------------------------------------------------------------
774  // Getters for numbers of special output ports
775  // ----------------------------------------------------------------------
776 
779  {
780  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdRegOut_OutputPort));
781  }
782 
785  {
786  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdResponseOut_OutputPort));
787  }
788 
791  {
792  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_eventOut_OutputPort));
793  }
794 
795 #if FW_ENABLE_TEXT_LOGGING == 1
796 
797  FwIndexType BufferLoggerComponentBase ::
798  getNum_eventOutText_OutputPorts() const
799  {
800  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_eventOutText_OutputPort));
801  }
802 
803 #endif
804 
807  {
808  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_timeCaller_OutputPort));
809  }
810 
813  {
814  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_tlmOut_OutputPort));
815  }
816 
817  // ----------------------------------------------------------------------
818  // Getters for numbers of typed output ports
819  // ----------------------------------------------------------------------
820 
823  {
824  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferSendOut_OutputPort));
825  }
826 
829  {
830  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_pingOut_OutputPort));
831  }
832 
833  // ----------------------------------------------------------------------
834  // Connection status queries for special output ports
835  // ----------------------------------------------------------------------
836 
839  {
840  FW_ASSERT(
841  portNum < this->getNum_cmdRegOut_OutputPorts(),
842  static_cast<FwAssertArgType>(portNum)
843  );
844 
845  return this->m_cmdRegOut_OutputPort[portNum].isConnected();
846  }
847 
850  {
851  FW_ASSERT(
852  portNum < this->getNum_cmdResponseOut_OutputPorts(),
853  static_cast<FwAssertArgType>(portNum)
854  );
855 
856  return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
857  }
858 
861  {
862  FW_ASSERT(
863  portNum < this->getNum_eventOut_OutputPorts(),
864  static_cast<FwAssertArgType>(portNum)
865  );
866 
867  return this->m_eventOut_OutputPort[portNum].isConnected();
868  }
869 
870 #if FW_ENABLE_TEXT_LOGGING == 1
871 
872  bool BufferLoggerComponentBase ::
873  isConnected_eventOutText_OutputPort(FwIndexType portNum)
874  {
875  FW_ASSERT(
876  portNum < this->getNum_eventOutText_OutputPorts(),
877  static_cast<FwAssertArgType>(portNum)
878  );
879 
880  return this->m_eventOutText_OutputPort[portNum].isConnected();
881  }
882 
883 #endif
884 
887  {
888  FW_ASSERT(
889  portNum < this->getNum_timeCaller_OutputPorts(),
890  static_cast<FwAssertArgType>(portNum)
891  );
892 
893  return this->m_timeCaller_OutputPort[portNum].isConnected();
894  }
895 
898  {
899  FW_ASSERT(
900  portNum < this->getNum_tlmOut_OutputPorts(),
901  static_cast<FwAssertArgType>(portNum)
902  );
903 
904  return this->m_tlmOut_OutputPort[portNum].isConnected();
905  }
906 
907  // ----------------------------------------------------------------------
908  // Connection status queries for typed output ports
909  // ----------------------------------------------------------------------
910 
913  {
914  FW_ASSERT(
915  portNum < this->getNum_bufferSendOut_OutputPorts(),
916  static_cast<FwAssertArgType>(portNum)
917  );
918 
919  return this->m_bufferSendOut_OutputPort[portNum].isConnected();
920  }
921 
924  {
925  FW_ASSERT(
926  portNum < this->getNum_pingOut_OutputPorts(),
927  static_cast<FwAssertArgType>(portNum)
928  );
929 
930  return this->m_pingOut_OutputPort[portNum].isConnected();
931  }
932 
933  // ----------------------------------------------------------------------
934  // Port handler base-class functions for typed input ports
935  //
936  // Call these functions directly to bypass the corresponding ports
937  // ----------------------------------------------------------------------
938 
941  FwIndexType portNum,
942  Fw::Buffer& fwBuffer
943  )
944  {
945  // Make sure port number is valid
946  FW_ASSERT(
947  portNum < this->getNum_bufferSendIn_InputPorts(),
948  static_cast<FwAssertArgType>(portNum)
949  );
950 
951  // Call pre-message hook
953  portNum,
954  fwBuffer
955  );
956  ComponentIpcSerializableBuffer msg;
958 
959  // Serialize message ID
960  _status = msg.serialize(
961  static_cast<FwEnumStoreType>(BUFFERSENDIN_BUFFERSEND)
962  );
963  FW_ASSERT(
964  _status == Fw::FW_SERIALIZE_OK,
965  static_cast<FwAssertArgType>(_status)
966  );
967 
968  // Serialize port number
969  _status = msg.serialize(portNum);
970  FW_ASSERT(
971  _status == Fw::FW_SERIALIZE_OK,
972  static_cast<FwAssertArgType>(_status)
973  );
974 
975  // Serialize argument fwBuffer
976  _status = msg.serialize(fwBuffer);
977  FW_ASSERT(
978  _status == Fw::FW_SERIALIZE_OK,
979  static_cast<FwAssertArgType>(_status)
980  );
981 
982  // Send message
984  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
985 
986  FW_ASSERT(
987  qStatus == Os::Queue::OP_OK,
988  static_cast<FwAssertArgType>(qStatus)
989  );
990  }
991 
994  FwIndexType portNum,
995  Fw::ComBuffer& data,
996  U32 context
997  )
998  {
999  // Make sure port number is valid
1000  FW_ASSERT(
1001  portNum < this->getNum_comIn_InputPorts(),
1002  static_cast<FwAssertArgType>(portNum)
1003  );
1004 
1005  // Call pre-message hook
1007  portNum,
1008  data,
1009  context
1010  );
1011  ComponentIpcSerializableBuffer msg;
1013 
1014  // Serialize message ID
1015  _status = msg.serialize(
1016  static_cast<FwEnumStoreType>(COMIN_COM)
1017  );
1018  FW_ASSERT(
1019  _status == Fw::FW_SERIALIZE_OK,
1020  static_cast<FwAssertArgType>(_status)
1021  );
1022 
1023  // Serialize port number
1024  _status = msg.serialize(portNum);
1025  FW_ASSERT(
1026  _status == Fw::FW_SERIALIZE_OK,
1027  static_cast<FwAssertArgType>(_status)
1028  );
1029 
1030  // Serialize argument data
1031  _status = msg.serialize(data);
1032  FW_ASSERT(
1033  _status == Fw::FW_SERIALIZE_OK,
1034  static_cast<FwAssertArgType>(_status)
1035  );
1036 
1037  // Serialize argument context
1038  _status = msg.serialize(context);
1039  FW_ASSERT(
1040  _status == Fw::FW_SERIALIZE_OK,
1041  static_cast<FwAssertArgType>(_status)
1042  );
1043 
1044  // Send message
1046  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1047 
1048  FW_ASSERT(
1049  qStatus == Os::Queue::OP_OK,
1050  static_cast<FwAssertArgType>(qStatus)
1051  );
1052  }
1053 
1056  FwIndexType portNum,
1057  U32 key
1058  )
1059  {
1060  // Make sure port number is valid
1061  FW_ASSERT(
1062  portNum < this->getNum_pingIn_InputPorts(),
1063  static_cast<FwAssertArgType>(portNum)
1064  );
1065 
1066  // Call pre-message hook
1068  portNum,
1069  key
1070  );
1071  ComponentIpcSerializableBuffer msg;
1073 
1074  // Serialize message ID
1075  _status = msg.serialize(
1076  static_cast<FwEnumStoreType>(PINGIN_PING)
1077  );
1078  FW_ASSERT(
1079  _status == Fw::FW_SERIALIZE_OK,
1080  static_cast<FwAssertArgType>(_status)
1081  );
1082 
1083  // Serialize port number
1084  _status = msg.serialize(portNum);
1085  FW_ASSERT(
1086  _status == Fw::FW_SERIALIZE_OK,
1087  static_cast<FwAssertArgType>(_status)
1088  );
1089 
1090  // Serialize argument key
1091  _status = msg.serialize(key);
1092  FW_ASSERT(
1093  _status == Fw::FW_SERIALIZE_OK,
1094  static_cast<FwAssertArgType>(_status)
1095  );
1096 
1097  // Send message
1099  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1100 
1101  FW_ASSERT(
1102  qStatus == Os::Queue::OP_OK,
1103  static_cast<FwAssertArgType>(qStatus)
1104  );
1105  }
1106 
1109  FwIndexType portNum,
1110  U32 context
1111  )
1112  {
1113  // Make sure port number is valid
1114  FW_ASSERT(
1115  portNum < this->getNum_schedIn_InputPorts(),
1116  static_cast<FwAssertArgType>(portNum)
1117  );
1118 
1119  // Call pre-message hook
1121  portNum,
1122  context
1123  );
1124  ComponentIpcSerializableBuffer msg;
1126 
1127  // Serialize message ID
1128  _status = msg.serialize(
1129  static_cast<FwEnumStoreType>(SCHEDIN_SCHED)
1130  );
1131  FW_ASSERT(
1132  _status == Fw::FW_SERIALIZE_OK,
1133  static_cast<FwAssertArgType>(_status)
1134  );
1135 
1136  // Serialize port number
1137  _status = msg.serialize(portNum);
1138  FW_ASSERT(
1139  _status == Fw::FW_SERIALIZE_OK,
1140  static_cast<FwAssertArgType>(_status)
1141  );
1142 
1143  // Serialize argument context
1144  _status = msg.serialize(context);
1145  FW_ASSERT(
1146  _status == Fw::FW_SERIALIZE_OK,
1147  static_cast<FwAssertArgType>(_status)
1148  );
1149 
1150  // Send message
1152  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1153 
1154  FW_ASSERT(
1155  qStatus == Os::Queue::OP_OK,
1156  static_cast<FwAssertArgType>(qStatus)
1157  );
1158  }
1159 
1160  // ----------------------------------------------------------------------
1161  // Pre-message hooks for typed async input ports
1162  //
1163  // Each of these functions is invoked just before processing a message
1164  // on the corresponding port. By default, they do nothing. You can
1165  // override them to provide specific pre-message behavior.
1166  // ----------------------------------------------------------------------
1167 
1170  FwIndexType portNum,
1171  Fw::Buffer& fwBuffer
1172  )
1173  {
1174  // Default: no-op
1175  }
1176 
1179  FwIndexType portNum,
1180  Fw::ComBuffer& data,
1181  U32 context
1182  )
1183  {
1184  // Default: no-op
1185  }
1186 
1189  FwIndexType portNum,
1190  U32 key
1191  )
1192  {
1193  // Default: no-op
1194  }
1195 
1198  FwIndexType portNum,
1199  U32 context
1200  )
1201  {
1202  // Default: no-op
1203  }
1204 
1205  // ----------------------------------------------------------------------
1206  // Invocation functions for typed output ports
1207  // ----------------------------------------------------------------------
1208 
1211  FwIndexType portNum,
1212  Fw::Buffer& fwBuffer
1213  )
1214  {
1215  FW_ASSERT(
1216  portNum < this->getNum_bufferSendOut_OutputPorts(),
1217  static_cast<FwAssertArgType>(portNum)
1218  );
1219 
1220  FW_ASSERT(
1221  this->m_bufferSendOut_OutputPort[portNum].isConnected(),
1222  static_cast<FwAssertArgType>(portNum)
1223  );
1224  this->m_bufferSendOut_OutputPort[portNum].invoke(
1225  fwBuffer
1226  );
1227  }
1228 
1231  FwIndexType portNum,
1232  U32 key
1233  )
1234  {
1235  FW_ASSERT(
1236  portNum < this->getNum_pingOut_OutputPorts(),
1237  static_cast<FwAssertArgType>(portNum)
1238  );
1239 
1240  FW_ASSERT(
1241  this->m_pingOut_OutputPort[portNum].isConnected(),
1242  static_cast<FwAssertArgType>(portNum)
1243  );
1244  this->m_pingOut_OutputPort[portNum].invoke(
1245  key
1246  );
1247  }
1248 
1249  // ----------------------------------------------------------------------
1250  // Command response
1251  // ----------------------------------------------------------------------
1252 
1255  FwOpcodeType opCode,
1256  U32 cmdSeq,
1257  Fw::CmdResponse response
1258  )
1259  {
1260  FW_ASSERT(this->m_cmdResponseOut_OutputPort[0].isConnected());
1261  this->m_cmdResponseOut_OutputPort[0].invoke(opCode, cmdSeq, response);
1262  }
1263 
1264  // ----------------------------------------------------------------------
1265  // Command handler base-class functions
1266  //
1267  // Call these functions directly to bypass the command input port
1268  // ----------------------------------------------------------------------
1269 
1272  FwOpcodeType opCode,
1273  U32 cmdSeq,
1274  Fw::CmdArgBuffer& args
1275  )
1276  {
1277  // Call pre-message hook
1278  this->BL_OpenFile_preMsgHook(opCode,cmdSeq);
1279 
1280  // Defer deserializing arguments to the message dispatcher
1281  // to avoid deserializing and reserializing just for IPC
1282  ComponentIpcSerializableBuffer msg;
1284 
1285  // Serialize for IPC
1286  _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_BL_OPENFILE));
1287  FW_ASSERT (
1288  _status == Fw::FW_SERIALIZE_OK,
1289  static_cast<FwAssertArgType>(_status)
1290  );
1291 
1292  // Fake port number to make message dequeue work
1293  FwIndexType port = 0;
1294 
1295  _status = msg.serialize(port);
1296  FW_ASSERT (
1297  _status == Fw::FW_SERIALIZE_OK,
1298  static_cast<FwAssertArgType>(_status)
1299  );
1300 
1301  _status = msg.serialize(opCode);
1302  FW_ASSERT (
1303  _status == Fw::FW_SERIALIZE_OK,
1304  static_cast<FwAssertArgType>(_status)
1305  );
1306 
1307  _status = msg.serialize(cmdSeq);
1308  FW_ASSERT (
1309  _status == Fw::FW_SERIALIZE_OK,
1310  static_cast<FwAssertArgType>(_status)
1311  );
1312 
1313  _status = msg.serialize(args);
1314  FW_ASSERT (
1315  _status == Fw::FW_SERIALIZE_OK,
1316  static_cast<FwAssertArgType>(_status)
1317  );
1318 
1319  // Send message
1321  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1322 
1323  FW_ASSERT(
1324  qStatus == Os::Queue::OP_OK,
1325  static_cast<FwAssertArgType>(qStatus)
1326  );
1327  }
1328 
1331  FwOpcodeType opCode,
1332  U32 cmdSeq,
1333  Fw::CmdArgBuffer& args
1334  )
1335  {
1336  // Call pre-message hook
1337  this->BL_CloseFile_preMsgHook(opCode,cmdSeq);
1338 
1339  // Defer deserializing arguments to the message dispatcher
1340  // to avoid deserializing and reserializing just for IPC
1341  ComponentIpcSerializableBuffer msg;
1343 
1344  // Serialize for IPC
1345  _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_BL_CLOSEFILE));
1346  FW_ASSERT (
1347  _status == Fw::FW_SERIALIZE_OK,
1348  static_cast<FwAssertArgType>(_status)
1349  );
1350 
1351  // Fake port number to make message dequeue work
1352  FwIndexType port = 0;
1353 
1354  _status = msg.serialize(port);
1355  FW_ASSERT (
1356  _status == Fw::FW_SERIALIZE_OK,
1357  static_cast<FwAssertArgType>(_status)
1358  );
1359 
1360  _status = msg.serialize(opCode);
1361  FW_ASSERT (
1362  _status == Fw::FW_SERIALIZE_OK,
1363  static_cast<FwAssertArgType>(_status)
1364  );
1365 
1366  _status = msg.serialize(cmdSeq);
1367  FW_ASSERT (
1368  _status == Fw::FW_SERIALIZE_OK,
1369  static_cast<FwAssertArgType>(_status)
1370  );
1371 
1372  _status = msg.serialize(args);
1373  FW_ASSERT (
1374  _status == Fw::FW_SERIALIZE_OK,
1375  static_cast<FwAssertArgType>(_status)
1376  );
1377 
1378  // Send message
1380  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1381 
1382  FW_ASSERT(
1383  qStatus == Os::Queue::OP_OK,
1384  static_cast<FwAssertArgType>(qStatus)
1385  );
1386  }
1387 
1390  FwOpcodeType opCode,
1391  U32 cmdSeq,
1392  Fw::CmdArgBuffer& args
1393  )
1394  {
1395  // Call pre-message hook
1396  this->BL_SetLogging_preMsgHook(opCode,cmdSeq);
1397 
1398  // Defer deserializing arguments to the message dispatcher
1399  // to avoid deserializing and reserializing just for IPC
1400  ComponentIpcSerializableBuffer msg;
1402 
1403  // Serialize for IPC
1404  _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_BL_SETLOGGING));
1405  FW_ASSERT (
1406  _status == Fw::FW_SERIALIZE_OK,
1407  static_cast<FwAssertArgType>(_status)
1408  );
1409 
1410  // Fake port number to make message dequeue work
1411  FwIndexType port = 0;
1412 
1413  _status = msg.serialize(port);
1414  FW_ASSERT (
1415  _status == Fw::FW_SERIALIZE_OK,
1416  static_cast<FwAssertArgType>(_status)
1417  );
1418 
1419  _status = msg.serialize(opCode);
1420  FW_ASSERT (
1421  _status == Fw::FW_SERIALIZE_OK,
1422  static_cast<FwAssertArgType>(_status)
1423  );
1424 
1425  _status = msg.serialize(cmdSeq);
1426  FW_ASSERT (
1427  _status == Fw::FW_SERIALIZE_OK,
1428  static_cast<FwAssertArgType>(_status)
1429  );
1430 
1431  _status = msg.serialize(args);
1432  FW_ASSERT (
1433  _status == Fw::FW_SERIALIZE_OK,
1434  static_cast<FwAssertArgType>(_status)
1435  );
1436 
1437  // Send message
1439  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1440 
1441  FW_ASSERT(
1442  qStatus == Os::Queue::OP_OK,
1443  static_cast<FwAssertArgType>(qStatus)
1444  );
1445  }
1446 
1449  FwOpcodeType opCode,
1450  U32 cmdSeq,
1451  Fw::CmdArgBuffer& args
1452  )
1453  {
1454  // Call pre-message hook
1455  this->BL_FlushFile_preMsgHook(opCode,cmdSeq);
1456 
1457  // Defer deserializing arguments to the message dispatcher
1458  // to avoid deserializing and reserializing just for IPC
1459  ComponentIpcSerializableBuffer msg;
1461 
1462  // Serialize for IPC
1463  _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_BL_FLUSHFILE));
1464  FW_ASSERT (
1465  _status == Fw::FW_SERIALIZE_OK,
1466  static_cast<FwAssertArgType>(_status)
1467  );
1468 
1469  // Fake port number to make message dequeue work
1470  FwIndexType port = 0;
1471 
1472  _status = msg.serialize(port);
1473  FW_ASSERT (
1474  _status == Fw::FW_SERIALIZE_OK,
1475  static_cast<FwAssertArgType>(_status)
1476  );
1477 
1478  _status = msg.serialize(opCode);
1479  FW_ASSERT (
1480  _status == Fw::FW_SERIALIZE_OK,
1481  static_cast<FwAssertArgType>(_status)
1482  );
1483 
1484  _status = msg.serialize(cmdSeq);
1485  FW_ASSERT (
1486  _status == Fw::FW_SERIALIZE_OK,
1487  static_cast<FwAssertArgType>(_status)
1488  );
1489 
1490  _status = msg.serialize(args);
1491  FW_ASSERT (
1492  _status == Fw::FW_SERIALIZE_OK,
1493  static_cast<FwAssertArgType>(_status)
1494  );
1495 
1496  // Send message
1498  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1499 
1500  FW_ASSERT(
1501  qStatus == Os::Queue::OP_OK,
1502  static_cast<FwAssertArgType>(qStatus)
1503  );
1504  }
1505 
1506  // ----------------------------------------------------------------------
1507  // Pre-message hooks for async commands
1508  //
1509  // Each of these functions is invoked just before processing the
1510  // corresponding command. By default they do nothing. You can
1511  // override them to provide specific pre-command behavior.
1512  // ----------------------------------------------------------------------
1513 
1516  FwOpcodeType opCode,
1517  U32 cmdSeq
1518  )
1519  {
1520  // Defaults to no-op; can be overridden
1521  (void) opCode;
1522  (void) cmdSeq;
1523  }
1524 
1527  FwOpcodeType opCode,
1528  U32 cmdSeq
1529  )
1530  {
1531  // Defaults to no-op; can be overridden
1532  (void) opCode;
1533  (void) cmdSeq;
1534  }
1535 
1538  FwOpcodeType opCode,
1539  U32 cmdSeq
1540  )
1541  {
1542  // Defaults to no-op; can be overridden
1543  (void) opCode;
1544  (void) cmdSeq;
1545  }
1546 
1549  FwOpcodeType opCode,
1550  U32 cmdSeq
1551  )
1552  {
1553  // Defaults to no-op; can be overridden
1554  (void) opCode;
1555  (void) cmdSeq;
1556  }
1557 
1558  // ----------------------------------------------------------------------
1559  // Event logging functions
1560  // ----------------------------------------------------------------------
1561 
1564  {
1565  // Get the time
1566  Fw::Time _logTime;
1567  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1568  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1569  }
1570 
1571  FwEventIdType _id = static_cast<FwEventIdType>(0);
1572 
1573  _id = this->getIdBase() + EVENTID_BL_LOGFILECLOSED;
1574 
1575  // Emit the event on the log port
1576  if (this->m_eventOut_OutputPort[0].isConnected()) {
1577  Fw::LogBuffer _logBuff;
1579 
1580 #if FW_AMPCS_COMPATIBLE
1581  // Serialize the number of arguments
1582  _status = _logBuff.serialize(static_cast<U8>(1));
1583  FW_ASSERT(
1584  _status == Fw::FW_SERIALIZE_OK,
1585  static_cast<FwAssertArgType>(_status)
1586  );
1587 #endif
1588 
1589  _status = file.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 256));
1590  FW_ASSERT(
1591  _status == Fw::FW_SERIALIZE_OK,
1592  static_cast<FwAssertArgType>(_status)
1593  );
1594 
1595  this->m_eventOut_OutputPort[0].invoke(
1596  _id,
1597  _logTime,
1599  _logBuff
1600  );
1601  }
1602 
1603  // Emit the event on the text log port
1604 #if FW_ENABLE_TEXT_LOGGING
1605  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1606 #if FW_OBJECT_NAMES == 1
1607  const char* _formatString =
1608  "(%s) %s: File %s closed";
1609 #else
1610  const char* _formatString =
1611  "%s: File %s closed";
1612 #endif
1613 
1614  Fw::TextLogString _logString;
1615  _logString.format(
1616  _formatString,
1617 #if FW_OBJECT_NAMES == 1
1618  this->m_objName.toChar(),
1619 #endif
1620  "BL_LogFileClosed ",
1621  file.toChar()
1622  );
1623 
1624  this->m_eventOutText_OutputPort[0].invoke(
1625  _id,
1626  _logTime,
1628  _logString
1629  );
1630  }
1631 #endif
1632  }
1633 
1636  U32 errornum,
1637  const Fw::StringBase& file
1638  ) const
1639  {
1640  // Get the time
1641  Fw::Time _logTime;
1642  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1643  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1644  }
1645 
1646  FwEventIdType _id = static_cast<FwEventIdType>(0);
1647 
1648  _id = this->getIdBase() + EVENTID_BL_LOGFILEOPENERROR;
1649 
1650  // Emit the event on the log port
1651  if (this->m_eventOut_OutputPort[0].isConnected()) {
1652  Fw::LogBuffer _logBuff;
1654 
1655 #if FW_AMPCS_COMPATIBLE
1656  // Serialize the number of arguments
1657  _status = _logBuff.serialize(static_cast<U8>(2));
1658  FW_ASSERT(
1659  _status == Fw::FW_SERIALIZE_OK,
1660  static_cast<FwAssertArgType>(_status)
1661  );
1662 #endif
1663 
1664 #if FW_AMPCS_COMPATIBLE
1665  // Serialize the argument size
1666  _status = _logBuff.serialize(
1667  static_cast<U8>(sizeof(U32))
1668  );
1669  FW_ASSERT(
1670  _status == Fw::FW_SERIALIZE_OK,
1671  static_cast<FwAssertArgType>(_status)
1672  );
1673 #endif
1674  _status = _logBuff.serialize(errornum);
1675  FW_ASSERT(
1676  _status == Fw::FW_SERIALIZE_OK,
1677  static_cast<FwAssertArgType>(_status)
1678  );
1679 
1680  _status = file.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 256));
1681  FW_ASSERT(
1682  _status == Fw::FW_SERIALIZE_OK,
1683  static_cast<FwAssertArgType>(_status)
1684  );
1685 
1686  this->m_eventOut_OutputPort[0].invoke(
1687  _id,
1688  _logTime,
1690  _logBuff
1691  );
1692  }
1693 
1694  // Emit the event on the text log port
1695 #if FW_ENABLE_TEXT_LOGGING
1696  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1697 #if FW_OBJECT_NAMES == 1
1698  const char* _formatString =
1699  "(%s) %s: Error %" PRIu32 " opening file %s";
1700 #else
1701  const char* _formatString =
1702  "%s: Error %" PRIu32 " opening file %s";
1703 #endif
1704 
1705  Fw::TextLogString _logString;
1706  _logString.format(
1707  _formatString,
1708 #if FW_OBJECT_NAMES == 1
1709  this->m_objName.toChar(),
1710 #endif
1711  "BL_LogFileOpenError ",
1712  errornum,
1713  file.toChar()
1714  );
1715 
1716  this->m_eventOutText_OutputPort[0].invoke(
1717  _id,
1718  _logTime,
1720  _logString
1721  );
1722  }
1723 #endif
1724  }
1725 
1728  const Fw::StringBase& validationFile,
1729  U32 status
1730  ) const
1731  {
1732  // Get the time
1733  Fw::Time _logTime;
1734  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1735  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1736  }
1737 
1738  FwEventIdType _id = static_cast<FwEventIdType>(0);
1739 
1741 
1742  // Emit the event on the log port
1743  if (this->m_eventOut_OutputPort[0].isConnected()) {
1744  Fw::LogBuffer _logBuff;
1746 
1747 #if FW_AMPCS_COMPATIBLE
1748  // Serialize the number of arguments
1749  _status = _logBuff.serialize(static_cast<U8>(2));
1750  FW_ASSERT(
1751  _status == Fw::FW_SERIALIZE_OK,
1752  static_cast<FwAssertArgType>(_status)
1753  );
1754 #endif
1755 
1756  _status = validationFile.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 256));
1757  FW_ASSERT(
1758  _status == Fw::FW_SERIALIZE_OK,
1759  static_cast<FwAssertArgType>(_status)
1760  );
1761 
1762 #if FW_AMPCS_COMPATIBLE
1763  // Serialize the argument size
1764  _status = _logBuff.serialize(
1765  static_cast<U8>(sizeof(U32))
1766  );
1767  FW_ASSERT(
1768  _status == Fw::FW_SERIALIZE_OK,
1769  static_cast<FwAssertArgType>(_status)
1770  );
1771 #endif
1772  _status = _logBuff.serialize(status);
1773  FW_ASSERT(
1774  _status == Fw::FW_SERIALIZE_OK,
1775  static_cast<FwAssertArgType>(_status)
1776  );
1777 
1778  this->m_eventOut_OutputPort[0].invoke(
1779  _id,
1780  _logTime,
1782  _logBuff
1783  );
1784  }
1785 
1786  // Emit the event on the text log port
1787 #if FW_ENABLE_TEXT_LOGGING
1788  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1789 #if FW_OBJECT_NAMES == 1
1790  const char* _formatString =
1791  "(%s) %s: Failed creating validation file %s with status %" PRIu32 "";
1792 #else
1793  const char* _formatString =
1794  "%s: Failed creating validation file %s with status %" PRIu32 "";
1795 #endif
1796 
1797  Fw::TextLogString _logString;
1798  _logString.format(
1799  _formatString,
1800 #if FW_OBJECT_NAMES == 1
1801  this->m_objName.toChar(),
1802 #endif
1803  "BL_LogFileValidationError ",
1804  validationFile.toChar(),
1805  status
1806  );
1807 
1808  this->m_eventOutText_OutputPort[0].invoke(
1809  _id,
1810  _logTime,
1812  _logString
1813  );
1814  }
1815 #endif
1816  }
1817 
1820  U32 errornum,
1821  U32 bytesWritten,
1822  U32 bytesToWrite,
1823  const Fw::StringBase& file
1824  ) const
1825  {
1826  // Get the time
1827  Fw::Time _logTime;
1828  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1829  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1830  }
1831 
1832  FwEventIdType _id = static_cast<FwEventIdType>(0);
1833 
1834  _id = this->getIdBase() + EVENTID_BL_LOGFILEWRITEERROR;
1835 
1836  // Emit the event on the log port
1837  if (this->m_eventOut_OutputPort[0].isConnected()) {
1838  Fw::LogBuffer _logBuff;
1840 
1841 #if FW_AMPCS_COMPATIBLE
1842  // Serialize the number of arguments
1843  _status = _logBuff.serialize(static_cast<U8>(4));
1844  FW_ASSERT(
1845  _status == Fw::FW_SERIALIZE_OK,
1846  static_cast<FwAssertArgType>(_status)
1847  );
1848 #endif
1849 
1850 #if FW_AMPCS_COMPATIBLE
1851  // Serialize the argument size
1852  _status = _logBuff.serialize(
1853  static_cast<U8>(sizeof(U32))
1854  );
1855  FW_ASSERT(
1856  _status == Fw::FW_SERIALIZE_OK,
1857  static_cast<FwAssertArgType>(_status)
1858  );
1859 #endif
1860  _status = _logBuff.serialize(errornum);
1861  FW_ASSERT(
1862  _status == Fw::FW_SERIALIZE_OK,
1863  static_cast<FwAssertArgType>(_status)
1864  );
1865 
1866 #if FW_AMPCS_COMPATIBLE
1867  // Serialize the argument size
1868  _status = _logBuff.serialize(
1869  static_cast<U8>(sizeof(U32))
1870  );
1871  FW_ASSERT(
1872  _status == Fw::FW_SERIALIZE_OK,
1873  static_cast<FwAssertArgType>(_status)
1874  );
1875 #endif
1876  _status = _logBuff.serialize(bytesWritten);
1877  FW_ASSERT(
1878  _status == Fw::FW_SERIALIZE_OK,
1879  static_cast<FwAssertArgType>(_status)
1880  );
1881 
1882 #if FW_AMPCS_COMPATIBLE
1883  // Serialize the argument size
1884  _status = _logBuff.serialize(
1885  static_cast<U8>(sizeof(U32))
1886  );
1887  FW_ASSERT(
1888  _status == Fw::FW_SERIALIZE_OK,
1889  static_cast<FwAssertArgType>(_status)
1890  );
1891 #endif
1892  _status = _logBuff.serialize(bytesToWrite);
1893  FW_ASSERT(
1894  _status == Fw::FW_SERIALIZE_OK,
1895  static_cast<FwAssertArgType>(_status)
1896  );
1897 
1898  _status = file.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 256));
1899  FW_ASSERT(
1900  _status == Fw::FW_SERIALIZE_OK,
1901  static_cast<FwAssertArgType>(_status)
1902  );
1903 
1904  this->m_eventOut_OutputPort[0].invoke(
1905  _id,
1906  _logTime,
1908  _logBuff
1909  );
1910  }
1911 
1912  // Emit the event on the text log port
1913 #if FW_ENABLE_TEXT_LOGGING
1914  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1915 #if FW_OBJECT_NAMES == 1
1916  const char* _formatString =
1917  "(%s) %s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1918 #else
1919  const char* _formatString =
1920  "%s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1921 #endif
1922 
1923  Fw::TextLogString _logString;
1924  _logString.format(
1925  _formatString,
1926 #if FW_OBJECT_NAMES == 1
1927  this->m_objName.toChar(),
1928 #endif
1929  "BL_LogFileWriteError ",
1930  errornum,
1931  bytesWritten,
1932  bytesToWrite,
1933  file.toChar()
1934  );
1935 
1936  this->m_eventOutText_OutputPort[0].invoke(
1937  _id,
1938  _logTime,
1940  _logString
1941  );
1942  }
1943 #endif
1944  }
1945 
1948  {
1949  // Get the time
1950  Fw::Time _logTime;
1951  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1952  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1953  }
1954 
1955  FwEventIdType _id = static_cast<FwEventIdType>(0);
1956 
1957  _id = this->getIdBase() + EVENTID_BL_ACTIVATED;
1958 
1959  // Emit the event on the log port
1960  if (this->m_eventOut_OutputPort[0].isConnected()) {
1961  Fw::LogBuffer _logBuff;
1962 
1963 #if FW_AMPCS_COMPATIBLE
1965  // Serialize the number of arguments
1966  _status = _logBuff.serialize(static_cast<U8>(0));
1967  FW_ASSERT(
1968  _status == Fw::FW_SERIALIZE_OK,
1969  static_cast<FwAssertArgType>(_status)
1970  );
1971 #endif
1972 
1973  this->m_eventOut_OutputPort[0].invoke(
1974  _id,
1975  _logTime,
1977  _logBuff
1978  );
1979  }
1980 
1981  // Emit the event on the text log port
1982 #if FW_ENABLE_TEXT_LOGGING
1983  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1984 #if FW_OBJECT_NAMES == 1
1985  const char* _formatString =
1986  "(%s) %s: Buffer logger was activated";
1987 #else
1988  const char* _formatString =
1989  "%s: Buffer logger was activated";
1990 #endif
1991 
1992  Fw::TextLogString _logString;
1993  _logString.format(
1994  _formatString,
1995 #if FW_OBJECT_NAMES == 1
1996  this->m_objName.toChar(),
1997 #endif
1998  "BL_Activated "
1999  );
2000 
2001  this->m_eventOutText_OutputPort[0].invoke(
2002  _id,
2003  _logTime,
2005  _logString
2006  );
2007  }
2008 #endif
2009  }
2010 
2013  {
2014  // Get the time
2015  Fw::Time _logTime;
2016  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2017  this->m_timeCaller_OutputPort[0].invoke(_logTime);
2018  }
2019 
2020  FwEventIdType _id = static_cast<FwEventIdType>(0);
2021 
2022  _id = this->getIdBase() + EVENTID_BL_DEACTIVATED;
2023 
2024  // Emit the event on the log port
2025  if (this->m_eventOut_OutputPort[0].isConnected()) {
2026  Fw::LogBuffer _logBuff;
2027 
2028 #if FW_AMPCS_COMPATIBLE
2030  // Serialize the number of arguments
2031  _status = _logBuff.serialize(static_cast<U8>(0));
2032  FW_ASSERT(
2033  _status == Fw::FW_SERIALIZE_OK,
2034  static_cast<FwAssertArgType>(_status)
2035  );
2036 #endif
2037 
2038  this->m_eventOut_OutputPort[0].invoke(
2039  _id,
2040  _logTime,
2042  _logBuff
2043  );
2044  }
2045 
2046  // Emit the event on the text log port
2047 #if FW_ENABLE_TEXT_LOGGING
2048  if (this->m_eventOutText_OutputPort[0].isConnected()) {
2049 #if FW_OBJECT_NAMES == 1
2050  const char* _formatString =
2051  "(%s) %s: Buffer logger was deactivated";
2052 #else
2053  const char* _formatString =
2054  "%s: Buffer logger was deactivated";
2055 #endif
2056 
2057  Fw::TextLogString _logString;
2058  _logString.format(
2059  _formatString,
2060 #if FW_OBJECT_NAMES == 1
2061  this->m_objName.toChar(),
2062 #endif
2063  "BL_Deactivated "
2064  );
2065 
2066  this->m_eventOutText_OutputPort[0].invoke(
2067  _id,
2068  _logTime,
2070  _logString
2071  );
2072  }
2073 #endif
2074  }
2075 
2078  {
2079  // Get the time
2080  Fw::Time _logTime;
2081  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2082  this->m_timeCaller_OutputPort[0].invoke(_logTime);
2083  }
2084 
2085  FwEventIdType _id = static_cast<FwEventIdType>(0);
2086 
2088 
2089  // Emit the event on the log port
2090  if (this->m_eventOut_OutputPort[0].isConnected()) {
2091  Fw::LogBuffer _logBuff;
2092 
2093 #if FW_AMPCS_COMPATIBLE
2095  // Serialize the number of arguments
2096  _status = _logBuff.serialize(static_cast<U8>(0));
2097  FW_ASSERT(
2098  _status == Fw::FW_SERIALIZE_OK,
2099  static_cast<FwAssertArgType>(_status)
2100  );
2101 #endif
2102 
2103  this->m_eventOut_OutputPort[0].invoke(
2104  _id,
2105  _logTime,
2107  _logBuff
2108  );
2109  }
2110 
2111  // Emit the event on the text log port
2112 #if FW_ENABLE_TEXT_LOGGING
2113  if (this->m_eventOutText_OutputPort[0].isConnected()) {
2114 #if FW_OBJECT_NAMES == 1
2115  const char* _formatString =
2116  "(%s) %s: No log file open command";
2117 #else
2118  const char* _formatString =
2119  "%s: No log file open command";
2120 #endif
2121 
2122  Fw::TextLogString _logString;
2123  _logString.format(
2124  _formatString,
2125 #if FW_OBJECT_NAMES == 1
2126  this->m_objName.toChar(),
2127 #endif
2128  "BL_NoLogFileOpenInitError "
2129  );
2130 
2131  this->m_eventOutText_OutputPort[0].invoke(
2132  _id,
2133  _logTime,
2135  _logString
2136  );
2137  }
2138 #endif
2139  }
2140 
2141  // ----------------------------------------------------------------------
2142  // Telemetry write functions
2143  // ----------------------------------------------------------------------
2144 
2147  U32 arg,
2148  Fw::Time _tlmTime
2149  ) const
2150  {
2151  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2152  if (
2153  this->m_timeCaller_OutputPort[0].isConnected() &&
2154  (_tlmTime == Fw::ZERO_TIME)
2155  ) {
2156  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2157  }
2158 
2159  Fw::TlmBuffer _tlmBuff;
2160  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2161  FW_ASSERT(
2162  _stat == Fw::FW_SERIALIZE_OK,
2163  static_cast<FwAssertArgType>(_stat)
2164  );
2165 
2166  FwChanIdType _id;
2167 
2169 
2170  this->m_tlmOut_OutputPort[0].invoke(
2171  _id,
2172  _tlmTime,
2173  _tlmBuff
2174  );
2175  }
2176  }
2177 
2178  // ----------------------------------------------------------------------
2179  // Time
2180  // ----------------------------------------------------------------------
2181 
2184  {
2185  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2186  Fw::Time _time;
2187  this->m_timeCaller_OutputPort[0].invoke(_time);
2188  return _time;
2189  }
2190  else {
2191  return Fw::Time(TB_NONE, 0, 0);
2192  }
2193  }
2194 
2195  // ----------------------------------------------------------------------
2196  // Message dispatch functions
2197  // ----------------------------------------------------------------------
2198 
2199  Fw::QueuedComponentBase::MsgDispatchStatus BufferLoggerComponentBase ::
2200  doDispatch()
2201  {
2202  ComponentIpcSerializableBuffer _msg;
2203  FwQueuePriorityType _priority = 0;
2204 
2205  Os::Queue::Status _msgStatus = this->m_queue.receive(
2206  _msg,
2208  _priority
2209  );
2210  FW_ASSERT(
2211  _msgStatus == Os::Queue::OP_OK,
2212  static_cast<FwAssertArgType>(_msgStatus)
2213  );
2214 
2215  // Reset to beginning of buffer
2216  _msg.resetDeser();
2217 
2218  FwEnumStoreType _desMsg = 0;
2219  Fw::SerializeStatus _deserStatus = _msg.deserialize(_desMsg);
2220  FW_ASSERT(
2221  _deserStatus == Fw::FW_SERIALIZE_OK,
2222  static_cast<FwAssertArgType>(_deserStatus)
2223  );
2224 
2225  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
2226 
2227  if (_msgType == BUFFERLOGGER_COMPONENT_EXIT) {
2228  return MSG_DISPATCH_EXIT;
2229  }
2230 
2231  FwIndexType portNum = 0;
2232  _deserStatus = _msg.deserialize(portNum);
2233  FW_ASSERT(
2234  _deserStatus == Fw::FW_SERIALIZE_OK,
2235  static_cast<FwAssertArgType>(_deserStatus)
2236  );
2237 
2238  switch (_msgType) {
2239  // Handle async input port bufferSendIn
2240  case BUFFERSENDIN_BUFFERSEND: {
2241  // Deserialize argument fwBuffer
2242  Fw::Buffer fwBuffer;
2243  _deserStatus = _msg.deserialize(fwBuffer);
2244  FW_ASSERT(
2245  _deserStatus == Fw::FW_SERIALIZE_OK,
2246  static_cast<FwAssertArgType>(_deserStatus)
2247  );
2248  // Call handler function
2249  this->bufferSendIn_handler(
2250  portNum,
2251  fwBuffer
2252  );
2253 
2254  break;
2255  }
2256 
2257  // Handle async input port comIn
2258  case COMIN_COM: {
2259  // Deserialize argument data
2260  Fw::ComBuffer data;
2261  _deserStatus = _msg.deserialize(data);
2262  FW_ASSERT(
2263  _deserStatus == Fw::FW_SERIALIZE_OK,
2264  static_cast<FwAssertArgType>(_deserStatus)
2265  );
2266 
2267  // Deserialize argument context
2268  U32 context;
2269  _deserStatus = _msg.deserialize(context);
2270  FW_ASSERT(
2271  _deserStatus == Fw::FW_SERIALIZE_OK,
2272  static_cast<FwAssertArgType>(_deserStatus)
2273  );
2274  // Call handler function
2275  this->comIn_handler(
2276  portNum,
2277  data,
2278  context
2279  );
2280 
2281  break;
2282  }
2283 
2284  // Handle async input port pingIn
2285  case PINGIN_PING: {
2286  // Deserialize argument key
2287  U32 key;
2288  _deserStatus = _msg.deserialize(key);
2289  FW_ASSERT(
2290  _deserStatus == Fw::FW_SERIALIZE_OK,
2291  static_cast<FwAssertArgType>(_deserStatus)
2292  );
2293  // Call handler function
2294  this->pingIn_handler(
2295  portNum,
2296  key
2297  );
2298 
2299  break;
2300  }
2301 
2302  // Handle async input port schedIn
2303  case SCHEDIN_SCHED: {
2304  // Deserialize argument context
2305  U32 context;
2306  _deserStatus = _msg.deserialize(context);
2307  FW_ASSERT(
2308  _deserStatus == Fw::FW_SERIALIZE_OK,
2309  static_cast<FwAssertArgType>(_deserStatus)
2310  );
2311  // Call handler function
2312  this->schedIn_handler(
2313  portNum,
2314  context
2315  );
2316 
2317  break;
2318  }
2319 
2320  // Handle command BL_OpenFile
2321  case CMD_BL_OPENFILE: {
2322  // Deserialize opcode
2323  FwOpcodeType _opCode = 0;
2324  _deserStatus = _msg.deserialize(_opCode);
2325  FW_ASSERT (
2326  _deserStatus == Fw::FW_SERIALIZE_OK,
2327  static_cast<FwAssertArgType>(_deserStatus)
2328  );
2329 
2330  // Deserialize command sequence
2331  U32 _cmdSeq = 0;
2332  _deserStatus = _msg.deserialize(_cmdSeq);
2333  FW_ASSERT (
2334  _deserStatus == Fw::FW_SERIALIZE_OK,
2335  static_cast<FwAssertArgType>(_deserStatus)
2336  );
2337 
2338  // Deserialize command argument buffer
2339  Fw::CmdArgBuffer args;
2340  _deserStatus = _msg.deserialize(args);
2341  FW_ASSERT (
2342  _deserStatus == Fw::FW_SERIALIZE_OK,
2343  static_cast<FwAssertArgType>(_deserStatus)
2344  );
2345 
2346  // Reset buffer
2347  args.resetDeser();
2348 
2349  // Deserialize argument file
2350  Fw::CmdStringArg file;
2351  _deserStatus = args.deserialize(file);
2352  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2353  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2354  this->cmdResponse_out(
2355  _opCode,
2356  _cmdSeq,
2358  );
2359  }
2360  // Don't crash the task if bad arguments were passed from the ground
2361  break;
2362  }
2363 
2364  // Make sure there was no data left over.
2365  // That means the argument buffer size was incorrect.
2366 #if FW_CMD_CHECK_RESIDUAL
2367  if (args.getBuffLeft() != 0) {
2368  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2369  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2370  }
2371  // Don't crash the task if bad arguments were passed from the ground
2372  break;
2373  }
2374 #endif
2375 
2376  // Call handler function
2377  this->BL_OpenFile_cmdHandler(
2378  _opCode, _cmdSeq,
2379  file
2380  );
2381 
2382  break;
2383  }
2384 
2385  // Handle command BL_CloseFile
2386  case CMD_BL_CLOSEFILE: {
2387  // Deserialize opcode
2388  FwOpcodeType _opCode = 0;
2389  _deserStatus = _msg.deserialize(_opCode);
2390  FW_ASSERT (
2391  _deserStatus == Fw::FW_SERIALIZE_OK,
2392  static_cast<FwAssertArgType>(_deserStatus)
2393  );
2394 
2395  // Deserialize command sequence
2396  U32 _cmdSeq = 0;
2397  _deserStatus = _msg.deserialize(_cmdSeq);
2398  FW_ASSERT (
2399  _deserStatus == Fw::FW_SERIALIZE_OK,
2400  static_cast<FwAssertArgType>(_deserStatus)
2401  );
2402 
2403  // Deserialize command argument buffer
2404  Fw::CmdArgBuffer args;
2405  _deserStatus = _msg.deserialize(args);
2406  FW_ASSERT (
2407  _deserStatus == Fw::FW_SERIALIZE_OK,
2408  static_cast<FwAssertArgType>(_deserStatus)
2409  );
2410 
2411  // Reset buffer
2412  args.resetDeser();
2413 
2414  // Make sure there was no data left over.
2415  // That means the argument buffer size was incorrect.
2416 #if FW_CMD_CHECK_RESIDUAL
2417  if (args.getBuffLeft() != 0) {
2418  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2419  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2420  }
2421  // Don't crash the task if bad arguments were passed from the ground
2422  break;
2423  }
2424 #endif
2425 
2426  // Call handler function
2427  this->BL_CloseFile_cmdHandler(_opCode, _cmdSeq);
2428 
2429  break;
2430  }
2431 
2432  // Handle command BL_SetLogging
2433  case CMD_BL_SETLOGGING: {
2434  // Deserialize opcode
2435  FwOpcodeType _opCode = 0;
2436  _deserStatus = _msg.deserialize(_opCode);
2437  FW_ASSERT (
2438  _deserStatus == Fw::FW_SERIALIZE_OK,
2439  static_cast<FwAssertArgType>(_deserStatus)
2440  );
2441 
2442  // Deserialize command sequence
2443  U32 _cmdSeq = 0;
2444  _deserStatus = _msg.deserialize(_cmdSeq);
2445  FW_ASSERT (
2446  _deserStatus == Fw::FW_SERIALIZE_OK,
2447  static_cast<FwAssertArgType>(_deserStatus)
2448  );
2449 
2450  // Deserialize command argument buffer
2451  Fw::CmdArgBuffer args;
2452  _deserStatus = _msg.deserialize(args);
2453  FW_ASSERT (
2454  _deserStatus == Fw::FW_SERIALIZE_OK,
2455  static_cast<FwAssertArgType>(_deserStatus)
2456  );
2457 
2458  // Reset buffer
2459  args.resetDeser();
2460 
2461  // Deserialize argument state
2463  _deserStatus = args.deserialize(state);
2464  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2465  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2466  this->cmdResponse_out(
2467  _opCode,
2468  _cmdSeq,
2470  );
2471  }
2472  // Don't crash the task if bad arguments were passed from the ground
2473  break;
2474  }
2475 
2476  // Make sure there was no data left over.
2477  // That means the argument buffer size was incorrect.
2478 #if FW_CMD_CHECK_RESIDUAL
2479  if (args.getBuffLeft() != 0) {
2480  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2481  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2482  }
2483  // Don't crash the task if bad arguments were passed from the ground
2484  break;
2485  }
2486 #endif
2487 
2488  // Call handler function
2490  _opCode, _cmdSeq,
2491  state
2492  );
2493 
2494  break;
2495  }
2496 
2497  // Handle command BL_FlushFile
2498  case CMD_BL_FLUSHFILE: {
2499  // Deserialize opcode
2500  FwOpcodeType _opCode = 0;
2501  _deserStatus = _msg.deserialize(_opCode);
2502  FW_ASSERT (
2503  _deserStatus == Fw::FW_SERIALIZE_OK,
2504  static_cast<FwAssertArgType>(_deserStatus)
2505  );
2506 
2507  // Deserialize command sequence
2508  U32 _cmdSeq = 0;
2509  _deserStatus = _msg.deserialize(_cmdSeq);
2510  FW_ASSERT (
2511  _deserStatus == Fw::FW_SERIALIZE_OK,
2512  static_cast<FwAssertArgType>(_deserStatus)
2513  );
2514 
2515  // Deserialize command argument buffer
2516  Fw::CmdArgBuffer args;
2517  _deserStatus = _msg.deserialize(args);
2518  FW_ASSERT (
2519  _deserStatus == Fw::FW_SERIALIZE_OK,
2520  static_cast<FwAssertArgType>(_deserStatus)
2521  );
2522 
2523  // Reset buffer
2524  args.resetDeser();
2525 
2526  // Make sure there was no data left over.
2527  // That means the argument buffer size was incorrect.
2528 #if FW_CMD_CHECK_RESIDUAL
2529  if (args.getBuffLeft() != 0) {
2530  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2531  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2532  }
2533  // Don't crash the task if bad arguments were passed from the ground
2534  break;
2535  }
2536 #endif
2537 
2538  // Call handler function
2539  this->BL_FlushFile_cmdHandler(_opCode, _cmdSeq);
2540 
2541  break;
2542  }
2543 
2544  default:
2545  return MSG_DISPATCH_ERROR;
2546  }
2547 
2548  return MSG_DISPATCH_OK;
2549  }
2550 
2551  // ----------------------------------------------------------------------
2552  // Calls for messages received on special input ports
2553  // ----------------------------------------------------------------------
2554 
2555  void BufferLoggerComponentBase ::
2556  m_p_cmdIn_in(
2557  Fw::PassiveComponentBase* callComp,
2558  FwIndexType portNum,
2559  FwOpcodeType opCode,
2560  U32 cmdSeq,
2561  Fw::CmdArgBuffer& args
2562  )
2563  {
2564  FW_ASSERT(callComp);
2565  BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2566 
2567  const U32 idBase = callComp->getIdBase();
2568  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
2569 
2570  // Select base class function based on opcode
2571  switch (opCode - idBase) {
2572  case OPCODE_BL_OPENFILE: {
2573  compPtr->BL_OpenFile_cmdHandlerBase(
2574  opCode,
2575  cmdSeq,
2576  args
2577  );
2578  break;
2579  }
2580 
2581  case OPCODE_BL_CLOSEFILE: {
2582  compPtr->BL_CloseFile_cmdHandlerBase(
2583  opCode,
2584  cmdSeq,
2585  args
2586  );
2587  break;
2588  }
2589 
2590  case OPCODE_BL_SETLOGGING: {
2591  compPtr->BL_SetLogging_cmdHandlerBase(
2592  opCode,
2593  cmdSeq,
2594  args
2595  );
2596  break;
2597  }
2598 
2599  case OPCODE_BL_FLUSHFILE: {
2600  compPtr->BL_FlushFile_cmdHandlerBase(
2601  opCode,
2602  cmdSeq,
2603  args
2604  );
2605  break;
2606  }
2607  }
2608  }
2609 
2610  // ----------------------------------------------------------------------
2611  // Calls for messages received on typed input ports
2612  // ----------------------------------------------------------------------
2613 
2614  void BufferLoggerComponentBase ::
2615  m_p_bufferSendIn_in(
2616  Fw::PassiveComponentBase* callComp,
2617  FwIndexType portNum,
2618  Fw::Buffer& fwBuffer
2619  )
2620  {
2621  FW_ASSERT(callComp);
2622  BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2623  compPtr->bufferSendIn_handlerBase(
2624  portNum,
2625  fwBuffer
2626  );
2627  }
2628 
2629  void BufferLoggerComponentBase ::
2630  m_p_comIn_in(
2631  Fw::PassiveComponentBase* callComp,
2632  FwIndexType portNum,
2633  Fw::ComBuffer& data,
2634  U32 context
2635  )
2636  {
2637  FW_ASSERT(callComp);
2638  BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2639  compPtr->comIn_handlerBase(
2640  portNum,
2641  data,
2642  context
2643  );
2644  }
2645 
2646  void BufferLoggerComponentBase ::
2647  m_p_pingIn_in(
2648  Fw::PassiveComponentBase* callComp,
2649  FwIndexType portNum,
2650  U32 key
2651  )
2652  {
2653  FW_ASSERT(callComp);
2654  BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2655  compPtr->pingIn_handlerBase(
2656  portNum,
2657  key
2658  );
2659  }
2660 
2661  void BufferLoggerComponentBase ::
2662  m_p_schedIn_in(
2663  Fw::PassiveComponentBase* callComp,
2664  FwIndexType portNum,
2665  U32 context
2666  )
2667  {
2668  FW_ASSERT(callComp);
2669  BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2670  compPtr->schedIn_handlerBase(
2671  portNum,
2672  context
2673  );
2674  }
2675 
2676 }
Serialization/Deserialization operation was successful.
void BL_SetLogging_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
The Buffer Logger encountered an error writing to a log file.
Definition: Time.hpp:9
void regCommands()
Register commands with the Command Dispatcher.
virtual void bufferSendIn_preMsgHook(FwIndexType portNum, Fw::Buffer &fwBuffer)
Pre-message hook for async input port bufferSendIn.
Operation succeeded.
Definition: Os.hpp:26
Svc::InputSchedPort * get_schedIn_InputPort(FwIndexType portNum)
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum)
virtual void schedIn_preMsgHook(FwIndexType portNum, U32 context)
Pre-message hook for async input port schedIn.
Status
status returned from the queue send function
Definition: Queue.hpp:30
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
void set_tlmOut_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to tlmOut[portNum].
void init()
Initialization function.
Definition: SchedPortAc.cpp:56
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
void init()
Initialization function.
Definition: CmdPortAc.cpp:56
void pingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port pingIn.
virtual void BL_SetLogging_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command BL_SetLogging.
virtual void BL_CloseFile_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command BL_CloseFile.
bool isConnected_timeCaller_OutputPort(FwIndexType portNum)
PlatformSizeType FwSizeType
Definition: FpConfig.h:35
void invoke(U32 key) const
Invoke a port interface.
Definition: PingPortAc.cpp:147
const Time ZERO_TIME
Definition: Time.cpp:5
virtual void BL_SetLogging_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::BufferLogger_LogState state)=0
virtual void BL_OpenFile_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command BL_OpenFile.
virtual void BL_FlushFile_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command BL_FlushFile.
virtual void bufferSendIn_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port bufferSendIn.
void BL_OpenFile_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
bool isConnected_pingOut_OutputPort(FwIndexType portNum)
I32 FwEnumStoreType
Definition: FpConfig.h:64
bool isConnected_tlmOut_OutputPort(FwIndexType portNum)
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
void log_DIAGNOSTIC_BL_LogFileClosed(const Fw::StringBase &file) const
Enum representing a command response.
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
PlatformIndexType FwIndexType
Definition: FpConfig.h:25
bool isConnected_eventOut_OutputPort(FwIndexType portNum)
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:37
Os::Queue m_queue
queue object for active component
Software diagnostic events.
Close the currently open log file, if any.
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
void bufferSendIn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferSendIn.
The Buffer Logger encountered an error writing a validation file.
void init()
Object initializer.
Definition: ObjBase.cpp:26
void init()
Initialization function.
Definition: ComPortAc.cpp:56
SerializeStatus
forward declaration for string
virtual void comIn_handler(FwIndexType portNum, Fw::ComBuffer &data, U32 context)=0
Handler for input port comIn.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CmdPortAc.cpp:62
FwIndexType getNum_bufferSendOut_OutputPorts() const
Message will block until space is available.
Definition: Queue.hpp:46
void log_WARNING_HI_BL_LogFileOpenError(U32 errornum, const Fw::StringBase &file) const
Open a new log file with specified name; also resets unique file counter to 0.
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
bool isConnected_bufferSendOut_OutputPort(FwIndexType portNum)
virtual void comIn_preMsgHook(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Pre-message hook for async input port comIn.
void invoke(FwOpcodeType opCode) const
Invoke a port interface.
void set_bufferSendOut_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to bufferSendOut[portNum].
Fw::InputCmdPort * get_cmdIn_InputPort(FwIndexType portNum)
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
void init()
Initialization function.
Definition: TimePortAc.cpp:128
message to exit active component task
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: ComPortAc.cpp:62
Less important informational events.
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
#define FW_MIN(a, b)
MIN macro.
Definition: BasicTypes.h:87
void invoke(Fw::Buffer &fwBuffer) const
Invoke a port interface.
void init()
Initialization function.
Definition: PingPortAc.cpp:128
void tlmWrite_BufferLogger_NumLoggedBuffers(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void init()
Initialization function.
void addCallPort(InputBufferSendPort *callPort)
Register an input port.
void invoke(Fw::Time &time) const
Invoke a port interface.
Definition: TimePortAc.cpp:147
virtual void BL_FlushFile_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
U32 FwOpcodeType
Definition: FpConfig.h:91
The size of the serial representations of the port arguments.
const char * toChar() const
Definition: ObjectName.hpp:50
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke a port interface.
No time base has been established.
Definition: FpConfig.h:70
FwSizeType SizeType
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:134
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
void BL_CloseFile_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
void log_WARNING_HI_BL_LogFileWriteError(U32 errornum, U32 bytesWritten, U32 bytesToWrite, const Fw::StringBase &file) const
BufferLoggerComponentBase(const char *compName="")
Construct BufferLoggerComponentBase object.
virtual void schedIn_handler(FwIndexType portNum, U32 context)=0
Handler for input port schedIn.
void resetDeser()
reset deserialization to beginning
A serious but recoverable event.
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke a port interface.
Definition: TlmPortAc.cpp:163
bool isConnected() const
Definition: PortBase.cpp:42
Fw::InputBufferSendPort * get_bufferSendIn_InputPort(FwIndexType portNum)
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
U32 FwEventIdType
Definition: FpConfig.h:103
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:32
BlockingType
message type
Definition: Queue.hpp:45
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
FwIndexType getNum_bufferSendIn_InputPorts() const
Fw::InputComPort * get_comIn_InputPort(FwIndexType portNum)
Command failed to deserialize.
The size of the serial representations of the port arguments.
Definition: SchedPortAc.hpp:36
The Buffer Logger encountered an error opening a log file.
void init()
Initialization function.
void comIn_handlerBase(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port comIn.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: SchedPortAc.cpp:62
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port interface.
Definition: LogPortAc.cpp:170
Flushes the current open log file to disk; a no-op with fprime&#39;s unbuffered file I/O, so always returns success.
PlatformQueuePriorityType FwQueuePriorityType
Definition: FpConfig.h:55
void bufferSendOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port bufferSendOut.
virtual void pingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port pingIn.
A message was sent requesting an exit of the loop.
virtual ~BufferLoggerComponentBase()
Destroy BufferLoggerComponentBase object.
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:85
The size of the serial representations of the port arguments.
Definition: ComPortAc.hpp:37
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
void init()
Initialization function.
void init()
Initialization function.
Definition: PingPortAc.cpp:56
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:35
No log file open command was received by BufferLogger.
FwIndexType getNum_cmdResponseOut_OutputPorts() const
virtual SerializeStatus serialize(SerializeBufferBase &buffer) const
serialization function
Definition: StringBase.cpp:142
void BL_FlushFile_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
bool isConnected_cmdRegOut_OutputPort(FwIndexType portNum)
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:62
void set_timeCaller_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
void set_eventOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
Message will return with status when space is unavailable.
Definition: Queue.hpp:47
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
void schedIn_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port schedIn.
void init()
Initialization function.
virtual void BL_CloseFile_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:148
virtual void BL_OpenFile_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg &file)=0
#define FW_ASSERT(...)
Definition: Assert.hpp:14
#define FW_LOG_STRING_MAX_SIZE
Max size of log string parameter type.
Definition: FpConfig.h:319
virtual const CHAR * toChar() const =0
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
U32 FwChanIdType
Definition: FpConfig.h:95
void log_WARNING_HI_BL_LogFileValidationError(const Fw::StringBase &validationFile, U32 status) const
void set_cmdRegOut_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegOut[portNum].