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 
7 #include "Fw/Types/Assert.hpp"
9 #if FW_ENABLE_TEXT_LOGGING
10 #include "Fw/Types/String.hpp"
11 #endif
13 
14 namespace Svc {
15 
16  namespace {
17  enum MsgTypeEnum {
18  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 getCapacity() 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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  // Connection status queries for special output ports
737  // ----------------------------------------------------------------------
738 
741  {
742  FW_ASSERT(
743  (0 <= portNum) && (portNum < this->getNum_cmdRegOut_OutputPorts()),
744  static_cast<FwAssertArgType>(portNum)
745  );
746 
747  return this->m_cmdRegOut_OutputPort[portNum].isConnected();
748  }
749 
752  {
753  FW_ASSERT(
754  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
755  static_cast<FwAssertArgType>(portNum)
756  );
757 
758  return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
759  }
760 
763  {
764  FW_ASSERT(
765  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
766  static_cast<FwAssertArgType>(portNum)
767  );
768 
769  return this->m_eventOut_OutputPort[portNum].isConnected();
770  }
771 
772 #if FW_ENABLE_TEXT_LOGGING == 1
773 
774  bool BufferLoggerComponentBase ::
775  isConnected_eventOutText_OutputPort(FwIndexType portNum)
776  {
777  FW_ASSERT(
778  (0 <= portNum) && (portNum < this->getNum_eventOutText_OutputPorts()),
779  static_cast<FwAssertArgType>(portNum)
780  );
781 
782  return this->m_eventOutText_OutputPort[portNum].isConnected();
783  }
784 
785 #endif
786 
789  {
790  FW_ASSERT(
791  (0 <= portNum) && (portNum < this->getNum_timeCaller_OutputPorts()),
792  static_cast<FwAssertArgType>(portNum)
793  );
794 
795  return this->m_timeCaller_OutputPort[portNum].isConnected();
796  }
797 
800  {
801  FW_ASSERT(
802  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
803  static_cast<FwAssertArgType>(portNum)
804  );
805 
806  return this->m_tlmOut_OutputPort[portNum].isConnected();
807  }
808 
809  // ----------------------------------------------------------------------
810  // Connection status queries for typed output ports
811  // ----------------------------------------------------------------------
812 
815  {
816  FW_ASSERT(
817  (0 <= portNum) && (portNum < this->getNum_bufferSendOut_OutputPorts()),
818  static_cast<FwAssertArgType>(portNum)
819  );
820 
821  return this->m_bufferSendOut_OutputPort[portNum].isConnected();
822  }
823 
826  {
827  FW_ASSERT(
828  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
829  static_cast<FwAssertArgType>(portNum)
830  );
831 
832  return this->m_pingOut_OutputPort[portNum].isConnected();
833  }
834 
835  // ----------------------------------------------------------------------
836  // Port handler base-class functions for typed input ports
837  //
838  // Call these functions directly to bypass the corresponding ports
839  // ----------------------------------------------------------------------
840 
843  FwIndexType portNum,
844  Fw::Buffer& fwBuffer
845  )
846  {
847  // Make sure port number is valid
848  FW_ASSERT(
849  (0 <= portNum) && (portNum < this->getNum_bufferSendIn_InputPorts()),
850  static_cast<FwAssertArgType>(portNum)
851  );
852 
853  // Call pre-message hook
855  portNum,
856  fwBuffer
857  );
858  ComponentIpcSerializableBuffer msg;
860 
861  // Serialize message ID
862  _status = msg.serializeFrom(
863  static_cast<FwEnumStoreType>(BUFFERSENDIN_BUFFERSEND)
864  );
865  FW_ASSERT(
866  _status == Fw::FW_SERIALIZE_OK,
867  static_cast<FwAssertArgType>(_status)
868  );
869 
870  // Serialize port number
871  _status = msg.serializeFrom(portNum);
872  FW_ASSERT(
873  _status == Fw::FW_SERIALIZE_OK,
874  static_cast<FwAssertArgType>(_status)
875  );
876 
877  // Serialize argument fwBuffer
878  _status = msg.serializeFrom(fwBuffer);
879  FW_ASSERT(
880  _status == Fw::FW_SERIALIZE_OK,
881  static_cast<FwAssertArgType>(_status)
882  );
883 
884  // Send message
886  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
887 
888  FW_ASSERT(
889  qStatus == Os::Queue::OP_OK,
890  static_cast<FwAssertArgType>(qStatus)
891  );
892  }
893 
896  FwIndexType portNum,
897  Fw::ComBuffer& data,
898  U32 context
899  )
900  {
901  // Make sure port number is valid
902  FW_ASSERT(
903  (0 <= portNum) && (portNum < this->getNum_comIn_InputPorts()),
904  static_cast<FwAssertArgType>(portNum)
905  );
906 
907  // Call pre-message hook
909  portNum,
910  data,
911  context
912  );
913  ComponentIpcSerializableBuffer msg;
915 
916  // Serialize message ID
917  _status = msg.serializeFrom(
918  static_cast<FwEnumStoreType>(COMIN_COM)
919  );
920  FW_ASSERT(
921  _status == Fw::FW_SERIALIZE_OK,
922  static_cast<FwAssertArgType>(_status)
923  );
924 
925  // Serialize port number
926  _status = msg.serializeFrom(portNum);
927  FW_ASSERT(
928  _status == Fw::FW_SERIALIZE_OK,
929  static_cast<FwAssertArgType>(_status)
930  );
931 
932  // Serialize argument data
933  _status = msg.serializeFrom(data);
934  FW_ASSERT(
935  _status == Fw::FW_SERIALIZE_OK,
936  static_cast<FwAssertArgType>(_status)
937  );
938 
939  // Serialize argument context
940  _status = msg.serializeFrom(context);
941  FW_ASSERT(
942  _status == Fw::FW_SERIALIZE_OK,
943  static_cast<FwAssertArgType>(_status)
944  );
945 
946  // Send message
948  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
949 
950  FW_ASSERT(
951  qStatus == Os::Queue::OP_OK,
952  static_cast<FwAssertArgType>(qStatus)
953  );
954  }
955 
958  FwIndexType portNum,
959  U32 key
960  )
961  {
962  // Make sure port number is valid
963  FW_ASSERT(
964  (0 <= portNum) && (portNum < this->getNum_pingIn_InputPorts()),
965  static_cast<FwAssertArgType>(portNum)
966  );
967 
968  // Call pre-message hook
970  portNum,
971  key
972  );
973  ComponentIpcSerializableBuffer msg;
975 
976  // Serialize message ID
977  _status = msg.serializeFrom(
978  static_cast<FwEnumStoreType>(PINGIN_PING)
979  );
980  FW_ASSERT(
981  _status == Fw::FW_SERIALIZE_OK,
982  static_cast<FwAssertArgType>(_status)
983  );
984 
985  // Serialize port number
986  _status = msg.serializeFrom(portNum);
987  FW_ASSERT(
988  _status == Fw::FW_SERIALIZE_OK,
989  static_cast<FwAssertArgType>(_status)
990  );
991 
992  // Serialize argument key
993  _status = msg.serializeFrom(key);
994  FW_ASSERT(
995  _status == Fw::FW_SERIALIZE_OK,
996  static_cast<FwAssertArgType>(_status)
997  );
998 
999  // Send message
1001  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1002 
1003  FW_ASSERT(
1004  qStatus == Os::Queue::OP_OK,
1005  static_cast<FwAssertArgType>(qStatus)
1006  );
1007  }
1008 
1011  FwIndexType portNum,
1012  U32 context
1013  )
1014  {
1015  // Make sure port number is valid
1016  FW_ASSERT(
1017  (0 <= portNum) && (portNum < this->getNum_schedIn_InputPorts()),
1018  static_cast<FwAssertArgType>(portNum)
1019  );
1020 
1021  // Call pre-message hook
1023  portNum,
1024  context
1025  );
1026  ComponentIpcSerializableBuffer msg;
1028 
1029  // Serialize message ID
1030  _status = msg.serializeFrom(
1031  static_cast<FwEnumStoreType>(SCHEDIN_SCHED)
1032  );
1033  FW_ASSERT(
1034  _status == Fw::FW_SERIALIZE_OK,
1035  static_cast<FwAssertArgType>(_status)
1036  );
1037 
1038  // Serialize port number
1039  _status = msg.serializeFrom(portNum);
1040  FW_ASSERT(
1041  _status == Fw::FW_SERIALIZE_OK,
1042  static_cast<FwAssertArgType>(_status)
1043  );
1044 
1045  // Serialize argument context
1046  _status = msg.serializeFrom(context);
1047  FW_ASSERT(
1048  _status == Fw::FW_SERIALIZE_OK,
1049  static_cast<FwAssertArgType>(_status)
1050  );
1051 
1052  // Send message
1054  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1055 
1056  FW_ASSERT(
1057  qStatus == Os::Queue::OP_OK,
1058  static_cast<FwAssertArgType>(qStatus)
1059  );
1060  }
1061 
1062  // ----------------------------------------------------------------------
1063  // Pre-message hooks for typed async input ports
1064  //
1065  // Each of these functions is invoked just before processing a message
1066  // on the corresponding port. By default, they do nothing. You can
1067  // override them to provide specific pre-message behavior.
1068  // ----------------------------------------------------------------------
1069 
1072  FwIndexType portNum,
1073  Fw::Buffer& fwBuffer
1074  )
1075  {
1076  // Default: no-op
1077  }
1078 
1081  FwIndexType portNum,
1082  Fw::ComBuffer& data,
1083  U32 context
1084  )
1085  {
1086  // Default: no-op
1087  }
1088 
1091  FwIndexType portNum,
1092  U32 key
1093  )
1094  {
1095  // Default: no-op
1096  }
1097 
1100  FwIndexType portNum,
1101  U32 context
1102  )
1103  {
1104  // Default: no-op
1105  }
1106 
1107  // ----------------------------------------------------------------------
1108  // Invocation functions for typed output ports
1109  // ----------------------------------------------------------------------
1110 
1113  FwIndexType portNum,
1114  Fw::Buffer& fwBuffer
1115  )
1116  {
1117  FW_ASSERT(
1118  (0 <= portNum) && (portNum < this->getNum_bufferSendOut_OutputPorts()),
1119  static_cast<FwAssertArgType>(portNum)
1120  );
1121 
1122  FW_ASSERT(
1123  this->m_bufferSendOut_OutputPort[portNum].isConnected(),
1124  static_cast<FwAssertArgType>(portNum)
1125  );
1126  this->m_bufferSendOut_OutputPort[portNum].invoke(
1127  fwBuffer
1128  );
1129  }
1130 
1133  FwIndexType portNum,
1134  U32 key
1135  )
1136  {
1137  FW_ASSERT(
1138  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
1139  static_cast<FwAssertArgType>(portNum)
1140  );
1141 
1142  FW_ASSERT(
1143  this->m_pingOut_OutputPort[portNum].isConnected(),
1144  static_cast<FwAssertArgType>(portNum)
1145  );
1146  this->m_pingOut_OutputPort[portNum].invoke(
1147  key
1148  );
1149  }
1150 
1151  // ----------------------------------------------------------------------
1152  // Command response
1153  // ----------------------------------------------------------------------
1154 
1157  FwOpcodeType opCode,
1158  U32 cmdSeq,
1159  Fw::CmdResponse response
1160  )
1161  {
1162  FW_ASSERT(this->m_cmdResponseOut_OutputPort[0].isConnected());
1163  this->m_cmdResponseOut_OutputPort[0].invoke(opCode, cmdSeq, response);
1164  }
1165 
1166  // ----------------------------------------------------------------------
1167  // Command handler base-class functions
1168  //
1169  // Call these functions directly to bypass the command input port
1170  // ----------------------------------------------------------------------
1171 
1174  FwOpcodeType opCode,
1175  U32 cmdSeq,
1176  Fw::CmdArgBuffer& args
1177  )
1178  {
1179  // Call pre-message hook
1180  this->BL_OpenFile_preMsgHook(opCode,cmdSeq);
1181 
1182  // Defer deserializing arguments to the message dispatcher
1183  // to avoid deserializing and reserializing just for IPC
1184  ComponentIpcSerializableBuffer msg;
1186 
1187  // Serialize for IPC
1188  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_BL_OPENFILE));
1189  FW_ASSERT (
1190  _status == Fw::FW_SERIALIZE_OK,
1191  static_cast<FwAssertArgType>(_status)
1192  );
1193 
1194  // Fake port number to make message dequeue work
1195  FwIndexType port = 0;
1196 
1197  _status = msg.serializeFrom(port);
1198  FW_ASSERT (
1199  _status == Fw::FW_SERIALIZE_OK,
1200  static_cast<FwAssertArgType>(_status)
1201  );
1202 
1203  _status = msg.serializeFrom(opCode);
1204  FW_ASSERT (
1205  _status == Fw::FW_SERIALIZE_OK,
1206  static_cast<FwAssertArgType>(_status)
1207  );
1208 
1209  _status = msg.serializeFrom(cmdSeq);
1210  FW_ASSERT (
1211  _status == Fw::FW_SERIALIZE_OK,
1212  static_cast<FwAssertArgType>(_status)
1213  );
1214 
1215  _status = msg.serializeFrom(args);
1216  FW_ASSERT (
1217  _status == Fw::FW_SERIALIZE_OK,
1218  static_cast<FwAssertArgType>(_status)
1219  );
1220 
1221  // Send message
1223  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1224 
1225  FW_ASSERT(
1226  qStatus == Os::Queue::OP_OK,
1227  static_cast<FwAssertArgType>(qStatus)
1228  );
1229  }
1230 
1233  FwOpcodeType opCode,
1234  U32 cmdSeq,
1235  Fw::CmdArgBuffer& args
1236  )
1237  {
1238  // Call pre-message hook
1239  this->BL_CloseFile_preMsgHook(opCode,cmdSeq);
1240 
1241  // Defer deserializing arguments to the message dispatcher
1242  // to avoid deserializing and reserializing just for IPC
1243  ComponentIpcSerializableBuffer msg;
1245 
1246  // Serialize for IPC
1247  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_BL_CLOSEFILE));
1248  FW_ASSERT (
1249  _status == Fw::FW_SERIALIZE_OK,
1250  static_cast<FwAssertArgType>(_status)
1251  );
1252 
1253  // Fake port number to make message dequeue work
1254  FwIndexType port = 0;
1255 
1256  _status = msg.serializeFrom(port);
1257  FW_ASSERT (
1258  _status == Fw::FW_SERIALIZE_OK,
1259  static_cast<FwAssertArgType>(_status)
1260  );
1261 
1262  _status = msg.serializeFrom(opCode);
1263  FW_ASSERT (
1264  _status == Fw::FW_SERIALIZE_OK,
1265  static_cast<FwAssertArgType>(_status)
1266  );
1267 
1268  _status = msg.serializeFrom(cmdSeq);
1269  FW_ASSERT (
1270  _status == Fw::FW_SERIALIZE_OK,
1271  static_cast<FwAssertArgType>(_status)
1272  );
1273 
1274  _status = msg.serializeFrom(args);
1275  FW_ASSERT (
1276  _status == Fw::FW_SERIALIZE_OK,
1277  static_cast<FwAssertArgType>(_status)
1278  );
1279 
1280  // Send message
1282  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1283 
1284  FW_ASSERT(
1285  qStatus == Os::Queue::OP_OK,
1286  static_cast<FwAssertArgType>(qStatus)
1287  );
1288  }
1289 
1292  FwOpcodeType opCode,
1293  U32 cmdSeq,
1294  Fw::CmdArgBuffer& args
1295  )
1296  {
1297  // Call pre-message hook
1298  this->BL_SetLogging_preMsgHook(opCode,cmdSeq);
1299 
1300  // Defer deserializing arguments to the message dispatcher
1301  // to avoid deserializing and reserializing just for IPC
1302  ComponentIpcSerializableBuffer msg;
1304 
1305  // Serialize for IPC
1306  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_BL_SETLOGGING));
1307  FW_ASSERT (
1308  _status == Fw::FW_SERIALIZE_OK,
1309  static_cast<FwAssertArgType>(_status)
1310  );
1311 
1312  // Fake port number to make message dequeue work
1313  FwIndexType port = 0;
1314 
1315  _status = msg.serializeFrom(port);
1316  FW_ASSERT (
1317  _status == Fw::FW_SERIALIZE_OK,
1318  static_cast<FwAssertArgType>(_status)
1319  );
1320 
1321  _status = msg.serializeFrom(opCode);
1322  FW_ASSERT (
1323  _status == Fw::FW_SERIALIZE_OK,
1324  static_cast<FwAssertArgType>(_status)
1325  );
1326 
1327  _status = msg.serializeFrom(cmdSeq);
1328  FW_ASSERT (
1329  _status == Fw::FW_SERIALIZE_OK,
1330  static_cast<FwAssertArgType>(_status)
1331  );
1332 
1333  _status = msg.serializeFrom(args);
1334  FW_ASSERT (
1335  _status == Fw::FW_SERIALIZE_OK,
1336  static_cast<FwAssertArgType>(_status)
1337  );
1338 
1339  // Send message
1341  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1342 
1343  FW_ASSERT(
1344  qStatus == Os::Queue::OP_OK,
1345  static_cast<FwAssertArgType>(qStatus)
1346  );
1347  }
1348 
1351  FwOpcodeType opCode,
1352  U32 cmdSeq,
1353  Fw::CmdArgBuffer& args
1354  )
1355  {
1356  // Call pre-message hook
1357  this->BL_FlushFile_preMsgHook(opCode,cmdSeq);
1358 
1359  // Defer deserializing arguments to the message dispatcher
1360  // to avoid deserializing and reserializing just for IPC
1361  ComponentIpcSerializableBuffer msg;
1363 
1364  // Serialize for IPC
1365  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_BL_FLUSHFILE));
1366  FW_ASSERT (
1367  _status == Fw::FW_SERIALIZE_OK,
1368  static_cast<FwAssertArgType>(_status)
1369  );
1370 
1371  // Fake port number to make message dequeue work
1372  FwIndexType port = 0;
1373 
1374  _status = msg.serializeFrom(port);
1375  FW_ASSERT (
1376  _status == Fw::FW_SERIALIZE_OK,
1377  static_cast<FwAssertArgType>(_status)
1378  );
1379 
1380  _status = msg.serializeFrom(opCode);
1381  FW_ASSERT (
1382  _status == Fw::FW_SERIALIZE_OK,
1383  static_cast<FwAssertArgType>(_status)
1384  );
1385 
1386  _status = msg.serializeFrom(cmdSeq);
1387  FW_ASSERT (
1388  _status == Fw::FW_SERIALIZE_OK,
1389  static_cast<FwAssertArgType>(_status)
1390  );
1391 
1392  _status = msg.serializeFrom(args);
1393  FW_ASSERT (
1394  _status == Fw::FW_SERIALIZE_OK,
1395  static_cast<FwAssertArgType>(_status)
1396  );
1397 
1398  // Send message
1400  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1401 
1402  FW_ASSERT(
1403  qStatus == Os::Queue::OP_OK,
1404  static_cast<FwAssertArgType>(qStatus)
1405  );
1406  }
1407 
1408  // ----------------------------------------------------------------------
1409  // Pre-message hooks for async commands
1410  //
1411  // Each of these functions is invoked just before processing the
1412  // corresponding command. By default they do nothing. You can
1413  // override them to provide specific pre-command behavior.
1414  // ----------------------------------------------------------------------
1415 
1418  FwOpcodeType opCode,
1419  U32 cmdSeq
1420  )
1421  {
1422  // Defaults to no-op; can be overridden
1423  (void) opCode;
1424  (void) cmdSeq;
1425  }
1426 
1429  FwOpcodeType opCode,
1430  U32 cmdSeq
1431  )
1432  {
1433  // Defaults to no-op; can be overridden
1434  (void) opCode;
1435  (void) cmdSeq;
1436  }
1437 
1440  FwOpcodeType opCode,
1441  U32 cmdSeq
1442  )
1443  {
1444  // Defaults to no-op; can be overridden
1445  (void) opCode;
1446  (void) cmdSeq;
1447  }
1448 
1451  FwOpcodeType opCode,
1452  U32 cmdSeq
1453  )
1454  {
1455  // Defaults to no-op; can be overridden
1456  (void) opCode;
1457  (void) cmdSeq;
1458  }
1459 
1460  // ----------------------------------------------------------------------
1461  // Event logging functions
1462  // ----------------------------------------------------------------------
1463 
1466  {
1467  // Get the time
1468  Fw::Time _logTime;
1469  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1470  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1471  }
1472 
1473  FwEventIdType _id = static_cast<FwEventIdType>(0);
1474 
1475  _id = this->getIdBase() + EVENTID_BL_LOGFILECLOSED;
1476 
1477  // Emit the event on the log port
1478  if (this->m_eventOut_OutputPort[0].isConnected()) {
1479  Fw::LogBuffer _logBuff;
1481 
1482 #if FW_AMPCS_COMPATIBLE
1483  // Serialize the number of arguments
1484  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1485  FW_ASSERT(
1486  _status == Fw::FW_SERIALIZE_OK,
1487  static_cast<FwAssertArgType>(_status)
1488  );
1489 #endif
1490 
1491  _status = file.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 256));
1492  FW_ASSERT(
1493  _status == Fw::FW_SERIALIZE_OK,
1494  static_cast<FwAssertArgType>(_status)
1495  );
1496 
1497  this->m_eventOut_OutputPort[0].invoke(
1498  _id,
1499  _logTime,
1501  _logBuff
1502  );
1503  }
1504 
1505  // Emit the event on the text log port
1506 #if FW_ENABLE_TEXT_LOGGING
1507  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1508 #if FW_OBJECT_NAMES == 1
1509  const char* _formatString =
1510  "(%s) %s: File %s closed";
1511 #else
1512  const char* _formatString =
1513  "%s: File %s closed";
1514 #endif
1515 
1516  Fw::TextLogString _logString;
1517  _logString.format(
1518  _formatString,
1519 #if FW_OBJECT_NAMES == 1
1520  this->m_objName.toChar(),
1521 #endif
1522  "BL_LogFileClosed ",
1523  file.toChar()
1524  );
1525 
1526  this->m_eventOutText_OutputPort[0].invoke(
1527  _id,
1528  _logTime,
1530  _logString
1531  );
1532  }
1533 #endif
1534  }
1535 
1538  U32 errornum,
1539  const Fw::StringBase& file
1540  ) const
1541  {
1542  // Get the time
1543  Fw::Time _logTime;
1544  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1545  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1546  }
1547 
1548  FwEventIdType _id = static_cast<FwEventIdType>(0);
1549 
1550  _id = this->getIdBase() + EVENTID_BL_LOGFILEOPENERROR;
1551 
1552  // Emit the event on the log port
1553  if (this->m_eventOut_OutputPort[0].isConnected()) {
1554  Fw::LogBuffer _logBuff;
1556 
1557 #if FW_AMPCS_COMPATIBLE
1558  // Serialize the number of arguments
1559  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1560  FW_ASSERT(
1561  _status == Fw::FW_SERIALIZE_OK,
1562  static_cast<FwAssertArgType>(_status)
1563  );
1564 #endif
1565 
1566 #if FW_AMPCS_COMPATIBLE
1567  // Serialize the argument size
1568  _status = _logBuff.serializeFrom(
1569  static_cast<U8>(sizeof(U32))
1570  );
1571  FW_ASSERT(
1572  _status == Fw::FW_SERIALIZE_OK,
1573  static_cast<FwAssertArgType>(_status)
1574  );
1575 #endif
1576  _status = _logBuff.serializeFrom(errornum);
1577  FW_ASSERT(
1578  _status == Fw::FW_SERIALIZE_OK,
1579  static_cast<FwAssertArgType>(_status)
1580  );
1581 
1582  _status = file.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 256));
1583  FW_ASSERT(
1584  _status == Fw::FW_SERIALIZE_OK,
1585  static_cast<FwAssertArgType>(_status)
1586  );
1587 
1588  this->m_eventOut_OutputPort[0].invoke(
1589  _id,
1590  _logTime,
1592  _logBuff
1593  );
1594  }
1595 
1596  // Emit the event on the text log port
1597 #if FW_ENABLE_TEXT_LOGGING
1598  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1599 #if FW_OBJECT_NAMES == 1
1600  const char* _formatString =
1601  "(%s) %s: Error %" PRIu32 " opening file %s";
1602 #else
1603  const char* _formatString =
1604  "%s: Error %" PRIu32 " opening file %s";
1605 #endif
1606 
1607  Fw::TextLogString _logString;
1608  _logString.format(
1609  _formatString,
1610 #if FW_OBJECT_NAMES == 1
1611  this->m_objName.toChar(),
1612 #endif
1613  "BL_LogFileOpenError ",
1614  errornum,
1615  file.toChar()
1616  );
1617 
1618  this->m_eventOutText_OutputPort[0].invoke(
1619  _id,
1620  _logTime,
1622  _logString
1623  );
1624  }
1625 #endif
1626  }
1627 
1630  const Fw::StringBase& validationFile,
1631  U32 status
1632  ) const
1633  {
1634  // Get the time
1635  Fw::Time _logTime;
1636  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1637  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1638  }
1639 
1640  FwEventIdType _id = static_cast<FwEventIdType>(0);
1641 
1643 
1644  // Emit the event on the log port
1645  if (this->m_eventOut_OutputPort[0].isConnected()) {
1646  Fw::LogBuffer _logBuff;
1648 
1649 #if FW_AMPCS_COMPATIBLE
1650  // Serialize the number of arguments
1651  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1652  FW_ASSERT(
1653  _status == Fw::FW_SERIALIZE_OK,
1654  static_cast<FwAssertArgType>(_status)
1655  );
1656 #endif
1657 
1658  _status = validationFile.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 256));
1659  FW_ASSERT(
1660  _status == Fw::FW_SERIALIZE_OK,
1661  static_cast<FwAssertArgType>(_status)
1662  );
1663 
1664 #if FW_AMPCS_COMPATIBLE
1665  // Serialize the argument size
1666  _status = _logBuff.serializeFrom(
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.serializeFrom(status);
1675  FW_ASSERT(
1676  _status == Fw::FW_SERIALIZE_OK,
1677  static_cast<FwAssertArgType>(_status)
1678  );
1679 
1680  this->m_eventOut_OutputPort[0].invoke(
1681  _id,
1682  _logTime,
1684  _logBuff
1685  );
1686  }
1687 
1688  // Emit the event on the text log port
1689 #if FW_ENABLE_TEXT_LOGGING
1690  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1691 #if FW_OBJECT_NAMES == 1
1692  const char* _formatString =
1693  "(%s) %s: Failed creating validation file %s with status %" PRIu32 "";
1694 #else
1695  const char* _formatString =
1696  "%s: Failed creating validation file %s with status %" PRIu32 "";
1697 #endif
1698 
1699  Fw::TextLogString _logString;
1700  _logString.format(
1701  _formatString,
1702 #if FW_OBJECT_NAMES == 1
1703  this->m_objName.toChar(),
1704 #endif
1705  "BL_LogFileValidationError ",
1706  validationFile.toChar(),
1707  status
1708  );
1709 
1710  this->m_eventOutText_OutputPort[0].invoke(
1711  _id,
1712  _logTime,
1714  _logString
1715  );
1716  }
1717 #endif
1718  }
1719 
1722  U32 errornum,
1723  U32 bytesWritten,
1724  U32 bytesToWrite,
1725  const Fw::StringBase& file
1726  ) const
1727  {
1728  // Get the time
1729  Fw::Time _logTime;
1730  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1731  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1732  }
1733 
1734  FwEventIdType _id = static_cast<FwEventIdType>(0);
1735 
1736  _id = this->getIdBase() + EVENTID_BL_LOGFILEWRITEERROR;
1737 
1738  // Emit the event on the log port
1739  if (this->m_eventOut_OutputPort[0].isConnected()) {
1740  Fw::LogBuffer _logBuff;
1742 
1743 #if FW_AMPCS_COMPATIBLE
1744  // Serialize the number of arguments
1745  _status = _logBuff.serializeFrom(static_cast<U8>(4));
1746  FW_ASSERT(
1747  _status == Fw::FW_SERIALIZE_OK,
1748  static_cast<FwAssertArgType>(_status)
1749  );
1750 #endif
1751 
1752 #if FW_AMPCS_COMPATIBLE
1753  // Serialize the argument size
1754  _status = _logBuff.serializeFrom(
1755  static_cast<U8>(sizeof(U32))
1756  );
1757  FW_ASSERT(
1758  _status == Fw::FW_SERIALIZE_OK,
1759  static_cast<FwAssertArgType>(_status)
1760  );
1761 #endif
1762  _status = _logBuff.serializeFrom(errornum);
1763  FW_ASSERT(
1764  _status == Fw::FW_SERIALIZE_OK,
1765  static_cast<FwAssertArgType>(_status)
1766  );
1767 
1768 #if FW_AMPCS_COMPATIBLE
1769  // Serialize the argument size
1770  _status = _logBuff.serializeFrom(
1771  static_cast<U8>(sizeof(U32))
1772  );
1773  FW_ASSERT(
1774  _status == Fw::FW_SERIALIZE_OK,
1775  static_cast<FwAssertArgType>(_status)
1776  );
1777 #endif
1778  _status = _logBuff.serializeFrom(bytesWritten);
1779  FW_ASSERT(
1780  _status == Fw::FW_SERIALIZE_OK,
1781  static_cast<FwAssertArgType>(_status)
1782  );
1783 
1784 #if FW_AMPCS_COMPATIBLE
1785  // Serialize the argument size
1786  _status = _logBuff.serializeFrom(
1787  static_cast<U8>(sizeof(U32))
1788  );
1789  FW_ASSERT(
1790  _status == Fw::FW_SERIALIZE_OK,
1791  static_cast<FwAssertArgType>(_status)
1792  );
1793 #endif
1794  _status = _logBuff.serializeFrom(bytesToWrite);
1795  FW_ASSERT(
1796  _status == Fw::FW_SERIALIZE_OK,
1797  static_cast<FwAssertArgType>(_status)
1798  );
1799 
1800  _status = file.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 256));
1801  FW_ASSERT(
1802  _status == Fw::FW_SERIALIZE_OK,
1803  static_cast<FwAssertArgType>(_status)
1804  );
1805 
1806  this->m_eventOut_OutputPort[0].invoke(
1807  _id,
1808  _logTime,
1810  _logBuff
1811  );
1812  }
1813 
1814  // Emit the event on the text log port
1815 #if FW_ENABLE_TEXT_LOGGING
1816  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1817 #if FW_OBJECT_NAMES == 1
1818  const char* _formatString =
1819  "(%s) %s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1820 #else
1821  const char* _formatString =
1822  "%s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
1823 #endif
1824 
1825  Fw::TextLogString _logString;
1826  _logString.format(
1827  _formatString,
1828 #if FW_OBJECT_NAMES == 1
1829  this->m_objName.toChar(),
1830 #endif
1831  "BL_LogFileWriteError ",
1832  errornum,
1833  bytesWritten,
1834  bytesToWrite,
1835  file.toChar()
1836  );
1837 
1838  this->m_eventOutText_OutputPort[0].invoke(
1839  _id,
1840  _logTime,
1842  _logString
1843  );
1844  }
1845 #endif
1846  }
1847 
1850  {
1851  // Get the time
1852  Fw::Time _logTime;
1853  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1854  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1855  }
1856 
1857  FwEventIdType _id = static_cast<FwEventIdType>(0);
1858 
1859  _id = this->getIdBase() + EVENTID_BL_ACTIVATED;
1860 
1861  // Emit the event on the log port
1862  if (this->m_eventOut_OutputPort[0].isConnected()) {
1863  Fw::LogBuffer _logBuff;
1864 
1865 #if FW_AMPCS_COMPATIBLE
1867  // Serialize the number of arguments
1868  _status = _logBuff.serializeFrom(static_cast<U8>(0));
1869  FW_ASSERT(
1870  _status == Fw::FW_SERIALIZE_OK,
1871  static_cast<FwAssertArgType>(_status)
1872  );
1873 #endif
1874 
1875  this->m_eventOut_OutputPort[0].invoke(
1876  _id,
1877  _logTime,
1879  _logBuff
1880  );
1881  }
1882 
1883  // Emit the event on the text log port
1884 #if FW_ENABLE_TEXT_LOGGING
1885  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1886 #if FW_OBJECT_NAMES == 1
1887  const char* _formatString =
1888  "(%s) %s: Buffer logger was activated";
1889 #else
1890  const char* _formatString =
1891  "%s: Buffer logger was activated";
1892 #endif
1893 
1894  Fw::TextLogString _logString;
1895  _logString.format(
1896  _formatString,
1897 #if FW_OBJECT_NAMES == 1
1898  this->m_objName.toChar(),
1899 #endif
1900  "BL_Activated "
1901  );
1902 
1903  this->m_eventOutText_OutputPort[0].invoke(
1904  _id,
1905  _logTime,
1907  _logString
1908  );
1909  }
1910 #endif
1911  }
1912 
1915  {
1916  // Get the time
1917  Fw::Time _logTime;
1918  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1919  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1920  }
1921 
1922  FwEventIdType _id = static_cast<FwEventIdType>(0);
1923 
1924  _id = this->getIdBase() + EVENTID_BL_DEACTIVATED;
1925 
1926  // Emit the event on the log port
1927  if (this->m_eventOut_OutputPort[0].isConnected()) {
1928  Fw::LogBuffer _logBuff;
1929 
1930 #if FW_AMPCS_COMPATIBLE
1932  // Serialize the number of arguments
1933  _status = _logBuff.serializeFrom(static_cast<U8>(0));
1934  FW_ASSERT(
1935  _status == Fw::FW_SERIALIZE_OK,
1936  static_cast<FwAssertArgType>(_status)
1937  );
1938 #endif
1939 
1940  this->m_eventOut_OutputPort[0].invoke(
1941  _id,
1942  _logTime,
1944  _logBuff
1945  );
1946  }
1947 
1948  // Emit the event on the text log port
1949 #if FW_ENABLE_TEXT_LOGGING
1950  if (this->m_eventOutText_OutputPort[0].isConnected()) {
1951 #if FW_OBJECT_NAMES == 1
1952  const char* _formatString =
1953  "(%s) %s: Buffer logger was deactivated";
1954 #else
1955  const char* _formatString =
1956  "%s: Buffer logger was deactivated";
1957 #endif
1958 
1959  Fw::TextLogString _logString;
1960  _logString.format(
1961  _formatString,
1962 #if FW_OBJECT_NAMES == 1
1963  this->m_objName.toChar(),
1964 #endif
1965  "BL_Deactivated "
1966  );
1967 
1968  this->m_eventOutText_OutputPort[0].invoke(
1969  _id,
1970  _logTime,
1972  _logString
1973  );
1974  }
1975 #endif
1976  }
1977 
1980  {
1981  // Get the time
1982  Fw::Time _logTime;
1983  if (this->m_timeCaller_OutputPort[0].isConnected()) {
1984  this->m_timeCaller_OutputPort[0].invoke(_logTime);
1985  }
1986 
1987  FwEventIdType _id = static_cast<FwEventIdType>(0);
1988 
1990 
1991  // Emit the event on the log port
1992  if (this->m_eventOut_OutputPort[0].isConnected()) {
1993  Fw::LogBuffer _logBuff;
1994 
1995 #if FW_AMPCS_COMPATIBLE
1997  // Serialize the number of arguments
1998  _status = _logBuff.serializeFrom(static_cast<U8>(0));
1999  FW_ASSERT(
2000  _status == Fw::FW_SERIALIZE_OK,
2001  static_cast<FwAssertArgType>(_status)
2002  );
2003 #endif
2004 
2005  this->m_eventOut_OutputPort[0].invoke(
2006  _id,
2007  _logTime,
2009  _logBuff
2010  );
2011  }
2012 
2013  // Emit the event on the text log port
2014 #if FW_ENABLE_TEXT_LOGGING
2015  if (this->m_eventOutText_OutputPort[0].isConnected()) {
2016 #if FW_OBJECT_NAMES == 1
2017  const char* _formatString =
2018  "(%s) %s: No log file open command";
2019 #else
2020  const char* _formatString =
2021  "%s: No log file open command";
2022 #endif
2023 
2024  Fw::TextLogString _logString;
2025  _logString.format(
2026  _formatString,
2027 #if FW_OBJECT_NAMES == 1
2028  this->m_objName.toChar(),
2029 #endif
2030  "BL_NoLogFileOpenInitError "
2031  );
2032 
2033  this->m_eventOutText_OutputPort[0].invoke(
2034  _id,
2035  _logTime,
2037  _logString
2038  );
2039  }
2040 #endif
2041  }
2042 
2043  // ----------------------------------------------------------------------
2044  // Telemetry write functions
2045  // ----------------------------------------------------------------------
2046 
2049  U32 arg,
2050  Fw::Time _tlmTime
2051  ) const
2052  {
2053  if (this->m_tlmOut_OutputPort[0].isConnected()) {
2054  if (
2055  this->m_timeCaller_OutputPort[0].isConnected() &&
2056  (_tlmTime == Fw::ZERO_TIME)
2057  ) {
2058  this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2059  }
2060 
2061  Fw::TlmBuffer _tlmBuff;
2062  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2063  FW_ASSERT(
2064  _stat == Fw::FW_SERIALIZE_OK,
2065  static_cast<FwAssertArgType>(_stat)
2066  );
2067 
2068  FwChanIdType _id;
2069 
2071 
2072  this->m_tlmOut_OutputPort[0].invoke(
2073  _id,
2074  _tlmTime,
2075  _tlmBuff
2076  );
2077  }
2078  }
2079 
2080  // ----------------------------------------------------------------------
2081  // Time
2082  // ----------------------------------------------------------------------
2083 
2085  getTime() const
2086  {
2087  if (this->m_timeCaller_OutputPort[0].isConnected()) {
2088  Fw::Time _time;
2089  this->m_timeCaller_OutputPort[0].invoke(_time);
2090  return _time;
2091  }
2092  else {
2093  return Fw::Time(TimeBase::TB_NONE, 0, 0);
2094  }
2095  }
2096 
2097  // ----------------------------------------------------------------------
2098  // Message dispatch functions
2099  // ----------------------------------------------------------------------
2100 
2101  Fw::QueuedComponentBase::MsgDispatchStatus BufferLoggerComponentBase ::
2102  doDispatch()
2103  {
2104  ComponentIpcSerializableBuffer _msg;
2105  FwQueuePriorityType _priority = 0;
2106 
2107  Os::Queue::Status _msgStatus = this->m_queue.receive(
2108  _msg,
2110  _priority
2111  );
2112  FW_ASSERT(
2113  _msgStatus == Os::Queue::OP_OK,
2114  static_cast<FwAssertArgType>(_msgStatus)
2115  );
2116 
2117  // Reset to beginning of buffer
2118  _msg.resetDeser();
2119 
2120  FwEnumStoreType _desMsg = 0;
2121  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
2122  FW_ASSERT(
2123  _deserStatus == Fw::FW_SERIALIZE_OK,
2124  static_cast<FwAssertArgType>(_deserStatus)
2125  );
2126 
2127  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
2128 
2129  if (_msgType == BUFFERLOGGER_COMPONENT_EXIT) {
2130  return MSG_DISPATCH_EXIT;
2131  }
2132 
2133  FwIndexType portNum = 0;
2134  _deserStatus = _msg.deserializeTo(portNum);
2135  FW_ASSERT(
2136  _deserStatus == Fw::FW_SERIALIZE_OK,
2137  static_cast<FwAssertArgType>(_deserStatus)
2138  );
2139 
2140  switch (_msgType) {
2141  // Handle async input port bufferSendIn
2142  case BUFFERSENDIN_BUFFERSEND: {
2143  // Deserialize argument fwBuffer
2144  Fw::Buffer fwBuffer;
2145  _deserStatus = _msg.deserializeTo(fwBuffer);
2146  FW_ASSERT(
2147  _deserStatus == Fw::FW_SERIALIZE_OK,
2148  static_cast<FwAssertArgType>(_deserStatus)
2149  );
2150  // Call handler function
2151  this->bufferSendIn_handler(
2152  portNum,
2153  fwBuffer
2154  );
2155 
2156  break;
2157  }
2158 
2159  // Handle async input port comIn
2160  case COMIN_COM: {
2161  // Deserialize argument data
2162  Fw::ComBuffer data;
2163  _deserStatus = _msg.deserializeTo(data);
2164  FW_ASSERT(
2165  _deserStatus == Fw::FW_SERIALIZE_OK,
2166  static_cast<FwAssertArgType>(_deserStatus)
2167  );
2168 
2169  // Deserialize argument context
2170  U32 context;
2171  _deserStatus = _msg.deserializeTo(context);
2172  FW_ASSERT(
2173  _deserStatus == Fw::FW_SERIALIZE_OK,
2174  static_cast<FwAssertArgType>(_deserStatus)
2175  );
2176  // Call handler function
2177  this->comIn_handler(
2178  portNum,
2179  data,
2180  context
2181  );
2182 
2183  break;
2184  }
2185 
2186  // Handle async input port pingIn
2187  case PINGIN_PING: {
2188  // Deserialize argument key
2189  U32 key;
2190  _deserStatus = _msg.deserializeTo(key);
2191  FW_ASSERT(
2192  _deserStatus == Fw::FW_SERIALIZE_OK,
2193  static_cast<FwAssertArgType>(_deserStatus)
2194  );
2195  // Call handler function
2196  this->pingIn_handler(
2197  portNum,
2198  key
2199  );
2200 
2201  break;
2202  }
2203 
2204  // Handle async input port schedIn
2205  case SCHEDIN_SCHED: {
2206  // Deserialize argument context
2207  U32 context;
2208  _deserStatus = _msg.deserializeTo(context);
2209  FW_ASSERT(
2210  _deserStatus == Fw::FW_SERIALIZE_OK,
2211  static_cast<FwAssertArgType>(_deserStatus)
2212  );
2213  // Call handler function
2214  this->schedIn_handler(
2215  portNum,
2216  context
2217  );
2218 
2219  break;
2220  }
2221 
2222  // Handle command BL_OpenFile
2223  case CMD_BL_OPENFILE: {
2224  // Deserialize opcode
2225  FwOpcodeType _opCode = 0;
2226  _deserStatus = _msg.deserializeTo(_opCode);
2227  FW_ASSERT (
2228  _deserStatus == Fw::FW_SERIALIZE_OK,
2229  static_cast<FwAssertArgType>(_deserStatus)
2230  );
2231 
2232  // Deserialize command sequence
2233  U32 _cmdSeq = 0;
2234  _deserStatus = _msg.deserializeTo(_cmdSeq);
2235  FW_ASSERT (
2236  _deserStatus == Fw::FW_SERIALIZE_OK,
2237  static_cast<FwAssertArgType>(_deserStatus)
2238  );
2239 
2240  // Deserialize command argument buffer
2241  Fw::CmdArgBuffer args;
2242  _deserStatus = _msg.deserializeTo(args);
2243  FW_ASSERT (
2244  _deserStatus == Fw::FW_SERIALIZE_OK,
2245  static_cast<FwAssertArgType>(_deserStatus)
2246  );
2247 
2248  // Reset buffer
2249  args.resetDeser();
2250 
2251  // Deserialize argument file
2252  Fw::CmdStringArg file;
2253  _deserStatus = args.deserializeTo(file);
2254  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2255  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2256  this->cmdResponse_out(
2257  _opCode,
2258  _cmdSeq,
2260  );
2261  }
2262  // Don't crash the task if bad arguments were passed from the ground
2263  break;
2264  }
2265 
2266  // Make sure there was no data left over.
2267  // That means the argument buffer size was incorrect.
2268 #if FW_CMD_CHECK_RESIDUAL
2269  if (args.getDeserializeSizeLeft() != 0) {
2270  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2271  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2272  }
2273  // Don't crash the task if bad arguments were passed from the ground
2274  break;
2275  }
2276 #endif
2277 
2278  // Call handler function
2279  this->BL_OpenFile_cmdHandler(
2280  _opCode, _cmdSeq,
2281  file
2282  );
2283 
2284  break;
2285  }
2286 
2287  // Handle command BL_CloseFile
2288  case CMD_BL_CLOSEFILE: {
2289  // Deserialize opcode
2290  FwOpcodeType _opCode = 0;
2291  _deserStatus = _msg.deserializeTo(_opCode);
2292  FW_ASSERT (
2293  _deserStatus == Fw::FW_SERIALIZE_OK,
2294  static_cast<FwAssertArgType>(_deserStatus)
2295  );
2296 
2297  // Deserialize command sequence
2298  U32 _cmdSeq = 0;
2299  _deserStatus = _msg.deserializeTo(_cmdSeq);
2300  FW_ASSERT (
2301  _deserStatus == Fw::FW_SERIALIZE_OK,
2302  static_cast<FwAssertArgType>(_deserStatus)
2303  );
2304 
2305  // Deserialize command argument buffer
2306  Fw::CmdArgBuffer args;
2307  _deserStatus = _msg.deserializeTo(args);
2308  FW_ASSERT (
2309  _deserStatus == Fw::FW_SERIALIZE_OK,
2310  static_cast<FwAssertArgType>(_deserStatus)
2311  );
2312 
2313  // Reset buffer
2314  args.resetDeser();
2315 
2316  // Make sure there was no data left over.
2317  // That means the argument buffer size was incorrect.
2318 #if FW_CMD_CHECK_RESIDUAL
2319  if (args.getDeserializeSizeLeft() != 0) {
2320  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2321  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2322  }
2323  // Don't crash the task if bad arguments were passed from the ground
2324  break;
2325  }
2326 #endif
2327 
2328  // Call handler function
2329  this->BL_CloseFile_cmdHandler(_opCode, _cmdSeq);
2330 
2331  break;
2332  }
2333 
2334  // Handle command BL_SetLogging
2335  case CMD_BL_SETLOGGING: {
2336  // Deserialize opcode
2337  FwOpcodeType _opCode = 0;
2338  _deserStatus = _msg.deserializeTo(_opCode);
2339  FW_ASSERT (
2340  _deserStatus == Fw::FW_SERIALIZE_OK,
2341  static_cast<FwAssertArgType>(_deserStatus)
2342  );
2343 
2344  // Deserialize command sequence
2345  U32 _cmdSeq = 0;
2346  _deserStatus = _msg.deserializeTo(_cmdSeq);
2347  FW_ASSERT (
2348  _deserStatus == Fw::FW_SERIALIZE_OK,
2349  static_cast<FwAssertArgType>(_deserStatus)
2350  );
2351 
2352  // Deserialize command argument buffer
2353  Fw::CmdArgBuffer args;
2354  _deserStatus = _msg.deserializeTo(args);
2355  FW_ASSERT (
2356  _deserStatus == Fw::FW_SERIALIZE_OK,
2357  static_cast<FwAssertArgType>(_deserStatus)
2358  );
2359 
2360  // Reset buffer
2361  args.resetDeser();
2362 
2363  // Deserialize argument state
2365  _deserStatus = args.deserializeTo(state);
2366  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2367  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2368  this->cmdResponse_out(
2369  _opCode,
2370  _cmdSeq,
2372  );
2373  }
2374  // Don't crash the task if bad arguments were passed from the ground
2375  break;
2376  }
2377 
2378  // Make sure there was no data left over.
2379  // That means the argument buffer size was incorrect.
2380 #if FW_CMD_CHECK_RESIDUAL
2381  if (args.getDeserializeSizeLeft() != 0) {
2382  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2383  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2384  }
2385  // Don't crash the task if bad arguments were passed from the ground
2386  break;
2387  }
2388 #endif
2389 
2390  // Call handler function
2392  _opCode, _cmdSeq,
2393  state
2394  );
2395 
2396  break;
2397  }
2398 
2399  // Handle command BL_FlushFile
2400  case CMD_BL_FLUSHFILE: {
2401  // Deserialize opcode
2402  FwOpcodeType _opCode = 0;
2403  _deserStatus = _msg.deserializeTo(_opCode);
2404  FW_ASSERT (
2405  _deserStatus == Fw::FW_SERIALIZE_OK,
2406  static_cast<FwAssertArgType>(_deserStatus)
2407  );
2408 
2409  // Deserialize command sequence
2410  U32 _cmdSeq = 0;
2411  _deserStatus = _msg.deserializeTo(_cmdSeq);
2412  FW_ASSERT (
2413  _deserStatus == Fw::FW_SERIALIZE_OK,
2414  static_cast<FwAssertArgType>(_deserStatus)
2415  );
2416 
2417  // Deserialize command argument buffer
2418  Fw::CmdArgBuffer args;
2419  _deserStatus = _msg.deserializeTo(args);
2420  FW_ASSERT (
2421  _deserStatus == Fw::FW_SERIALIZE_OK,
2422  static_cast<FwAssertArgType>(_deserStatus)
2423  );
2424 
2425  // Reset buffer
2426  args.resetDeser();
2427 
2428  // Make sure there was no data left over.
2429  // That means the argument buffer size was incorrect.
2430 #if FW_CMD_CHECK_RESIDUAL
2431  if (args.getDeserializeSizeLeft() != 0) {
2432  if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2433  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2434  }
2435  // Don't crash the task if bad arguments were passed from the ground
2436  break;
2437  }
2438 #endif
2439 
2440  // Call handler function
2441  this->BL_FlushFile_cmdHandler(_opCode, _cmdSeq);
2442 
2443  break;
2444  }
2445 
2446  default:
2447  return MSG_DISPATCH_ERROR;
2448  }
2449 
2450  return MSG_DISPATCH_OK;
2451  }
2452 
2453  // ----------------------------------------------------------------------
2454  // Calls for messages received on special input ports
2455  // ----------------------------------------------------------------------
2456 
2457  void BufferLoggerComponentBase ::
2458  m_p_cmdIn_in(
2459  Fw::PassiveComponentBase* callComp,
2460  FwIndexType portNum,
2461  FwOpcodeType opCode,
2462  U32 cmdSeq,
2463  Fw::CmdArgBuffer& args
2464  )
2465  {
2466  FW_ASSERT(callComp);
2467  BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2468 
2469  const U32 idBase = callComp->getIdBase();
2470  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
2471 
2472  // Select base class function based on opcode
2473  switch (opCode - idBase) {
2474  case OPCODE_BL_OPENFILE: {
2475  compPtr->BL_OpenFile_cmdHandlerBase(
2476  opCode,
2477  cmdSeq,
2478  args
2479  );
2480  break;
2481  }
2482 
2483  case OPCODE_BL_CLOSEFILE: {
2484  compPtr->BL_CloseFile_cmdHandlerBase(
2485  opCode,
2486  cmdSeq,
2487  args
2488  );
2489  break;
2490  }
2491 
2492  case OPCODE_BL_SETLOGGING: {
2493  compPtr->BL_SetLogging_cmdHandlerBase(
2494  opCode,
2495  cmdSeq,
2496  args
2497  );
2498  break;
2499  }
2500 
2501  case OPCODE_BL_FLUSHFILE: {
2502  compPtr->BL_FlushFile_cmdHandlerBase(
2503  opCode,
2504  cmdSeq,
2505  args
2506  );
2507  break;
2508  }
2509  }
2510  }
2511 
2512  // ----------------------------------------------------------------------
2513  // Calls for messages received on typed input ports
2514  // ----------------------------------------------------------------------
2515 
2516  void BufferLoggerComponentBase ::
2517  m_p_bufferSendIn_in(
2518  Fw::PassiveComponentBase* callComp,
2519  FwIndexType portNum,
2520  Fw::Buffer& fwBuffer
2521  )
2522  {
2523  FW_ASSERT(callComp);
2524  BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2525  compPtr->bufferSendIn_handlerBase(
2526  portNum,
2527  fwBuffer
2528  );
2529  }
2530 
2531  void BufferLoggerComponentBase ::
2532  m_p_comIn_in(
2533  Fw::PassiveComponentBase* callComp,
2534  FwIndexType portNum,
2535  Fw::ComBuffer& data,
2536  U32 context
2537  )
2538  {
2539  FW_ASSERT(callComp);
2540  BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2541  compPtr->comIn_handlerBase(
2542  portNum,
2543  data,
2544  context
2545  );
2546  }
2547 
2548  void BufferLoggerComponentBase ::
2549  m_p_pingIn_in(
2550  Fw::PassiveComponentBase* callComp,
2551  FwIndexType portNum,
2552  U32 key
2553  )
2554  {
2555  FW_ASSERT(callComp);
2556  BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2557  compPtr->pingIn_handlerBase(
2558  portNum,
2559  key
2560  );
2561  }
2562 
2563  void BufferLoggerComponentBase ::
2564  m_p_schedIn_in(
2565  Fw::PassiveComponentBase* callComp,
2566  FwIndexType portNum,
2567  U32 context
2568  )
2569  {
2570  FW_ASSERT(callComp);
2571  BufferLoggerComponentBase* compPtr = static_cast<BufferLoggerComponentBase*>(callComp);
2572  compPtr->schedIn_handlerBase(
2573  portNum,
2574  context
2575  );
2576  }
2577 
2578 }
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
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.
FwIdType FwOpcodeType
The type of a command opcode.
Operation succeeded.
Definition: Os.hpp:26
Svc::InputSchedPort * get_schedIn_InputPort(FwIndexType portNum)
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
PlatformSizeType FwSizeType
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum)
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
Definition: Queue.cpp:71
I32 FwEnumStoreType
virtual void schedIn_preMsgHook(FwIndexType portNum, U32 context)
Pre-message hook for async input port schedIn.
static constexpr FwIndexType getNum_pingIn_InputPorts()
Status
status returned from the queue send function
Definition: Queue.hpp:30
The Buffer Logger encountered an error writing a validation file.
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.
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:38
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)
void invoke(U32 key) const
Invoke a port interface.
Definition: PingPortAc.cpp:147
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
virtual const CHAR * toChar() const =0
Convert to a C-style char*.
const Time ZERO_TIME
Definition: Time.cpp:5
virtual void BL_SetLogging_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Svc::BufferLogger_LogState state)=0
The Buffer Logger encountered an error opening a log file.
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)
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.
No time base has been established (Required)
No log file open command was received by BufferLogger.
message to exit active component task
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
static constexpr FwIndexType getNum_timeCaller_OutputPorts()
bool isConnected_eventOut_OutputPort(FwIndexType portNum)
Os::Queue m_queue
queue object for active component
Software diagnostic events.
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.
void init()
Object initializer.
Definition: ObjBase.cpp:24
void init()
Initialization function.
Definition: ComPortAc.cpp:56
SerializeStatus
forward declaration for string
Close the currently open log file, if any.
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
Message will block until space is available.
Definition: Queue.hpp:47
void log_WARNING_HI_BL_LogFileOpenError(U32 errornum, const Fw::StringBase &file) const
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
FwIdType FwEventIdType
The type of an event identifier.
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.
static constexpr FwIndexType getNum_schedIn_InputPorts()
void invoke(FwOpcodeType opCode) const
Invoke a port interface.
static constexpr FwIndexType getNum_cmdRegOut_OutputPorts()
void set_bufferSendOut_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to bufferSendOut[portNum].
Fw::InputCmdPort * get_cmdIn_InputPort(FwIndexType portNum)
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:26
static constexpr FwIndexType getNum_cmdIn_InputPorts()
void init()
Initialization function.
Definition: TimePortAc.cpp:128
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:92
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
Serializable::SizeType getDeserializeSizeLeft() const override
Get remaining deserialization buffer size.
const char * toChar() const
Convert to a C-style char*.
Definition: ObjectName.hpp:50
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke a port interface.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
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
Definition: Queue.cpp:54
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
void resetDeser() override
Reset deserialization pointer to beginning of buffer.
BufferLoggerComponentBase(const char *compName="")
Construct BufferLoggerComponentBase object.
virtual void schedIn_handler(FwIndexType portNum, U32 context)=0
Handler for input port schedIn.
Open a new log file with specified name; also resets unique file counter to 0.
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:38
Fw::InputBufferSendPort * get_bufferSendIn_InputPort(FwIndexType portNum)
#define PRI_FwIndexType
static constexpr FwIndexType getNum_eventOut_OutputPorts()
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
BlockingType
message type
Definition: Queue.hpp:46
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
Fw::InputComPort * get_comIn_InputPort(FwIndexType portNum)
Command failed to deserialize.
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
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
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.
static constexpr FwIndexType getNum_bufferSendOut_OutputPorts()
The size of the serial representations of the port arguments.
The size of the serial representations of the port arguments.
Definition: SchedPortAc.hpp:36
A message was sent requesting an exit of the loop.
virtual ~BufferLoggerComponentBase()
Destroy BufferLoggerComponentBase object.
PlatformIndexType FwIndexType
static constexpr FwIndexType getNum_pingOut_OutputPorts()
static constexpr FwIndexType getNum_tlmOut_OutputPorts()
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
void init()
Initialization function.
void init()
Initialization function.
Definition: PingPortAc.cpp:56
RateGroupDivider component implementation.
message sent/received okay
Definition: Queue.hpp:31
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG) override
Deserialize an 8-bit unsigned integer value.
U8 BYTE
byte type
Definition: BasicTypes.h:56
static constexpr FwIndexType getNum_cmdResponseOut_OutputPorts()
The Buffer Logger encountered an error writing to a log file.
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:48
Implementation of malloc based allocator.
static constexpr FwIndexType getNum_bufferSendIn_InputPorts()
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_comIn_InputPorts()
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
Flushes the current open log file to disk; a no-op with fprime&#39;s unbuffered file I/O, so always returns success.
virtual void BL_OpenFile_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg &file)=0
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
void log_WARNING_HI_BL_LogFileValidationError(const Fw::StringBase &validationFile, U32 status) const
The size of the serial representations of the port arguments.
Definition: ComPortAc.hpp:37
SerializeStatus serializeTo(SerialBufferBase &buffer, Endianness mode=Endianness::BIG) const override
Serialize the contents of this object to a buffer.
void set_cmdRegOut_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegOut[portNum].