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