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