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