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