F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
ComLoggerComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ComLoggerComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for ComLogger component base class
5 // ======================================================================
6 
7 #include <cstdio>
8 
10 #include "Fw/Types/Assert.hpp"
11 #if FW_ENABLE_TEXT_LOGGING
12 #include "Fw/Types/String.hpp"
13 #endif
14 
15 namespace Svc {
16 
17  namespace {
18  enum MsgTypeEnum {
19  COMLOGGER_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
20  COMIN_COM,
21  PINGIN_PING,
22  CMD_CLOSEFILE,
23  };
24 
25  // Get the max size by constructing a union of the async input, command, and
26  // internal port serialization sizes
27  union BuffUnion {
31  };
32 
33  // Define a message buffer class large enough to handle all the
34  // asynchronous inputs to the component
35  class ComponentIpcSerializableBuffer :
37  {
38 
39  public:
40 
41  enum {
42  // Max. message size = size of data + message id + port
43  SERIALIZATION_SIZE =
44  sizeof(BuffUnion) +
45  sizeof(NATIVE_INT_TYPE) +
46  sizeof(NATIVE_INT_TYPE)
47  };
48 
49  NATIVE_UINT_TYPE getBuffCapacity() 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 
73  init(
74  NATIVE_INT_TYPE queueDepth,
75  NATIVE_INT_TYPE instance
76  )
77  {
78  // Initialize base class
80 
81  // Connect input port cmdIn
82  for (
83  PlatformIntType port = 0;
84  port < static_cast<PlatformIntType>(this->getNum_cmdIn_InputPorts());
85  port++
86  ) {
87  this->m_cmdIn_InputPort[port].init();
88  this->m_cmdIn_InputPort[port].addCallComp(
89  this,
90  m_p_cmdIn_in
91  );
92  this->m_cmdIn_InputPort[port].setPortNum(port);
93 
94 #if FW_OBJECT_NAMES == 1
95  // The port name consists of this->m_objName and some extra info.
96  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
97  // However, the compiler may assume that this->m_objName fills
98  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
99  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
100  // bytes to cover the extra info.
101  char portName[2*FW_OBJ_NAME_MAX_SIZE];
102  (void) snprintf(
103  portName,
104  sizeof(portName),
105  "%s_cmdIn_InputPort[%" PRI_PlatformIntType "]",
106  this->m_objName,
107  port
108  );
109  this->m_cmdIn_InputPort[port].setObjName(portName);
110 #endif
111  }
112 
113  // Connect input port comIn
114  for (
115  PlatformIntType port = 0;
116  port < static_cast<PlatformIntType>(this->getNum_comIn_InputPorts());
117  port++
118  ) {
119  this->m_comIn_InputPort[port].init();
120  this->m_comIn_InputPort[port].addCallComp(
121  this,
122  m_p_comIn_in
123  );
124  this->m_comIn_InputPort[port].setPortNum(port);
125 
126 #if FW_OBJECT_NAMES == 1
127  // The port name consists of this->m_objName and some extra info.
128  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
129  // However, the compiler may assume that this->m_objName fills
130  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
131  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
132  // bytes to cover the extra info.
133  char portName[2*FW_OBJ_NAME_MAX_SIZE];
134  (void) snprintf(
135  portName,
136  sizeof(portName),
137  "%s_comIn_InputPort[%" PRI_PlatformIntType "]",
138  this->m_objName,
139  port
140  );
141  this->m_comIn_InputPort[port].setObjName(portName);
142 #endif
143  }
144 
145  // Connect input port pingIn
146  for (
147  PlatformIntType port = 0;
148  port < static_cast<PlatformIntType>(this->getNum_pingIn_InputPorts());
149  port++
150  ) {
151  this->m_pingIn_InputPort[port].init();
152  this->m_pingIn_InputPort[port].addCallComp(
153  this,
154  m_p_pingIn_in
155  );
156  this->m_pingIn_InputPort[port].setPortNum(port);
157 
158 #if FW_OBJECT_NAMES == 1
159  // The port name consists of this->m_objName and some extra info.
160  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
161  // However, the compiler may assume that this->m_objName fills
162  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
163  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
164  // bytes to cover the extra info.
165  char portName[2*FW_OBJ_NAME_MAX_SIZE];
166  (void) snprintf(
167  portName,
168  sizeof(portName),
169  "%s_pingIn_InputPort[%" PRI_PlatformIntType "]",
170  this->m_objName,
171  port
172  );
173  this->m_pingIn_InputPort[port].setObjName(portName);
174 #endif
175  }
176 
177 #if FW_ENABLE_TEXT_LOGGING == 1
178  // Connect output port LogText
179  for (
180  PlatformIntType port = 0;
181  port < static_cast<PlatformIntType>(this->getNum_LogText_OutputPorts());
182  port++
183  ) {
184  this->m_LogText_OutputPort[port].init();
185 
186 #if FW_OBJECT_NAMES == 1
187  // The port name consists of this->m_objName and some extra info.
188  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
189  // However, the compiler may assume that this->m_objName fills
190  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
191  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
192  // bytes to cover the extra info.
193  char portName[2*FW_OBJ_NAME_MAX_SIZE];
194  (void) snprintf(
195  portName,
196  sizeof(portName),
197  "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
198  this->m_objName,
199  port
200  );
201  this->m_LogText_OutputPort[port].setObjName(portName);
202 #endif
203  }
204 #endif
205 
206  // Connect output port cmdRegOut
207  for (
208  PlatformIntType port = 0;
209  port < static_cast<PlatformIntType>(this->getNum_cmdRegOut_OutputPorts());
210  port++
211  ) {
212  this->m_cmdRegOut_OutputPort[port].init();
213 
214 #if FW_OBJECT_NAMES == 1
215  // The port name consists of this->m_objName and some extra info.
216  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
217  // However, the compiler may assume that this->m_objName fills
218  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
219  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
220  // bytes to cover the extra info.
221  char portName[2*FW_OBJ_NAME_MAX_SIZE];
222  (void) snprintf(
223  portName,
224  sizeof(portName),
225  "%s_cmdRegOut_OutputPort[%" PRI_PlatformIntType "]",
226  this->m_objName,
227  port
228  );
229  this->m_cmdRegOut_OutputPort[port].setObjName(portName);
230 #endif
231  }
232 
233  // Connect output port cmdResponseOut
234  for (
235  PlatformIntType port = 0;
236  port < static_cast<PlatformIntType>(this->getNum_cmdResponseOut_OutputPorts());
237  port++
238  ) {
239  this->m_cmdResponseOut_OutputPort[port].init();
240 
241 #if FW_OBJECT_NAMES == 1
242  // The port name consists of this->m_objName and some extra info.
243  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
244  // However, the compiler may assume that this->m_objName fills
245  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
246  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
247  // bytes to cover the extra info.
248  char portName[2*FW_OBJ_NAME_MAX_SIZE];
249  (void) snprintf(
250  portName,
251  sizeof(portName),
252  "%s_cmdResponseOut_OutputPort[%" PRI_PlatformIntType "]",
253  this->m_objName,
254  port
255  );
256  this->m_cmdResponseOut_OutputPort[port].setObjName(portName);
257 #endif
258  }
259 
260  // Connect output port logOut
261  for (
262  PlatformIntType port = 0;
263  port < static_cast<PlatformIntType>(this->getNum_logOut_OutputPorts());
264  port++
265  ) {
266  this->m_logOut_OutputPort[port].init();
267 
268 #if FW_OBJECT_NAMES == 1
269  // The port name consists of this->m_objName and some extra info.
270  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
271  // However, the compiler may assume that this->m_objName fills
272  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
273  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
274  // bytes to cover the extra info.
275  char portName[2*FW_OBJ_NAME_MAX_SIZE];
276  (void) snprintf(
277  portName,
278  sizeof(portName),
279  "%s_logOut_OutputPort[%" PRI_PlatformIntType "]",
280  this->m_objName,
281  port
282  );
283  this->m_logOut_OutputPort[port].setObjName(portName);
284 #endif
285  }
286 
287  // Connect output port timeCaller
288  for (
289  PlatformIntType port = 0;
290  port < static_cast<PlatformIntType>(this->getNum_timeCaller_OutputPorts());
291  port++
292  ) {
293  this->m_timeCaller_OutputPort[port].init();
294 
295 #if FW_OBJECT_NAMES == 1
296  // The port name consists of this->m_objName and some extra info.
297  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
298  // However, the compiler may assume that this->m_objName fills
299  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
300  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
301  // bytes to cover the extra info.
302  char portName[2*FW_OBJ_NAME_MAX_SIZE];
303  (void) snprintf(
304  portName,
305  sizeof(portName),
306  "%s_timeCaller_OutputPort[%" PRI_PlatformIntType "]",
307  this->m_objName,
308  port
309  );
310  this->m_timeCaller_OutputPort[port].setObjName(portName);
311 #endif
312  }
313 
314  // Connect output port pingOut
315  for (
316  PlatformIntType port = 0;
317  port < static_cast<PlatformIntType>(this->getNum_pingOut_OutputPorts());
318  port++
319  ) {
320  this->m_pingOut_OutputPort[port].init();
321 
322 #if FW_OBJECT_NAMES == 1
323  // The port name consists of this->m_objName and some extra info.
324  // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
325  // However, the compiler may assume that this->m_objName fills
326  // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
327  // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
328  // bytes to cover the extra info.
329  char portName[2*FW_OBJ_NAME_MAX_SIZE];
330  (void) snprintf(
331  portName,
332  sizeof(portName),
333  "%s_pingOut_OutputPort[%" PRI_PlatformIntType "]",
334  this->m_objName,
335  port
336  );
337  this->m_pingOut_OutputPort[port].setObjName(portName);
338 #endif
339  }
340 
341  Os::Queue::QueueStatus qStat = this->createQueue(
342  queueDepth,
343  ComponentIpcSerializableBuffer::SERIALIZATION_SIZE
344  );
345  FW_ASSERT(
346  Os::Queue::QUEUE_OK == qStat,
347  static_cast<FwAssertArgType>(qStat)
348  );
349  }
350 
351  // ----------------------------------------------------------------------
352  // Getters for special input ports
353  // ----------------------------------------------------------------------
354 
357  {
358  FW_ASSERT(
359  portNum < this->getNum_cmdIn_InputPorts(),
360  static_cast<FwAssertArgType>(portNum)
361  );
362 
363  return &this->m_cmdIn_InputPort[portNum];
364  }
365 
366  // ----------------------------------------------------------------------
367  // Getters for typed input ports
368  // ----------------------------------------------------------------------
369 
372  {
373  FW_ASSERT(
374  portNum < this->getNum_comIn_InputPorts(),
375  static_cast<FwAssertArgType>(portNum)
376  );
377 
378  return &this->m_comIn_InputPort[portNum];
379  }
380 
383  {
384  FW_ASSERT(
385  portNum < this->getNum_pingIn_InputPorts(),
386  static_cast<FwAssertArgType>(portNum)
387  );
388 
389  return &this->m_pingIn_InputPort[portNum];
390  }
391 
392  // ----------------------------------------------------------------------
393  // Connect input ports to special output ports
394  // ----------------------------------------------------------------------
395 
396 #if FW_ENABLE_TEXT_LOGGING == 1
397 
398  void ComLoggerComponentBase ::
399  set_LogText_OutputPort(
400  NATIVE_INT_TYPE portNum,
402  )
403  {
404  FW_ASSERT(
405  portNum < this->getNum_LogText_OutputPorts(),
406  static_cast<FwAssertArgType>(portNum)
407  );
408 
409  this->m_LogText_OutputPort[portNum].addCallPort(port);
410  }
411 
412 #endif
413 
416  NATIVE_INT_TYPE portNum,
417  Fw::InputCmdRegPort* port
418  )
419  {
420  FW_ASSERT(
421  portNum < this->getNum_cmdRegOut_OutputPorts(),
422  static_cast<FwAssertArgType>(portNum)
423  );
424 
425  this->m_cmdRegOut_OutputPort[portNum].addCallPort(port);
426  }
427 
430  NATIVE_INT_TYPE portNum,
432  )
433  {
434  FW_ASSERT(
435  portNum < this->getNum_cmdResponseOut_OutputPorts(),
436  static_cast<FwAssertArgType>(portNum)
437  );
438 
439  this->m_cmdResponseOut_OutputPort[portNum].addCallPort(port);
440  }
441 
444  NATIVE_INT_TYPE portNum,
445  Fw::InputLogPort* port
446  )
447  {
448  FW_ASSERT(
449  portNum < this->getNum_logOut_OutputPorts(),
450  static_cast<FwAssertArgType>(portNum)
451  );
452 
453  this->m_logOut_OutputPort[portNum].addCallPort(port);
454  }
455 
458  NATIVE_INT_TYPE portNum,
459  Fw::InputTimePort* port
460  )
461  {
462  FW_ASSERT(
463  portNum < this->getNum_timeCaller_OutputPorts(),
464  static_cast<FwAssertArgType>(portNum)
465  );
466 
467  this->m_timeCaller_OutputPort[portNum].addCallPort(port);
468  }
469 
470  // ----------------------------------------------------------------------
471  // Connect typed input ports to typed output ports
472  // ----------------------------------------------------------------------
473 
476  NATIVE_INT_TYPE portNum,
477  Svc::InputPingPort* port
478  )
479  {
480  FW_ASSERT(
481  portNum < this->getNum_pingOut_OutputPorts(),
482  static_cast<FwAssertArgType>(portNum)
483  );
484 
485  this->m_pingOut_OutputPort[portNum].addCallPort(port);
486  }
487 
488 #if FW_PORT_SERIALIZATION
489 
490  // ----------------------------------------------------------------------
491  // Connect serial input ports to special output ports
492  // ----------------------------------------------------------------------
493 
494 #if FW_ENABLE_TEXT_LOGGING == 1
495 
496  void ComLoggerComponentBase ::
497  set_LogText_OutputPort(
498  NATIVE_INT_TYPE portNum,
499  Fw::InputSerializePort* port
500  )
501  {
502  FW_ASSERT(
503  portNum < this->getNum_LogText_OutputPorts(),
504  static_cast<FwAssertArgType>(portNum)
505  );
506 
507  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
508  }
509 
510 #endif
511 
514  NATIVE_INT_TYPE portNum,
515  Fw::InputSerializePort* port
516  )
517  {
518  FW_ASSERT(
519  portNum < this->getNum_cmdRegOut_OutputPorts(),
520  static_cast<FwAssertArgType>(portNum)
521  );
522 
523  this->m_cmdRegOut_OutputPort[portNum].registerSerialPort(port);
524  }
525 
528  NATIVE_INT_TYPE portNum,
529  Fw::InputSerializePort* port
530  )
531  {
532  FW_ASSERT(
533  portNum < this->getNum_cmdResponseOut_OutputPorts(),
534  static_cast<FwAssertArgType>(portNum)
535  );
536 
537  this->m_cmdResponseOut_OutputPort[portNum].registerSerialPort(port);
538  }
539 
542  NATIVE_INT_TYPE portNum,
543  Fw::InputSerializePort* port
544  )
545  {
546  FW_ASSERT(
547  portNum < this->getNum_logOut_OutputPorts(),
548  static_cast<FwAssertArgType>(portNum)
549  );
550 
551  this->m_logOut_OutputPort[portNum].registerSerialPort(port);
552  }
553 
556  NATIVE_INT_TYPE portNum,
557  Fw::InputSerializePort* port
558  )
559  {
560  FW_ASSERT(
561  portNum < this->getNum_timeCaller_OutputPorts(),
562  static_cast<FwAssertArgType>(portNum)
563  );
564 
565  this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
566  }
567 
568 #endif
569 
570 #if FW_PORT_SERIALIZATION
571 
572  // ----------------------------------------------------------------------
573  // Connect serial input ports to typed output ports
574  // ----------------------------------------------------------------------
575 
578  NATIVE_INT_TYPE portNum,
579  Fw::InputSerializePort* port
580  )
581  {
582  FW_ASSERT(
583  portNum < this->getNum_pingOut_OutputPorts(),
584  static_cast<FwAssertArgType>(portNum)
585  );
586 
587  this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
588  }
589 
590 #endif
591 
592  // ----------------------------------------------------------------------
593  // Command registration
594  // ----------------------------------------------------------------------
595 
597  regCommands()
598  {
599  FW_ASSERT(this->m_cmdRegOut_OutputPort[0].isConnected());
600 
601  this->m_cmdRegOut_OutputPort[0].invoke(
602  this->getIdBase() + OPCODE_CLOSEFILE
603  );
604  }
605 
606  // ----------------------------------------------------------------------
607  // Component construction and destruction
608  // ----------------------------------------------------------------------
609 
611  ComLoggerComponentBase(const char* compName) :
612  Fw::ActiveComponentBase(compName)
613  {
614  this->m_FileNotInitializedThrottle = 0;
615  }
616 
619  {
620 
621  }
622 
623  // ----------------------------------------------------------------------
624  // Getters for numbers of special input ports
625  // ----------------------------------------------------------------------
626 
629  {
630  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdIn_InputPort));
631  }
632 
633  // ----------------------------------------------------------------------
634  // Getters for numbers of typed input ports
635  // ----------------------------------------------------------------------
636 
639  {
640  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_comIn_InputPort));
641  }
642 
645  {
646  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_pingIn_InputPort));
647  }
648 
649  // ----------------------------------------------------------------------
650  // Getters for numbers of special output ports
651  // ----------------------------------------------------------------------
652 
653 #if FW_ENABLE_TEXT_LOGGING == 1
654 
655  NATIVE_INT_TYPE ComLoggerComponentBase ::
656  getNum_LogText_OutputPorts() const
657  {
658  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
659  }
660 
661 #endif
662 
665  {
666  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdRegOut_OutputPort));
667  }
668 
671  {
672  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdResponseOut_OutputPort));
673  }
674 
677  {
678  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_logOut_OutputPort));
679  }
680 
683  {
684  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_timeCaller_OutputPort));
685  }
686 
687  // ----------------------------------------------------------------------
688  // Getters for numbers of typed output ports
689  // ----------------------------------------------------------------------
690 
693  {
694  return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_pingOut_OutputPort));
695  }
696 
697  // ----------------------------------------------------------------------
698  // Connection status queries for special output ports
699  // ----------------------------------------------------------------------
700 
701 #if FW_ENABLE_TEXT_LOGGING == 1
702 
703  bool ComLoggerComponentBase ::
704  isConnected_LogText_OutputPort(NATIVE_INT_TYPE portNum)
705  {
706  FW_ASSERT(
707  portNum < this->getNum_LogText_OutputPorts(),
708  static_cast<FwAssertArgType>(portNum)
709  );
710 
711  return this->m_LogText_OutputPort[portNum].isConnected();
712  }
713 
714 #endif
715 
718  {
719  FW_ASSERT(
720  portNum < this->getNum_cmdRegOut_OutputPorts(),
721  static_cast<FwAssertArgType>(portNum)
722  );
723 
724  return this->m_cmdRegOut_OutputPort[portNum].isConnected();
725  }
726 
729  {
730  FW_ASSERT(
731  portNum < this->getNum_cmdResponseOut_OutputPorts(),
732  static_cast<FwAssertArgType>(portNum)
733  );
734 
735  return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
736  }
737 
740  {
741  FW_ASSERT(
742  portNum < this->getNum_logOut_OutputPorts(),
743  static_cast<FwAssertArgType>(portNum)
744  );
745 
746  return this->m_logOut_OutputPort[portNum].isConnected();
747  }
748 
751  {
752  FW_ASSERT(
753  portNum < this->getNum_timeCaller_OutputPorts(),
754  static_cast<FwAssertArgType>(portNum)
755  );
756 
757  return this->m_timeCaller_OutputPort[portNum].isConnected();
758  }
759 
760  // ----------------------------------------------------------------------
761  // Connection status queries for typed output ports
762  // ----------------------------------------------------------------------
763 
766  {
767  FW_ASSERT(
768  portNum < this->getNum_pingOut_OutputPorts(),
769  static_cast<FwAssertArgType>(portNum)
770  );
771 
772  return this->m_pingOut_OutputPort[portNum].isConnected();
773  }
774 
775  // ----------------------------------------------------------------------
776  // Port handler base-class functions for typed input ports
777  //
778  // Call these functions directly to bypass the corresponding ports
779  // ----------------------------------------------------------------------
780 
783  NATIVE_INT_TYPE portNum,
784  Fw::ComBuffer& data,
785  U32 context
786  )
787  {
788  // Make sure port number is valid
789  FW_ASSERT(
790  portNum < this->getNum_comIn_InputPorts(),
791  static_cast<FwAssertArgType>(portNum)
792  );
793 
794  // Call pre-message hook
796  portNum,
797  data,
798  context
799  );
800  ComponentIpcSerializableBuffer msg;
802 
803  // Serialize message ID
804  _status = msg.serialize(
805  static_cast<NATIVE_INT_TYPE>(COMIN_COM)
806  );
807  FW_ASSERT(
808  _status == Fw::FW_SERIALIZE_OK,
809  static_cast<FwAssertArgType>(_status)
810  );
811 
812  // Serialize port number
813  _status = msg.serialize(portNum);
814  FW_ASSERT(
815  _status == Fw::FW_SERIALIZE_OK,
816  static_cast<FwAssertArgType>(_status)
817  );
818 
819  // Serialize argument data
820  _status = msg.serialize(data);
821  FW_ASSERT(
822  _status == Fw::FW_SERIALIZE_OK,
823  static_cast<FwAssertArgType>(_status)
824  );
825 
826  // Serialize argument context
827  _status = msg.serialize(context);
828  FW_ASSERT(
829  _status == Fw::FW_SERIALIZE_OK,
830  static_cast<FwAssertArgType>(_status)
831  );
832 
833  // Send message
835  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
836 
837  FW_ASSERT(
838  qStatus == Os::Queue::QUEUE_OK,
839  static_cast<FwAssertArgType>(qStatus)
840  );
841  }
842 
845  NATIVE_INT_TYPE portNum,
846  U32 key
847  )
848  {
849  // Make sure port number is valid
850  FW_ASSERT(
851  portNum < this->getNum_pingIn_InputPorts(),
852  static_cast<FwAssertArgType>(portNum)
853  );
854 
855  // Call pre-message hook
857  portNum,
858  key
859  );
860  ComponentIpcSerializableBuffer msg;
862 
863  // Serialize message ID
864  _status = msg.serialize(
865  static_cast<NATIVE_INT_TYPE>(PINGIN_PING)
866  );
867  FW_ASSERT(
868  _status == Fw::FW_SERIALIZE_OK,
869  static_cast<FwAssertArgType>(_status)
870  );
871 
872  // Serialize port number
873  _status = msg.serialize(portNum);
874  FW_ASSERT(
875  _status == Fw::FW_SERIALIZE_OK,
876  static_cast<FwAssertArgType>(_status)
877  );
878 
879  // Serialize argument key
880  _status = msg.serialize(key);
881  FW_ASSERT(
882  _status == Fw::FW_SERIALIZE_OK,
883  static_cast<FwAssertArgType>(_status)
884  );
885 
886  // Send message
888  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
889 
890  FW_ASSERT(
891  qStatus == Os::Queue::QUEUE_OK,
892  static_cast<FwAssertArgType>(qStatus)
893  );
894  }
895 
896  // ----------------------------------------------------------------------
897  // Pre-message hooks for typed async input ports
898  //
899  // Each of these functions is invoked just before processing a message
900  // on the corresponding port. By default, they do nothing. You can
901  // override them to provide specific pre-message behavior.
902  // ----------------------------------------------------------------------
903 
906  NATIVE_INT_TYPE portNum,
907  Fw::ComBuffer& data,
908  U32 context
909  )
910  {
911  // Default: no-op
912  }
913 
916  NATIVE_INT_TYPE portNum,
917  U32 key
918  )
919  {
920  // Default: no-op
921  }
922 
923  // ----------------------------------------------------------------------
924  // Invocation functions for typed output ports
925  // ----------------------------------------------------------------------
926 
929  NATIVE_INT_TYPE portNum,
930  U32 key
931  )
932  {
933  FW_ASSERT(
934  portNum < this->getNum_pingOut_OutputPorts(),
935  static_cast<FwAssertArgType>(portNum)
936  );
937  this->m_pingOut_OutputPort[portNum].invoke(
938  key
939  );
940  }
941 
942  // ----------------------------------------------------------------------
943  // Command response
944  // ----------------------------------------------------------------------
945 
948  FwOpcodeType opCode,
949  U32 cmdSeq,
950  Fw::CmdResponse response
951  )
952  {
953  FW_ASSERT(this->m_cmdResponseOut_OutputPort[0].isConnected());
954  this->m_cmdResponseOut_OutputPort[0].invoke(opCode, cmdSeq, response);
955  }
956 
957  // ----------------------------------------------------------------------
958  // Command handler base-class functions
959  //
960  // Call these functions directly to bypass the command input port
961  // ----------------------------------------------------------------------
962 
965  FwOpcodeType opCode,
966  U32 cmdSeq,
967  Fw::CmdArgBuffer& args
968  )
969  {
970  // Call pre-message hook
971  this->CloseFile_preMsgHook(opCode,cmdSeq);
972 
973  // Defer deserializing arguments to the message dispatcher
974  // to avoid deserializing and reserializing just for IPC
975  ComponentIpcSerializableBuffer msg;
977 
978  // Serialize for IPC
979  _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_CLOSEFILE));
980  FW_ASSERT (
981  _status == Fw::FW_SERIALIZE_OK,
982  static_cast<FwAssertArgType>(_status)
983  );
984 
985  // Fake port number to make message dequeue work
986  NATIVE_INT_TYPE port = 0;
987 
988  _status = msg.serialize(port);
989  FW_ASSERT (
990  _status == Fw::FW_SERIALIZE_OK,
991  static_cast<FwAssertArgType>(_status)
992  );
993 
994  _status = msg.serialize(opCode);
995  FW_ASSERT (
996  _status == Fw::FW_SERIALIZE_OK,
997  static_cast<FwAssertArgType>(_status)
998  );
999 
1000  _status = msg.serialize(cmdSeq);
1001  FW_ASSERT (
1002  _status == Fw::FW_SERIALIZE_OK,
1003  static_cast<FwAssertArgType>(_status)
1004  );
1005 
1006  _status = msg.serialize(args);
1007  FW_ASSERT (
1008  _status == Fw::FW_SERIALIZE_OK,
1009  static_cast<FwAssertArgType>(_status)
1010  );
1011 
1012  // Send message
1014  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1015 
1016  FW_ASSERT(
1017  qStatus == Os::Queue::QUEUE_OK,
1018  static_cast<FwAssertArgType>(qStatus)
1019  );
1020  }
1021 
1022  // ----------------------------------------------------------------------
1023  // Pre-message hooks for async commands
1024  //
1025  // Each of these functions is invoked just before processing the
1026  // corresponding command. By default they do nothing. You can
1027  // override them to provide specific pre-command behavior.
1028  // ----------------------------------------------------------------------
1029 
1032  FwOpcodeType opCode,
1033  U32 cmdSeq
1034  )
1035  {
1036  // Defaults to no-op; can be overridden
1037  (void) opCode;
1038  (void) cmdSeq;
1039  }
1040 
1041  // ----------------------------------------------------------------------
1042  // Event logging functions
1043  // ----------------------------------------------------------------------
1044 
1047  U32 errornum,
1048  const Fw::LogStringArg& file
1049  )
1050  {
1051  // Get the time
1052  Fw::Time _logTime;
1053  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1054  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1055  }
1056 
1057  FwEventIdType _id = static_cast<FwEventIdType>(0);
1058 
1059  _id = this->getIdBase() + EVENTID_FILEOPENERROR;
1060 
1061  // Emit the event on the log port
1062  if (this->m_logOut_OutputPort[0].isConnected()) {
1063  Fw::LogBuffer _logBuff;
1065 
1066 #if FW_AMPCS_COMPATIBLE
1067  // Serialize the number of arguments
1068  _status = _logBuff.serialize(static_cast<U8>(2));
1069  FW_ASSERT(
1070  _status == Fw::FW_SERIALIZE_OK,
1071  static_cast<FwAssertArgType>(_status)
1072  );
1073 #endif
1074 
1075 #if FW_AMPCS_COMPATIBLE
1076  // Serialize the argument size
1077  _status = _logBuff.serialize(
1078  static_cast<U8>(sizeof(U32))
1079  );
1080  FW_ASSERT(
1081  _status == Fw::FW_SERIALIZE_OK,
1082  static_cast<FwAssertArgType>(_status)
1083  );
1084 #endif
1085  _status = _logBuff.serialize(errornum);
1086  FW_ASSERT(
1087  _status == Fw::FW_SERIALIZE_OK,
1088  static_cast<FwAssertArgType>(_status)
1089  );
1090 
1091  _status = file.serialize(_logBuff, 240);
1092  FW_ASSERT(
1093  _status == Fw::FW_SERIALIZE_OK,
1094  static_cast<FwAssertArgType>(_status)
1095  );
1096 
1097  this->m_logOut_OutputPort[0].invoke(
1098  _id,
1099  _logTime,
1101  _logBuff
1102  );
1103  }
1104 
1105  // Emit the event on the text log port
1106 #if FW_ENABLE_TEXT_LOGGING
1107  if (this->m_LogText_OutputPort[0].isConnected()) {
1108 #if FW_OBJECT_NAMES == 1
1109  const char* _formatString =
1110  "(%s) %s: Error %" PRIu32 " opening file %s";
1111 #else
1112  const char* _formatString =
1113  "%s: Error %" PRIu32 " opening file %s";
1114 #endif
1115 
1116  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1117 
1118  (void) snprintf(
1119  _textBuffer,
1121  _formatString,
1122 #if FW_OBJECT_NAMES == 1
1123  this->m_objName,
1124 #endif
1125  "FileOpenError ",
1126  errornum,
1127  file.toChar()
1128  );
1129 
1130  // Null terminate
1131  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1132  Fw::TextLogString _logString = _textBuffer;
1133  this->m_LogText_OutputPort[0].invoke(
1134  _id,
1135  _logTime,
1137  _logString
1138  );
1139  }
1140 #endif
1141  }
1142 
1145  U32 errornum,
1146  U32 bytesWritten,
1147  U32 bytesToWrite,
1148  const Fw::LogStringArg& file
1149  )
1150  {
1151  // Get the time
1152  Fw::Time _logTime;
1153  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1154  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1155  }
1156 
1157  FwEventIdType _id = static_cast<FwEventIdType>(0);
1158 
1159  _id = this->getIdBase() + EVENTID_FILEWRITEERROR;
1160 
1161  // Emit the event on the log port
1162  if (this->m_logOut_OutputPort[0].isConnected()) {
1163  Fw::LogBuffer _logBuff;
1165 
1166 #if FW_AMPCS_COMPATIBLE
1167  // Serialize the number of arguments
1168  _status = _logBuff.serialize(static_cast<U8>(4));
1169  FW_ASSERT(
1170  _status == Fw::FW_SERIALIZE_OK,
1171  static_cast<FwAssertArgType>(_status)
1172  );
1173 #endif
1174 
1175 #if FW_AMPCS_COMPATIBLE
1176  // Serialize the argument size
1177  _status = _logBuff.serialize(
1178  static_cast<U8>(sizeof(U32))
1179  );
1180  FW_ASSERT(
1181  _status == Fw::FW_SERIALIZE_OK,
1182  static_cast<FwAssertArgType>(_status)
1183  );
1184 #endif
1185  _status = _logBuff.serialize(errornum);
1186  FW_ASSERT(
1187  _status == Fw::FW_SERIALIZE_OK,
1188  static_cast<FwAssertArgType>(_status)
1189  );
1190 
1191 #if FW_AMPCS_COMPATIBLE
1192  // Serialize the argument size
1193  _status = _logBuff.serialize(
1194  static_cast<U8>(sizeof(U32))
1195  );
1196  FW_ASSERT(
1197  _status == Fw::FW_SERIALIZE_OK,
1198  static_cast<FwAssertArgType>(_status)
1199  );
1200 #endif
1201  _status = _logBuff.serialize(bytesWritten);
1202  FW_ASSERT(
1203  _status == Fw::FW_SERIALIZE_OK,
1204  static_cast<FwAssertArgType>(_status)
1205  );
1206 
1207 #if FW_AMPCS_COMPATIBLE
1208  // Serialize the argument size
1209  _status = _logBuff.serialize(
1210  static_cast<U8>(sizeof(U32))
1211  );
1212  FW_ASSERT(
1213  _status == Fw::FW_SERIALIZE_OK,
1214  static_cast<FwAssertArgType>(_status)
1215  );
1216 #endif
1217  _status = _logBuff.serialize(bytesToWrite);
1218  FW_ASSERT(
1219  _status == Fw::FW_SERIALIZE_OK,
1220  static_cast<FwAssertArgType>(_status)
1221  );
1222 
1223  _status = file.serialize(_logBuff, 240);
1224  FW_ASSERT(
1225  _status == Fw::FW_SERIALIZE_OK,
1226  static_cast<FwAssertArgType>(_status)
1227  );
1228 
1229  this->m_logOut_OutputPort[0].invoke(
1230  _id,
1231  _logTime,
1233  _logBuff
1234  );
1235  }
1236 
1237  // Emit the event on the text log port
1238 #if FW_ENABLE_TEXT_LOGGING
1239  if (this->m_LogText_OutputPort[0].isConnected()) {
1240 #if FW_OBJECT_NAMES == 1
1241  const char* _formatString =
1242  "(%s) %s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1243 #else
1244  const char* _formatString =
1245  "%s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1246 #endif
1247 
1248  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1249 
1250  (void) snprintf(
1251  _textBuffer,
1253  _formatString,
1254 #if FW_OBJECT_NAMES == 1
1255  this->m_objName,
1256 #endif
1257  "FileWriteError ",
1258  errornum,
1259  bytesWritten,
1260  bytesToWrite,
1261  file.toChar()
1262  );
1263 
1264  // Null terminate
1265  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1266  Fw::TextLogString _logString = _textBuffer;
1267  this->m_LogText_OutputPort[0].invoke(
1268  _id,
1269  _logTime,
1271  _logString
1272  );
1273  }
1274 #endif
1275  }
1276 
1279  const Fw::LogStringArg& validationFile,
1280  const Fw::LogStringArg& file,
1281  U32 status
1282  )
1283  {
1284  // Get the time
1285  Fw::Time _logTime;
1286  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1287  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1288  }
1289 
1290  FwEventIdType _id = static_cast<FwEventIdType>(0);
1291 
1292  _id = this->getIdBase() + EVENTID_FILEVALIDATIONERROR;
1293 
1294  // Emit the event on the log port
1295  if (this->m_logOut_OutputPort[0].isConnected()) {
1296  Fw::LogBuffer _logBuff;
1298 
1299 #if FW_AMPCS_COMPATIBLE
1300  // Serialize the number of arguments
1301  _status = _logBuff.serialize(static_cast<U8>(3));
1302  FW_ASSERT(
1303  _status == Fw::FW_SERIALIZE_OK,
1304  static_cast<FwAssertArgType>(_status)
1305  );
1306 #endif
1307 
1308  _status = validationFile.serialize(_logBuff, 240);
1309  FW_ASSERT(
1310  _status == Fw::FW_SERIALIZE_OK,
1311  static_cast<FwAssertArgType>(_status)
1312  );
1313 
1314  _status = file.serialize(_logBuff, 240);
1315  FW_ASSERT(
1316  _status == Fw::FW_SERIALIZE_OK,
1317  static_cast<FwAssertArgType>(_status)
1318  );
1319 
1320 #if FW_AMPCS_COMPATIBLE
1321  // Serialize the argument size
1322  _status = _logBuff.serialize(
1323  static_cast<U8>(sizeof(U32))
1324  );
1325  FW_ASSERT(
1326  _status == Fw::FW_SERIALIZE_OK,
1327  static_cast<FwAssertArgType>(_status)
1328  );
1329 #endif
1330  _status = _logBuff.serialize(status);
1331  FW_ASSERT(
1332  _status == Fw::FW_SERIALIZE_OK,
1333  static_cast<FwAssertArgType>(_status)
1334  );
1335 
1336  this->m_logOut_OutputPort[0].invoke(
1337  _id,
1338  _logTime,
1340  _logBuff
1341  );
1342  }
1343 
1344  // Emit the event on the text log port
1345 #if FW_ENABLE_TEXT_LOGGING
1346  if (this->m_LogText_OutputPort[0].isConnected()) {
1347 #if FW_OBJECT_NAMES == 1
1348  const char* _formatString =
1349  "(%s) %s: The ComLogger failed to create a validation file %s for %s with error %" PRIu32 ".";
1350 #else
1351  const char* _formatString =
1352  "%s: The ComLogger failed to create a validation file %s for %s with error %" PRIu32 ".";
1353 #endif
1354 
1355  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1356 
1357  (void) snprintf(
1358  _textBuffer,
1360  _formatString,
1361 #if FW_OBJECT_NAMES == 1
1362  this->m_objName,
1363 #endif
1364  "FileValidationError ",
1365  validationFile.toChar(),
1366  file.toChar(),
1367  status
1368  );
1369 
1370  // Null terminate
1371  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1372  Fw::TextLogString _logString = _textBuffer;
1373  this->m_LogText_OutputPort[0].invoke(
1374  _id,
1375  _logTime,
1377  _logString
1378  );
1379  }
1380 #endif
1381  }
1382 
1385  {
1386  // Get the time
1387  Fw::Time _logTime;
1388  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1389  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1390  }
1391 
1392  FwEventIdType _id = static_cast<FwEventIdType>(0);
1393 
1394  _id = this->getIdBase() + EVENTID_FILECLOSED;
1395 
1396  // Emit the event on the log port
1397  if (this->m_logOut_OutputPort[0].isConnected()) {
1398  Fw::LogBuffer _logBuff;
1400 
1401 #if FW_AMPCS_COMPATIBLE
1402  // Serialize the number of arguments
1403  _status = _logBuff.serialize(static_cast<U8>(1));
1404  FW_ASSERT(
1405  _status == Fw::FW_SERIALIZE_OK,
1406  static_cast<FwAssertArgType>(_status)
1407  );
1408 #endif
1409 
1410  _status = file.serialize(_logBuff, 240);
1411  FW_ASSERT(
1412  _status == Fw::FW_SERIALIZE_OK,
1413  static_cast<FwAssertArgType>(_status)
1414  );
1415 
1416  this->m_logOut_OutputPort[0].invoke(
1417  _id,
1418  _logTime,
1420  _logBuff
1421  );
1422  }
1423 
1424  // Emit the event on the text log port
1425 #if FW_ENABLE_TEXT_LOGGING
1426  if (this->m_LogText_OutputPort[0].isConnected()) {
1427 #if FW_OBJECT_NAMES == 1
1428  const char* _formatString =
1429  "(%s) %s: File %s closed successfully.";
1430 #else
1431  const char* _formatString =
1432  "%s: File %s closed successfully.";
1433 #endif
1434 
1435  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1436 
1437  (void) snprintf(
1438  _textBuffer,
1440  _formatString,
1441 #if FW_OBJECT_NAMES == 1
1442  this->m_objName,
1443 #endif
1444  "FileClosed ",
1445  file.toChar()
1446  );
1447 
1448  // Null terminate
1449  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1450  Fw::TextLogString _logString = _textBuffer;
1451  this->m_LogText_OutputPort[0].invoke(
1452  _id,
1453  _logTime,
1455  _logString
1456  );
1457  }
1458 #endif
1459  }
1460 
1463  {
1464  // Check throttle value
1465  if (this->m_FileNotInitializedThrottle >= EVENTID_FILENOTINITIALIZED_THROTTLE) {
1466  return;
1467  }
1468  else {
1469  this->m_FileNotInitializedThrottle++;
1470  }
1471 
1472  // Get the time
1473  Fw::Time _logTime;
1474  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1475  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1476  }
1477 
1478  FwEventIdType _id = static_cast<FwEventIdType>(0);
1479 
1480  _id = this->getIdBase() + EVENTID_FILENOTINITIALIZED;
1481 
1482  // Emit the event on the log port
1483  if (this->m_logOut_OutputPort[0].isConnected()) {
1484  Fw::LogBuffer _logBuff;
1485 
1486 #if FW_AMPCS_COMPATIBLE
1488  // Serialize the number of arguments
1489  _status = _logBuff.serialize(static_cast<U8>(0));
1490  FW_ASSERT(
1491  _status == Fw::FW_SERIALIZE_OK,
1492  static_cast<FwAssertArgType>(_status)
1493  );
1494 #endif
1495 
1496  this->m_logOut_OutputPort[0].invoke(
1497  _id,
1498  _logTime,
1500  _logBuff
1501  );
1502  }
1503 
1504  // Emit the event on the text log port
1505 #if FW_ENABLE_TEXT_LOGGING
1506  if (this->m_LogText_OutputPort[0].isConnected()) {
1507 #if FW_OBJECT_NAMES == 1
1508  const char* _formatString =
1509  "(%s) %s: Could not open ComLogger file. File not initialized";
1510 #else
1511  const char* _formatString =
1512  "%s: Could not open ComLogger file. File not initialized";
1513 #endif
1514 
1515  char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1516 
1517  (void) snprintf(
1518  _textBuffer,
1520  _formatString,
1521 #if FW_OBJECT_NAMES == 1
1522  this->m_objName,
1523 #endif
1524  "FileNotInitialized "
1525  );
1526 
1527  // Null terminate
1528  _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1529  Fw::TextLogString _logString = _textBuffer;
1530  this->m_LogText_OutputPort[0].invoke(
1531  _id,
1532  _logTime,
1534  _logString
1535  );
1536  }
1537 #endif
1538  }
1539 
1540  // ----------------------------------------------------------------------
1541  // Event throttle reset functions
1542  // ----------------------------------------------------------------------
1543 
1546  {
1547  // Reset throttle counter
1548  this->m_FileNotInitializedThrottle = 0;
1549  }
1550 
1551  // ----------------------------------------------------------------------
1552  // Time
1553  // ----------------------------------------------------------------------
1554 
1556  getTime()
1557  {
1558  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1559  Fw::Time _time;
1560  this->m_timeCaller_OutputPort[0].invoke(_time);
1561  return _time;
1562  }
1563  else {
1564  return Fw::Time(TB_NONE, 0, 0);
1565  }
1566  }
1567 
1568  // ----------------------------------------------------------------------
1569  // Message dispatch functions
1570  // ----------------------------------------------------------------------
1571 
1572  Fw::QueuedComponentBase::MsgDispatchStatus ComLoggerComponentBase ::
1573  doDispatch()
1574  {
1575  ComponentIpcSerializableBuffer msg;
1576  NATIVE_INT_TYPE priority = 0;
1577 
1578  Os::Queue::QueueStatus msgStatus = this->m_queue.receive(
1579  msg,
1580  priority,
1582  );
1583  FW_ASSERT(
1584  msgStatus == Os::Queue::QUEUE_OK,
1585  static_cast<FwAssertArgType>(msgStatus)
1586  );
1587 
1588  // Reset to beginning of buffer
1589  msg.resetDeser();
1590 
1591  NATIVE_INT_TYPE desMsg = 0;
1592  Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
1593  FW_ASSERT(
1594  deserStatus == Fw::FW_SERIALIZE_OK,
1595  static_cast<FwAssertArgType>(deserStatus)
1596  );
1597 
1598  MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
1599 
1600  if (msgType == COMLOGGER_COMPONENT_EXIT) {
1601  return MSG_DISPATCH_EXIT;
1602  }
1603 
1604  NATIVE_INT_TYPE portNum = 0;
1605  deserStatus = msg.deserialize(portNum);
1606  FW_ASSERT(
1607  deserStatus == Fw::FW_SERIALIZE_OK,
1608  static_cast<FwAssertArgType>(deserStatus)
1609  );
1610 
1611  switch (msgType) {
1612  // Handle async input port comIn
1613  case COMIN_COM: {
1614  // Deserialize argument data
1615  Fw::ComBuffer data;
1616  deserStatus = msg.deserialize(data);
1617  FW_ASSERT(
1618  deserStatus == Fw::FW_SERIALIZE_OK,
1619  static_cast<FwAssertArgType>(deserStatus)
1620  );
1621 
1622  // Deserialize argument context
1623  U32 context;
1624  deserStatus = msg.deserialize(context);
1625  FW_ASSERT(
1626  deserStatus == Fw::FW_SERIALIZE_OK,
1627  static_cast<FwAssertArgType>(deserStatus)
1628  );
1629  // Call handler function
1630  this->comIn_handler(
1631  portNum,
1632  data,
1633  context
1634  );
1635 
1636  break;
1637  }
1638 
1639  // Handle async input port pingIn
1640  case PINGIN_PING: {
1641  // Deserialize argument key
1642  U32 key;
1643  deserStatus = msg.deserialize(key);
1644  FW_ASSERT(
1645  deserStatus == Fw::FW_SERIALIZE_OK,
1646  static_cast<FwAssertArgType>(deserStatus)
1647  );
1648  // Call handler function
1649  this->pingIn_handler(
1650  portNum,
1651  key
1652  );
1653 
1654  break;
1655  }
1656 
1657  // Handle command CloseFile
1658  case CMD_CLOSEFILE: {
1659  // Deserialize opcode
1660  FwOpcodeType opCode = 0;
1661  deserStatus = msg.deserialize(opCode);
1662  FW_ASSERT (
1663  deserStatus == Fw::FW_SERIALIZE_OK,
1664  static_cast<FwAssertArgType>(deserStatus)
1665  );
1666 
1667  // Deserialize command sequence
1668  U32 cmdSeq = 0;
1669  deserStatus = msg.deserialize(cmdSeq);
1670  FW_ASSERT (
1671  deserStatus == Fw::FW_SERIALIZE_OK,
1672  static_cast<FwAssertArgType>(deserStatus)
1673  );
1674 
1675  // Deserialize command argument buffer
1676  Fw::CmdArgBuffer args;
1677  deserStatus = msg.deserialize(args);
1678  FW_ASSERT (
1679  deserStatus == Fw::FW_SERIALIZE_OK,
1680  static_cast<FwAssertArgType>(deserStatus)
1681  );
1682 
1683  // Reset buffer
1684  args.resetDeser();
1685 
1686  // Make sure there was no data left over.
1687  // That means the argument buffer size was incorrect.
1688 #if FW_CMD_CHECK_RESIDUAL
1689  if (args.getBuffLeft() != 0) {
1690  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
1691  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
1692  }
1693  // Don't crash the task if bad arguments were passed from the ground
1694  break;
1695  }
1696 #endif
1697 
1698  // Call handler function
1699  this->CloseFile_cmdHandler(opCode, cmdSeq);
1700 
1701  break;
1702  }
1703 
1704  default:
1705  return MSG_DISPATCH_ERROR;
1706  }
1707 
1708  return MSG_DISPATCH_OK;
1709  }
1710 
1711  // ----------------------------------------------------------------------
1712  // Calls for messages received on special input ports
1713  // ----------------------------------------------------------------------
1714 
1715  void ComLoggerComponentBase ::
1716  m_p_cmdIn_in(
1717  Fw::PassiveComponentBase* callComp,
1718  NATIVE_INT_TYPE portNum,
1719  FwOpcodeType opCode,
1720  U32 cmdSeq,
1721  Fw::CmdArgBuffer& args
1722  )
1723  {
1724  FW_ASSERT(callComp);
1725  ComLoggerComponentBase* compPtr = static_cast<ComLoggerComponentBase*>(callComp);
1726 
1727  const U32 idBase = callComp->getIdBase();
1728  FW_ASSERT(opCode >= idBase, opCode, idBase);
1729 
1730  // Select base class function based on opcode
1731  switch (opCode - idBase) {
1732  case OPCODE_CLOSEFILE: {
1733  compPtr->CloseFile_cmdHandlerBase(
1734  opCode,
1735  cmdSeq,
1736  args
1737  );
1738  break;
1739  }
1740  }
1741  }
1742 
1743  // ----------------------------------------------------------------------
1744  // Calls for messages received on typed input ports
1745  // ----------------------------------------------------------------------
1746 
1747  void ComLoggerComponentBase ::
1748  m_p_comIn_in(
1749  Fw::PassiveComponentBase* callComp,
1750  NATIVE_INT_TYPE portNum,
1751  Fw::ComBuffer& data,
1752  U32 context
1753  )
1754  {
1755  FW_ASSERT(callComp);
1756  ComLoggerComponentBase* compPtr = static_cast<ComLoggerComponentBase*>(callComp);
1757  compPtr->comIn_handlerBase(
1758  portNum,
1759  data,
1760  context
1761  );
1762  }
1763 
1764  void ComLoggerComponentBase ::
1765  m_p_pingIn_in(
1766  Fw::PassiveComponentBase* callComp,
1767  NATIVE_INT_TYPE portNum,
1768  U32 key
1769  )
1770  {
1771  FW_ASSERT(callComp);
1772  ComLoggerComponentBase* compPtr = static_cast<ComLoggerComponentBase*>(callComp);
1773  compPtr->pingIn_handlerBase(
1774  portNum,
1775  key
1776  );
1777  }
1778 
1779 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
U8 BYTE
byte type
Definition: BasicTypes.h:27
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:26
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:66
PlatformUIntType NATIVE_UINT_TYPE
Definition: BasicTypes.h:52
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition: FpConfig.h:39
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:21
U32 FwEventIdType
Definition: FpConfig.h:62
U32 FwOpcodeType
Definition: FpConfig.h:56
#define FW_LOG_TEXT_BUFFER_SIZE
Max size of string for text log message.
Definition: FpConfig.h:299
#define FW_OBJ_NAME_MAX_SIZE
Size of object name (if object names enabled). AC Limits to 80, truncation occurs above 80.
Definition: FpConfig.h:184
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects)
Definition: FpConfig.h:88
@ ACTIVE_COMPONENT_EXIT
message to exit active component task
Enum representing a command response.
@ FORMAT_ERROR
Command failed to deserialize.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CmdPortAc.cpp:62
void init()
Initialization function.
Definition: CmdPortAc.cpp:56
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:37
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: ComPortAc.hpp:37
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: ComPortAc.cpp:62
void init()
Initialization function.
Definition: ComPortAc.cpp:56
void setPortNum(NATIVE_INT_TYPE portNum)
@ WARNING_HI
A serious but recoverable event.
@ WARNING_LO
A less serious but recoverable event.
@ DIAGNOSTIC
Software diagnostic events.
const char * toChar() const override
Definition: LogString.cpp:49
SerializeStatus serialize(SerializeBufferBase &buffer) const override
serialization function
Definition: LogString.cpp:57
void init()
Object initializer.
Definition: ObjBase.cpp:27
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
void invoke(FwOpcodeType opCode)
Invoke a port interface.
void init()
Initialization function.
void init()
Initialization function.
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Invoke a port interface.
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args)
Invoke a port interface.
Definition: LogPortAc.cpp:170
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
void invoke(Fw::Time &time)
Invoke a port interface.
Definition: TimePortAc.cpp:147
void init()
Initialization function.
Definition: TimePortAc.cpp:128
bool isConnected()
Definition: PortBase.cpp:41
Os::Queue::QueueStatus createQueue(NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
Os::Queue m_queue
queue object for active component
@ MSG_DISPATCH_OK
Dispatch was normal.
@ MSG_DISPATCH_EXIT
A message was sent requesting an exit of the loop.
@ MSG_DISPATCH_ERROR
Errors dispatching messages.
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
void resetDeser()
reset deserialization to beginning
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Definition: Time.hpp:9
QueueStatus
Definition: Queue.hpp:27
@ QUEUE_OK
message sent/received okay
Definition: Queue.hpp:28
QueueStatus send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block)
send a message
Definition: QueueCommon.cpp:13
QueueStatus receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block)
receive a message
Definition: QueueCommon.cpp:22
QueueBlocking
Definition: Queue.hpp:40
@ QUEUE_BLOCKING
Queue receive blocks until a message arrives.
Definition: Queue.hpp:41
@ QUEUE_NONBLOCKING
Queue receive always returns even if there is no message.
Definition: Queue.hpp:42
NATIVE_INT_TYPE getNum_pingIn_InputPorts() const
void log_WARNING_HI_FileOpenError(U32 errornum, const Fw::LogStringArg &file)
virtual ~ComLoggerComponentBase()
Destroy ComLoggerComponentBase object.
NATIVE_INT_TYPE getNum_pingOut_OutputPorts() const
bool isConnected_cmdRegOut_OutputPort(NATIVE_INT_TYPE portNum)
NATIVE_INT_TYPE getNum_cmdRegOut_OutputPorts() const
void log_DIAGNOSTIC_FileClosed(const Fw::LogStringArg &file)
bool isConnected_cmdResponseOut_OutputPort(NATIVE_INT_TYPE portNum)
Fw::InputCmdPort * get_cmdIn_InputPort(NATIVE_INT_TYPE portNum)
NATIVE_INT_TYPE getNum_comIn_InputPorts() const
ComLoggerComponentBase(const char *compName="")
Construct ComLoggerComponentBase object.
@ EVENTID_FILENOTINITIALIZED_THROTTLE
Throttle reset count for FileNotInitialized.
virtual void comIn_handler(NATIVE_INT_TYPE portNum, Fw::ComBuffer &data, U32 context)=0
Handler for input port comIn.
Fw::InputComPort * get_comIn_InputPort(NATIVE_INT_TYPE portNum)
virtual void pingIn_handler(NATIVE_INT_TYPE portNum, U32 key)=0
Handler for input port pingIn.
void log_WARNING_LO_FileValidationError(const Fw::LogStringArg &validationFile, const Fw::LogStringArg &file, U32 status)
virtual void comIn_preMsgHook(NATIVE_INT_TYPE portNum, Fw::ComBuffer &data, U32 context)
Pre-message hook for async input port comIn.
virtual void pingIn_preMsgHook(NATIVE_INT_TYPE portNum, U32 key)
Pre-message hook for async input port pingIn.
void comIn_handlerBase(NATIVE_INT_TYPE portNum, Fw::ComBuffer &data, U32 context)
Handler base-class function for input port comIn.
bool isConnected_pingOut_OutputPort(NATIVE_INT_TYPE portNum)
virtual void CloseFile_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
void log_WARNING_LO_FileNotInitialized()
Log event FileNotInitialized.
NATIVE_INT_TYPE getNum_timeCaller_OutputPorts() const
void CloseFile_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
void set_timeCaller_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputTimePort *port)
Connect port to timeCaller[portNum].
void regCommands()
Register commands with the Command Dispatcher.
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
virtual void CloseFile_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command CloseFile.
bool isConnected_timeCaller_OutputPort(NATIVE_INT_TYPE portNum)
Svc::InputPingPort * get_pingIn_InputPort(NATIVE_INT_TYPE portNum)
void set_cmdRegOut_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegOut[portNum].
NATIVE_INT_TYPE getNum_logOut_OutputPorts() const
void pingIn_handlerBase(NATIVE_INT_TYPE portNum, U32 key)
Handler base-class function for input port pingIn.
void set_logOut_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputLogPort *port)
Connect port to logOut[portNum].
@ EVENTID_FILECLOSED
The ComLogger successfully closed a file on command.
@ EVENTID_FILEWRITEERROR
The ComLogger encountered an error writing to a file.
@ EVENTID_FILEVALIDATIONERROR
The ComLogger encountered an error writing the validation file.
@ EVENTID_FILEOPENERROR
The ComLogger encountered an error opening a file.
NATIVE_INT_TYPE getNum_cmdResponseOut_OutputPorts() const
void set_pingOut_OutputPort(NATIVE_INT_TYPE portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
NATIVE_INT_TYPE getNum_cmdIn_InputPorts() const
@ OPCODE_CLOSEFILE
Forces a close of the currently opened file.
void pingOut_out(NATIVE_INT_TYPE portNum, U32 key)
Invoke output port pingOut.
bool isConnected_logOut_OutputPort(NATIVE_INT_TYPE portNum)
void log_WARNING_HI_FileWriteError(U32 errornum, U32 bytesWritten, U32 bytesToWrite, const Fw::LogStringArg &file)
void set_cmdResponseOut_OutputPort(NATIVE_INT_TYPE portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
void log_WARNING_LO_FileNotInitialized_ThrottleClear()
Reset throttle value for FileNotInitialized.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:62
void init()
Initialization function.
Definition: PingPortAc.cpp:56
void invoke(U32 key)
Invoke a port interface.
Definition: PingPortAc.cpp:147
void init()
Initialization function.
Definition: PingPortAc.cpp:128
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:134
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.