F´ Flight Software - C/C++ Documentation devel
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
FileUplinkComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title FileUplinkComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for FileUplink 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 FILEUPLINK_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
20 BUFFERSENDIN_BUFFERSEND,
21 PINGIN_PING,
22 };
23
24 // Get the max size by constructing a union of the async input, command, and
25 // internal port serialization sizes
26 union BuffUnion {
29 };
30
31 // Define a message buffer class large enough to handle all the
32 // asynchronous inputs to the component
33 class ComponentIpcSerializableBuffer :
35 {
36
37 public:
38
39 enum {
40 // Max. message size = size of data + message id + port
41 SERIALIZATION_SIZE =
42 sizeof(BuffUnion) +
43 sizeof(NATIVE_INT_TYPE) +
44 sizeof(NATIVE_INT_TYPE)
45 };
46
47 NATIVE_UINT_TYPE getBuffCapacity() const {
48 return sizeof(m_buff);
49 }
50
51 U8* getBuffAddr() {
52 return m_buff;
53 }
54
55 const U8* getBuffAddr() const {
56 return m_buff;
57 }
58
59 private:
60 // Should be the max of all the input ports serialized sizes...
61 U8 m_buff[SERIALIZATION_SIZE];
62
63 };
64 }
65
66 // ----------------------------------------------------------------------
67 // Component initialization
68 // ----------------------------------------------------------------------
69
70 void FileUplinkComponentBase ::
71 init(
72 NATIVE_INT_TYPE queueDepth,
73 NATIVE_INT_TYPE instance
74 )
75 {
76 // Initialize base class
78
79 // Connect input port bufferSendIn
80 for (
81 PlatformIntType port = 0;
82 port < static_cast<PlatformIntType>(this->getNum_bufferSendIn_InputPorts());
83 port++
84 ) {
85 this->m_bufferSendIn_InputPort[port].init();
86 this->m_bufferSendIn_InputPort[port].addCallComp(
87 this,
88 m_p_bufferSendIn_in
89 );
90 this->m_bufferSendIn_InputPort[port].setPortNum(port);
91
92#if FW_OBJECT_NAMES == 1
93 char portName[120];
94 (void) snprintf(
95 portName,
96 sizeof(portName),
97 "%s_bufferSendIn_InputPort[%" PRI_PlatformIntType "]",
98 this->m_objName,
99 port
100 );
101 this->m_bufferSendIn_InputPort[port].setObjName(portName);
102#endif
103 }
104
105 // Connect input port pingIn
106 for (
107 PlatformIntType port = 0;
108 port < static_cast<PlatformIntType>(this->getNum_pingIn_InputPorts());
109 port++
110 ) {
111 this->m_pingIn_InputPort[port].init();
112 this->m_pingIn_InputPort[port].addCallComp(
113 this,
114 m_p_pingIn_in
115 );
116 this->m_pingIn_InputPort[port].setPortNum(port);
117
118#if FW_OBJECT_NAMES == 1
119 char portName[120];
120 (void) snprintf(
121 portName,
122 sizeof(portName),
123 "%s_pingIn_InputPort[%" PRI_PlatformIntType "]",
124 this->m_objName,
125 port
126 );
127 this->m_pingIn_InputPort[port].setObjName(portName);
128#endif
129 }
130
131#if FW_ENABLE_TEXT_LOGGING == 1
132 // Connect output port LogText
133 for (
134 PlatformIntType port = 0;
135 port < static_cast<PlatformIntType>(this->getNum_LogText_OutputPorts());
136 port++
137 ) {
138 this->m_LogText_OutputPort[port].init();
139
140#if FW_OBJECT_NAMES == 1
141 char portName[120];
142 (void) snprintf(
143 portName,
144 sizeof(portName),
145 "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
146 this->m_objName,
147 port
148 );
149 this->m_LogText_OutputPort[port].setObjName(portName);
150#endif
151 }
152#endif
153
154 // Connect output port eventOut
155 for (
156 PlatformIntType port = 0;
157 port < static_cast<PlatformIntType>(this->getNum_eventOut_OutputPorts());
158 port++
159 ) {
160 this->m_eventOut_OutputPort[port].init();
161
162#if FW_OBJECT_NAMES == 1
163 char portName[120];
164 (void) snprintf(
165 portName,
166 sizeof(portName),
167 "%s_eventOut_OutputPort[%" PRI_PlatformIntType "]",
168 this->m_objName,
169 port
170 );
171 this->m_eventOut_OutputPort[port].setObjName(portName);
172#endif
173 }
174
175 // Connect output port timeCaller
176 for (
177 PlatformIntType port = 0;
178 port < static_cast<PlatformIntType>(this->getNum_timeCaller_OutputPorts());
179 port++
180 ) {
181 this->m_timeCaller_OutputPort[port].init();
182
183#if FW_OBJECT_NAMES == 1
184 char portName[120];
185 (void) snprintf(
186 portName,
187 sizeof(portName),
188 "%s_timeCaller_OutputPort[%" PRI_PlatformIntType "]",
189 this->m_objName,
190 port
191 );
192 this->m_timeCaller_OutputPort[port].setObjName(portName);
193#endif
194 }
195
196 // Connect output port tlmOut
197 for (
198 PlatformIntType port = 0;
199 port < static_cast<PlatformIntType>(this->getNum_tlmOut_OutputPorts());
200 port++
201 ) {
202 this->m_tlmOut_OutputPort[port].init();
203
204#if FW_OBJECT_NAMES == 1
205 char portName[120];
206 (void) snprintf(
207 portName,
208 sizeof(portName),
209 "%s_tlmOut_OutputPort[%" PRI_PlatformIntType "]",
210 this->m_objName,
211 port
212 );
213 this->m_tlmOut_OutputPort[port].setObjName(portName);
214#endif
215 }
216
217 // Connect output port bufferSendOut
218 for (
219 PlatformIntType port = 0;
220 port < static_cast<PlatformIntType>(this->getNum_bufferSendOut_OutputPorts());
221 port++
222 ) {
223 this->m_bufferSendOut_OutputPort[port].init();
224
225#if FW_OBJECT_NAMES == 1
226 char portName[120];
227 (void) snprintf(
228 portName,
229 sizeof(portName),
230 "%s_bufferSendOut_OutputPort[%" PRI_PlatformIntType "]",
231 this->m_objName,
232 port
233 );
234 this->m_bufferSendOut_OutputPort[port].setObjName(portName);
235#endif
236 }
237
238 // Connect output port pingOut
239 for (
240 PlatformIntType port = 0;
241 port < static_cast<PlatformIntType>(this->getNum_pingOut_OutputPorts());
242 port++
243 ) {
244 this->m_pingOut_OutputPort[port].init();
245
246#if FW_OBJECT_NAMES == 1
247 char portName[120];
248 (void) snprintf(
249 portName,
250 sizeof(portName),
251 "%s_pingOut_OutputPort[%" PRI_PlatformIntType "]",
252 this->m_objName,
253 port
254 );
255 this->m_pingOut_OutputPort[port].setObjName(portName);
256#endif
257 }
258
259 Os::Queue::QueueStatus qStat = this->createQueue(
260 queueDepth,
261 ComponentIpcSerializableBuffer::SERIALIZATION_SIZE
262 );
263 FW_ASSERT(
264 Os::Queue::QUEUE_OK == qStat,
265 static_cast<FwAssertArgType>(qStat)
266 );
267 }
268
269 // ----------------------------------------------------------------------
270 // Getters for typed input ports
271 // ----------------------------------------------------------------------
272
273 Fw::InputBufferSendPort* FileUplinkComponentBase ::
274 get_bufferSendIn_InputPort(NATIVE_INT_TYPE portNum)
275 {
276 FW_ASSERT(
277 portNum < this->getNum_bufferSendIn_InputPorts(),
278 static_cast<FwAssertArgType>(portNum)
279 );
280
281 return &this->m_bufferSendIn_InputPort[portNum];
282 }
283
284 Svc::InputPingPort* FileUplinkComponentBase ::
285 get_pingIn_InputPort(NATIVE_INT_TYPE portNum)
286 {
287 FW_ASSERT(
288 portNum < this->getNum_pingIn_InputPorts(),
289 static_cast<FwAssertArgType>(portNum)
290 );
291
292 return &this->m_pingIn_InputPort[portNum];
293 }
294
295 // ----------------------------------------------------------------------
296 // Connect input ports to special output ports
297 // ----------------------------------------------------------------------
298
299#if FW_ENABLE_TEXT_LOGGING == 1
300
301 void FileUplinkComponentBase ::
302 set_LogText_OutputPort(
303 NATIVE_INT_TYPE portNum,
305 )
306 {
307 FW_ASSERT(
308 portNum < this->getNum_LogText_OutputPorts(),
309 static_cast<FwAssertArgType>(portNum)
310 );
311
312 this->m_LogText_OutputPort[portNum].addCallPort(port);
313 }
314
315#endif
316
317 void FileUplinkComponentBase ::
318 set_eventOut_OutputPort(
319 NATIVE_INT_TYPE portNum,
320 Fw::InputLogPort* port
321 )
322 {
323 FW_ASSERT(
324 portNum < this->getNum_eventOut_OutputPorts(),
325 static_cast<FwAssertArgType>(portNum)
326 );
327
328 this->m_eventOut_OutputPort[portNum].addCallPort(port);
329 }
330
331 void FileUplinkComponentBase ::
332 set_timeCaller_OutputPort(
333 NATIVE_INT_TYPE portNum,
335 )
336 {
337 FW_ASSERT(
338 portNum < this->getNum_timeCaller_OutputPorts(),
339 static_cast<FwAssertArgType>(portNum)
340 );
341
342 this->m_timeCaller_OutputPort[portNum].addCallPort(port);
343 }
344
345 void FileUplinkComponentBase ::
346 set_tlmOut_OutputPort(
347 NATIVE_INT_TYPE portNum,
348 Fw::InputTlmPort* port
349 )
350 {
351 FW_ASSERT(
352 portNum < this->getNum_tlmOut_OutputPorts(),
353 static_cast<FwAssertArgType>(portNum)
354 );
355
356 this->m_tlmOut_OutputPort[portNum].addCallPort(port);
357 }
358
359 // ----------------------------------------------------------------------
360 // Connect typed input ports to typed output ports
361 // ----------------------------------------------------------------------
362
363 void FileUplinkComponentBase ::
364 set_bufferSendOut_OutputPort(
365 NATIVE_INT_TYPE portNum,
367 )
368 {
369 FW_ASSERT(
370 portNum < this->getNum_bufferSendOut_OutputPorts(),
371 static_cast<FwAssertArgType>(portNum)
372 );
373
374 this->m_bufferSendOut_OutputPort[portNum].addCallPort(port);
375 }
376
377 void FileUplinkComponentBase ::
378 set_pingOut_OutputPort(
379 NATIVE_INT_TYPE portNum,
381 )
382 {
383 FW_ASSERT(
384 portNum < this->getNum_pingOut_OutputPorts(),
385 static_cast<FwAssertArgType>(portNum)
386 );
387
388 this->m_pingOut_OutputPort[portNum].addCallPort(port);
389 }
390
391#if FW_PORT_SERIALIZATION
392
393 // ----------------------------------------------------------------------
394 // Connect serial input ports to special output ports
395 // ----------------------------------------------------------------------
396
397#if FW_ENABLE_TEXT_LOGGING == 1
398
399 void FileUplinkComponentBase ::
400 set_LogText_OutputPort(
401 NATIVE_INT_TYPE portNum,
402 Fw::InputSerializePort* port
403 )
404 {
405 FW_ASSERT(
406 portNum < this->getNum_LogText_OutputPorts(),
407 static_cast<FwAssertArgType>(portNum)
408 );
409
410 this->m_LogText_OutputPort[portNum].registerSerialPort(port);
411 }
412
413#endif
414
415 void FileUplinkComponentBase ::
416 set_eventOut_OutputPort(
417 NATIVE_INT_TYPE portNum,
418 Fw::InputSerializePort* port
419 )
420 {
421 FW_ASSERT(
422 portNum < this->getNum_eventOut_OutputPorts(),
423 static_cast<FwAssertArgType>(portNum)
424 );
425
426 this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
427 }
428
429 void FileUplinkComponentBase ::
430 set_timeCaller_OutputPort(
431 NATIVE_INT_TYPE portNum,
432 Fw::InputSerializePort* port
433 )
434 {
435 FW_ASSERT(
436 portNum < this->getNum_timeCaller_OutputPorts(),
437 static_cast<FwAssertArgType>(portNum)
438 );
439
440 this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
441 }
442
443 void FileUplinkComponentBase ::
444 set_tlmOut_OutputPort(
445 NATIVE_INT_TYPE portNum,
446 Fw::InputSerializePort* port
447 )
448 {
449 FW_ASSERT(
450 portNum < this->getNum_tlmOut_OutputPorts(),
451 static_cast<FwAssertArgType>(portNum)
452 );
453
454 this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
455 }
456
457#endif
458
459#if FW_PORT_SERIALIZATION
460
461 // ----------------------------------------------------------------------
462 // Connect serial input ports to typed output ports
463 // ----------------------------------------------------------------------
464
465 void FileUplinkComponentBase ::
466 set_bufferSendOut_OutputPort(
467 NATIVE_INT_TYPE portNum,
468 Fw::InputSerializePort* port
469 )
470 {
471 FW_ASSERT(
472 portNum < this->getNum_bufferSendOut_OutputPorts(),
473 static_cast<FwAssertArgType>(portNum)
474 );
475
476 this->m_bufferSendOut_OutputPort[portNum].registerSerialPort(port);
477 }
478
479 void FileUplinkComponentBase ::
480 set_pingOut_OutputPort(
481 NATIVE_INT_TYPE portNum,
482 Fw::InputSerializePort* port
483 )
484 {
485 FW_ASSERT(
486 portNum < this->getNum_pingOut_OutputPorts(),
487 static_cast<FwAssertArgType>(portNum)
488 );
489
490 this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
491 }
492
493#endif
494
495 // ----------------------------------------------------------------------
496 // Component construction and destruction
497 // ----------------------------------------------------------------------
498
499 FileUplinkComponentBase ::
500 FileUplinkComponentBase(const char* compName) :
501 Fw::ActiveComponentBase(compName)
502 {
503 this->m_FileWriteErrorThrottle = 0;
504 this->m_InvalidReceiveModeThrottle = 0;
505 this->m_PacketOutOfBoundsThrottle = 0;
506 this->m_PacketOutOfOrderThrottle = 0;
507 }
508
509 FileUplinkComponentBase ::
510 ~FileUplinkComponentBase()
511 {
512
513 }
514
515 // ----------------------------------------------------------------------
516 // Getters for numbers of typed input ports
517 // ----------------------------------------------------------------------
518
519 NATIVE_INT_TYPE FileUplinkComponentBase ::
520 getNum_bufferSendIn_InputPorts() const
521 {
522 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferSendIn_InputPort));
523 }
524
525 NATIVE_INT_TYPE FileUplinkComponentBase ::
526 getNum_pingIn_InputPorts() const
527 {
528 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_pingIn_InputPort));
529 }
530
531 // ----------------------------------------------------------------------
532 // Getters for numbers of special output ports
533 // ----------------------------------------------------------------------
534
535#if FW_ENABLE_TEXT_LOGGING == 1
536
537 NATIVE_INT_TYPE FileUplinkComponentBase ::
538 getNum_LogText_OutputPorts() const
539 {
540 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
541 }
542
543#endif
544
545 NATIVE_INT_TYPE FileUplinkComponentBase ::
546 getNum_eventOut_OutputPorts() const
547 {
548 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_eventOut_OutputPort));
549 }
550
551 NATIVE_INT_TYPE FileUplinkComponentBase ::
552 getNum_timeCaller_OutputPorts() const
553 {
554 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_timeCaller_OutputPort));
555 }
556
557 NATIVE_INT_TYPE FileUplinkComponentBase ::
558 getNum_tlmOut_OutputPorts() const
559 {
560 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_tlmOut_OutputPort));
561 }
562
563 // ----------------------------------------------------------------------
564 // Getters for numbers of typed output ports
565 // ----------------------------------------------------------------------
566
567 NATIVE_INT_TYPE FileUplinkComponentBase ::
568 getNum_bufferSendOut_OutputPorts() const
569 {
570 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferSendOut_OutputPort));
571 }
572
573 NATIVE_INT_TYPE FileUplinkComponentBase ::
574 getNum_pingOut_OutputPorts() const
575 {
576 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_pingOut_OutputPort));
577 }
578
579 // ----------------------------------------------------------------------
580 // Connection status queries for special output ports
581 // ----------------------------------------------------------------------
582
583#if FW_ENABLE_TEXT_LOGGING == 1
584
585 bool FileUplinkComponentBase ::
586 isConnected_LogText_OutputPort(NATIVE_INT_TYPE portNum)
587 {
588 FW_ASSERT(
589 portNum < this->getNum_LogText_OutputPorts(),
590 static_cast<FwAssertArgType>(portNum)
591 );
592
593 return this->m_LogText_OutputPort[portNum].isConnected();
594 }
595
596#endif
597
598 bool FileUplinkComponentBase ::
599 isConnected_eventOut_OutputPort(NATIVE_INT_TYPE portNum)
600 {
601 FW_ASSERT(
602 portNum < this->getNum_eventOut_OutputPorts(),
603 static_cast<FwAssertArgType>(portNum)
604 );
605
606 return this->m_eventOut_OutputPort[portNum].isConnected();
607 }
608
609 bool FileUplinkComponentBase ::
610 isConnected_timeCaller_OutputPort(NATIVE_INT_TYPE portNum)
611 {
612 FW_ASSERT(
613 portNum < this->getNum_timeCaller_OutputPorts(),
614 static_cast<FwAssertArgType>(portNum)
615 );
616
617 return this->m_timeCaller_OutputPort[portNum].isConnected();
618 }
619
620 bool FileUplinkComponentBase ::
621 isConnected_tlmOut_OutputPort(NATIVE_INT_TYPE portNum)
622 {
623 FW_ASSERT(
624 portNum < this->getNum_tlmOut_OutputPorts(),
625 static_cast<FwAssertArgType>(portNum)
626 );
627
628 return this->m_tlmOut_OutputPort[portNum].isConnected();
629 }
630
631 // ----------------------------------------------------------------------
632 // Connection status queries for typed output ports
633 // ----------------------------------------------------------------------
634
635 bool FileUplinkComponentBase ::
636 isConnected_bufferSendOut_OutputPort(NATIVE_INT_TYPE portNum)
637 {
638 FW_ASSERT(
639 portNum < this->getNum_bufferSendOut_OutputPorts(),
640 static_cast<FwAssertArgType>(portNum)
641 );
642
643 return this->m_bufferSendOut_OutputPort[portNum].isConnected();
644 }
645
646 bool FileUplinkComponentBase ::
647 isConnected_pingOut_OutputPort(NATIVE_INT_TYPE portNum)
648 {
649 FW_ASSERT(
650 portNum < this->getNum_pingOut_OutputPorts(),
651 static_cast<FwAssertArgType>(portNum)
652 );
653
654 return this->m_pingOut_OutputPort[portNum].isConnected();
655 }
656
657 // ----------------------------------------------------------------------
658 // Port handler base-class functions for typed input ports
659 //
660 // Call these functions directly to bypass the corresponding ports
661 // ----------------------------------------------------------------------
662
663 void FileUplinkComponentBase ::
664 bufferSendIn_handlerBase(
665 NATIVE_INT_TYPE portNum,
666 Fw::Buffer& fwBuffer
667 )
668 {
669 // Make sure port number is valid
670 FW_ASSERT(
671 portNum < this->getNum_bufferSendIn_InputPorts(),
672 static_cast<FwAssertArgType>(portNum)
673 );
674
675 // Call pre-message hook
676 bufferSendIn_preMsgHook(
677 portNum,
678 fwBuffer
679 );
680 ComponentIpcSerializableBuffer msg;
682
683 // Serialize message ID
684 _status = msg.serialize(
685 static_cast<NATIVE_INT_TYPE>(BUFFERSENDIN_BUFFERSEND)
686 );
687 FW_ASSERT(
688 _status == Fw::FW_SERIALIZE_OK,
689 static_cast<FwAssertArgType>(_status)
690 );
691
692 // Serialize port number
693 _status = msg.serialize(portNum);
694 FW_ASSERT(
695 _status == Fw::FW_SERIALIZE_OK,
696 static_cast<FwAssertArgType>(_status)
697 );
698
699 // Serialize argument fwBuffer
700 _status = msg.serialize(fwBuffer);
701 FW_ASSERT(
702 _status == Fw::FW_SERIALIZE_OK,
703 static_cast<FwAssertArgType>(_status)
704 );
705
706 // Send message
708 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
709
710 FW_ASSERT(
711 qStatus == Os::Queue::QUEUE_OK,
712 static_cast<FwAssertArgType>(qStatus)
713 );
714 }
715
716 void FileUplinkComponentBase ::
717 pingIn_handlerBase(
718 NATIVE_INT_TYPE portNum,
719 U32 key
720 )
721 {
722 // Make sure port number is valid
723 FW_ASSERT(
724 portNum < this->getNum_pingIn_InputPorts(),
725 static_cast<FwAssertArgType>(portNum)
726 );
727
728 // Call pre-message hook
729 pingIn_preMsgHook(
730 portNum,
731 key
732 );
733 ComponentIpcSerializableBuffer msg;
735
736 // Serialize message ID
737 _status = msg.serialize(
738 static_cast<NATIVE_INT_TYPE>(PINGIN_PING)
739 );
740 FW_ASSERT(
741 _status == Fw::FW_SERIALIZE_OK,
742 static_cast<FwAssertArgType>(_status)
743 );
744
745 // Serialize port number
746 _status = msg.serialize(portNum);
747 FW_ASSERT(
748 _status == Fw::FW_SERIALIZE_OK,
749 static_cast<FwAssertArgType>(_status)
750 );
751
752 // Serialize argument key
753 _status = msg.serialize(key);
754 FW_ASSERT(
755 _status == Fw::FW_SERIALIZE_OK,
756 static_cast<FwAssertArgType>(_status)
757 );
758
759 // Send message
761 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
762
763 FW_ASSERT(
764 qStatus == Os::Queue::QUEUE_OK,
765 static_cast<FwAssertArgType>(qStatus)
766 );
767 }
768
769 // ----------------------------------------------------------------------
770 // Pre-message hooks for typed async input ports
771 //
772 // Each of these functions is invoked just before processing a message
773 // on the corresponding port. By default, they do nothing. You can
774 // override them to provide specific pre-message behavior.
775 // ----------------------------------------------------------------------
776
777 void FileUplinkComponentBase ::
778 bufferSendIn_preMsgHook(
779 NATIVE_INT_TYPE portNum,
780 Fw::Buffer& fwBuffer
781 )
782 {
783 // Default: no-op
784 }
785
786 void FileUplinkComponentBase ::
787 pingIn_preMsgHook(
788 NATIVE_INT_TYPE portNum,
789 U32 key
790 )
791 {
792 // Default: no-op
793 }
794
795 // ----------------------------------------------------------------------
796 // Invocation functions for typed output ports
797 // ----------------------------------------------------------------------
798
799 void FileUplinkComponentBase ::
800 bufferSendOut_out(
801 NATIVE_INT_TYPE portNum,
802 Fw::Buffer& fwBuffer
803 )
804 {
805 FW_ASSERT(
806 portNum < this->getNum_bufferSendOut_OutputPorts(),
807 static_cast<FwAssertArgType>(portNum)
808 );
809 this->m_bufferSendOut_OutputPort[portNum].invoke(
810 fwBuffer
811 );
812 }
813
814 void FileUplinkComponentBase ::
815 pingOut_out(
816 NATIVE_INT_TYPE portNum,
817 U32 key
818 )
819 {
820 FW_ASSERT(
821 portNum < this->getNum_pingOut_OutputPorts(),
822 static_cast<FwAssertArgType>(portNum)
823 );
824 this->m_pingOut_OutputPort[portNum].invoke(
825 key
826 );
827 }
828
829 // ----------------------------------------------------------------------
830 // Event logging functions
831 // ----------------------------------------------------------------------
832
833 void FileUplinkComponentBase ::
834 log_WARNING_HI_BadChecksum(
835 const Fw::LogStringArg& fileName,
836 U32 computed,
837 U32 read
838 )
839 {
840 // Get the time
841 Fw::Time _logTime;
842 if (this->m_timeCaller_OutputPort[0].isConnected()) {
843 this->m_timeCaller_OutputPort[0].invoke(_logTime);
844 }
845
846 FwEventIdType _id = static_cast<FwEventIdType>(0);
847
848 _id = this->getIdBase() + EVENTID_BADCHECKSUM;
849
850 // Emit the event on the log port
851 if (this->m_eventOut_OutputPort[0].isConnected()) {
852 Fw::LogBuffer _logBuff;
854
855#if FW_AMPCS_COMPATIBLE
856 // Serialize the number of arguments
857 _status = _logBuff.serialize(static_cast<U8>(3));
858 FW_ASSERT(
859 _status == Fw::FW_SERIALIZE_OK,
860 static_cast<FwAssertArgType>(_status)
861 );
862#endif
863
864 _status = fileName.serialize(_logBuff, 40);
865 FW_ASSERT(
866 _status == Fw::FW_SERIALIZE_OK,
867 static_cast<FwAssertArgType>(_status)
868 );
869
870#if FW_AMPCS_COMPATIBLE
871 // Serialize the argument size
872 _status = _logBuff.serialize(
873 static_cast<U8>(sizeof(U32))
874 );
875 FW_ASSERT(
876 _status == Fw::FW_SERIALIZE_OK,
877 static_cast<FwAssertArgType>(_status)
878 );
879#endif
880 _status = _logBuff.serialize(computed);
881 FW_ASSERT(
882 _status == Fw::FW_SERIALIZE_OK,
883 static_cast<FwAssertArgType>(_status)
884 );
885
886#if FW_AMPCS_COMPATIBLE
887 // Serialize the argument size
888 _status = _logBuff.serialize(
889 static_cast<U8>(sizeof(U32))
890 );
891 FW_ASSERT(
892 _status == Fw::FW_SERIALIZE_OK,
893 static_cast<FwAssertArgType>(_status)
894 );
895#endif
896 _status = _logBuff.serialize(read);
897 FW_ASSERT(
898 _status == Fw::FW_SERIALIZE_OK,
899 static_cast<FwAssertArgType>(_status)
900 );
901
902 this->m_eventOut_OutputPort[0].invoke(
903 _id,
904 _logTime,
906 _logBuff
907 );
908 }
909
910 // Emit the event on the text log port
911#if FW_ENABLE_TEXT_LOGGING
912 if (this->m_LogText_OutputPort[0].isConnected()) {
913#if FW_OBJECT_NAMES == 1
914 const char* _formatString =
915 "(%s) %s: Bad checksum value during receipt of file %s: computed 0x%" PRIx32 ", read 0x%" PRIx32 "";
916#else
917 const char* _formatString =
918 "%s: Bad checksum value during receipt of file %s: computed 0x%" PRIx32 ", read 0x%" PRIx32 "";
919#endif
920
921 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
922
923 (void) snprintf(
924 _textBuffer,
926 _formatString,
927#if FW_OBJECT_NAMES == 1
928 this->m_objName,
929#endif
930 "BadChecksum ",
931 fileName.toChar(),
932 computed,
933 read
934 );
935
936 // Null terminate
937 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
938 Fw::TextLogString _logString = _textBuffer;
939 this->m_LogText_OutputPort[0].invoke(
940 _id,
941 _logTime,
943 _logString
944 );
945 }
946#endif
947 }
948
949 void FileUplinkComponentBase ::
950 log_WARNING_HI_FileOpenError(const Fw::LogStringArg& fileName)
951 {
952 // Get the time
953 Fw::Time _logTime;
954 if (this->m_timeCaller_OutputPort[0].isConnected()) {
955 this->m_timeCaller_OutputPort[0].invoke(_logTime);
956 }
957
958 FwEventIdType _id = static_cast<FwEventIdType>(0);
959
960 _id = this->getIdBase() + EVENTID_FILEOPENERROR;
961
962 // Emit the event on the log port
963 if (this->m_eventOut_OutputPort[0].isConnected()) {
964 Fw::LogBuffer _logBuff;
966
967#if FW_AMPCS_COMPATIBLE
968 // Serialize the number of arguments
969 _status = _logBuff.serialize(static_cast<U8>(1));
970 FW_ASSERT(
971 _status == Fw::FW_SERIALIZE_OK,
972 static_cast<FwAssertArgType>(_status)
973 );
974#endif
975
976 _status = fileName.serialize(_logBuff, 40);
977 FW_ASSERT(
978 _status == Fw::FW_SERIALIZE_OK,
979 static_cast<FwAssertArgType>(_status)
980 );
981
982 this->m_eventOut_OutputPort[0].invoke(
983 _id,
984 _logTime,
986 _logBuff
987 );
988 }
989
990 // Emit the event on the text log port
991#if FW_ENABLE_TEXT_LOGGING
992 if (this->m_LogText_OutputPort[0].isConnected()) {
993#if FW_OBJECT_NAMES == 1
994 const char* _formatString =
995 "(%s) %s: Could not open file %s";
996#else
997 const char* _formatString =
998 "%s: Could not open file %s";
999#endif
1000
1001 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1002
1003 (void) snprintf(
1004 _textBuffer,
1006 _formatString,
1007#if FW_OBJECT_NAMES == 1
1008 this->m_objName,
1009#endif
1010 "FileOpenError ",
1011 fileName.toChar()
1012 );
1013
1014 // Null terminate
1015 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1016 Fw::TextLogString _logString = _textBuffer;
1017 this->m_LogText_OutputPort[0].invoke(
1018 _id,
1019 _logTime,
1021 _logString
1022 );
1023 }
1024#endif
1025 }
1026
1027 void FileUplinkComponentBase ::
1028 log_ACTIVITY_HI_FileReceived(const Fw::LogStringArg& fileName)
1029 {
1030 // Get the time
1031 Fw::Time _logTime;
1032 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1033 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1034 }
1035
1036 FwEventIdType _id = static_cast<FwEventIdType>(0);
1037
1038 _id = this->getIdBase() + EVENTID_FILERECEIVED;
1039
1040 // Emit the event on the log port
1041 if (this->m_eventOut_OutputPort[0].isConnected()) {
1042 Fw::LogBuffer _logBuff;
1044
1045#if FW_AMPCS_COMPATIBLE
1046 // Serialize the number of arguments
1047 _status = _logBuff.serialize(static_cast<U8>(1));
1048 FW_ASSERT(
1049 _status == Fw::FW_SERIALIZE_OK,
1050 static_cast<FwAssertArgType>(_status)
1051 );
1052#endif
1053
1054 _status = fileName.serialize(_logBuff, 40);
1055 FW_ASSERT(
1056 _status == Fw::FW_SERIALIZE_OK,
1057 static_cast<FwAssertArgType>(_status)
1058 );
1059
1060 this->m_eventOut_OutputPort[0].invoke(
1061 _id,
1062 _logTime,
1064 _logBuff
1065 );
1066 }
1067
1068 // Emit the event on the text log port
1069#if FW_ENABLE_TEXT_LOGGING
1070 if (this->m_LogText_OutputPort[0].isConnected()) {
1071#if FW_OBJECT_NAMES == 1
1072 const char* _formatString =
1073 "(%s) %s: Received file %s";
1074#else
1075 const char* _formatString =
1076 "%s: Received file %s";
1077#endif
1078
1079 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1080
1081 (void) snprintf(
1082 _textBuffer,
1084 _formatString,
1085#if FW_OBJECT_NAMES == 1
1086 this->m_objName,
1087#endif
1088 "FileReceived ",
1089 fileName.toChar()
1090 );
1091
1092 // Null terminate
1093 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1094 Fw::TextLogString _logString = _textBuffer;
1095 this->m_LogText_OutputPort[0].invoke(
1096 _id,
1097 _logTime,
1099 _logString
1100 );
1101 }
1102#endif
1103 }
1104
1105 void FileUplinkComponentBase ::
1106 log_WARNING_HI_FileWriteError(const Fw::LogStringArg& fileName)
1107 {
1108 // Check throttle value
1109 if (this->m_FileWriteErrorThrottle >= EVENTID_FILEWRITEERROR_THROTTLE) {
1110 return;
1111 }
1112 else {
1113 this->m_FileWriteErrorThrottle++;
1114 }
1115
1116 // Get the time
1117 Fw::Time _logTime;
1118 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1119 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1120 }
1121
1122 FwEventIdType _id = static_cast<FwEventIdType>(0);
1123
1124 _id = this->getIdBase() + EVENTID_FILEWRITEERROR;
1125
1126 // Emit the event on the log port
1127 if (this->m_eventOut_OutputPort[0].isConnected()) {
1128 Fw::LogBuffer _logBuff;
1130
1131#if FW_AMPCS_COMPATIBLE
1132 // Serialize the number of arguments
1133 _status = _logBuff.serialize(static_cast<U8>(1));
1134 FW_ASSERT(
1135 _status == Fw::FW_SERIALIZE_OK,
1136 static_cast<FwAssertArgType>(_status)
1137 );
1138#endif
1139
1140 _status = fileName.serialize(_logBuff, 40);
1141 FW_ASSERT(
1142 _status == Fw::FW_SERIALIZE_OK,
1143 static_cast<FwAssertArgType>(_status)
1144 );
1145
1146 this->m_eventOut_OutputPort[0].invoke(
1147 _id,
1148 _logTime,
1150 _logBuff
1151 );
1152 }
1153
1154 // Emit the event on the text log port
1155#if FW_ENABLE_TEXT_LOGGING
1156 if (this->m_LogText_OutputPort[0].isConnected()) {
1157#if FW_OBJECT_NAMES == 1
1158 const char* _formatString =
1159 "(%s) %s: Could not write to file %s";
1160#else
1161 const char* _formatString =
1162 "%s: Could not write to file %s";
1163#endif
1164
1165 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1166
1167 (void) snprintf(
1168 _textBuffer,
1170 _formatString,
1171#if FW_OBJECT_NAMES == 1
1172 this->m_objName,
1173#endif
1174 "FileWriteError ",
1175 fileName.toChar()
1176 );
1177
1178 // Null terminate
1179 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1180 Fw::TextLogString _logString = _textBuffer;
1181 this->m_LogText_OutputPort[0].invoke(
1182 _id,
1183 _logTime,
1185 _logString
1186 );
1187 }
1188#endif
1189 }
1190
1191 void FileUplinkComponentBase ::
1192 log_WARNING_HI_InvalidReceiveMode(
1193 U32 packetType,
1194 U32 mode
1195 )
1196 {
1197 // Check throttle value
1198 if (this->m_InvalidReceiveModeThrottle >= EVENTID_INVALIDRECEIVEMODE_THROTTLE) {
1199 return;
1200 }
1201 else {
1202 this->m_InvalidReceiveModeThrottle++;
1203 }
1204
1205 // Get the time
1206 Fw::Time _logTime;
1207 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1208 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1209 }
1210
1211 FwEventIdType _id = static_cast<FwEventIdType>(0);
1212
1213 _id = this->getIdBase() + EVENTID_INVALIDRECEIVEMODE;
1214
1215 // Emit the event on the log port
1216 if (this->m_eventOut_OutputPort[0].isConnected()) {
1217 Fw::LogBuffer _logBuff;
1219
1220#if FW_AMPCS_COMPATIBLE
1221 // Serialize the number of arguments
1222 _status = _logBuff.serialize(static_cast<U8>(2));
1223 FW_ASSERT(
1224 _status == Fw::FW_SERIALIZE_OK,
1225 static_cast<FwAssertArgType>(_status)
1226 );
1227#endif
1228
1229#if FW_AMPCS_COMPATIBLE
1230 // Serialize the argument size
1231 _status = _logBuff.serialize(
1232 static_cast<U8>(sizeof(U32))
1233 );
1234 FW_ASSERT(
1235 _status == Fw::FW_SERIALIZE_OK,
1236 static_cast<FwAssertArgType>(_status)
1237 );
1238#endif
1239 _status = _logBuff.serialize(packetType);
1240 FW_ASSERT(
1241 _status == Fw::FW_SERIALIZE_OK,
1242 static_cast<FwAssertArgType>(_status)
1243 );
1244
1245#if FW_AMPCS_COMPATIBLE
1246 // Serialize the argument size
1247 _status = _logBuff.serialize(
1248 static_cast<U8>(sizeof(U32))
1249 );
1250 FW_ASSERT(
1251 _status == Fw::FW_SERIALIZE_OK,
1252 static_cast<FwAssertArgType>(_status)
1253 );
1254#endif
1255 _status = _logBuff.serialize(mode);
1256 FW_ASSERT(
1257 _status == Fw::FW_SERIALIZE_OK,
1258 static_cast<FwAssertArgType>(_status)
1259 );
1260
1261 this->m_eventOut_OutputPort[0].invoke(
1262 _id,
1263 _logTime,
1265 _logBuff
1266 );
1267 }
1268
1269 // Emit the event on the text log port
1270#if FW_ENABLE_TEXT_LOGGING
1271 if (this->m_LogText_OutputPort[0].isConnected()) {
1272#if FW_OBJECT_NAMES == 1
1273 const char* _formatString =
1274 "(%s) %s: Packet type %" PRIu32 " received in mode %" PRIu32 "";
1275#else
1276 const char* _formatString =
1277 "%s: Packet type %" PRIu32 " received in mode %" PRIu32 "";
1278#endif
1279
1280 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1281
1282 (void) snprintf(
1283 _textBuffer,
1285 _formatString,
1286#if FW_OBJECT_NAMES == 1
1287 this->m_objName,
1288#endif
1289 "InvalidReceiveMode ",
1290 packetType,
1291 mode
1292 );
1293
1294 // Null terminate
1295 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1296 Fw::TextLogString _logString = _textBuffer;
1297 this->m_LogText_OutputPort[0].invoke(
1298 _id,
1299 _logTime,
1301 _logString
1302 );
1303 }
1304#endif
1305 }
1306
1307 void FileUplinkComponentBase ::
1308 log_WARNING_HI_PacketOutOfBounds(
1309 U32 packetIndex,
1310 const Fw::LogStringArg& fileName
1311 )
1312 {
1313 // Check throttle value
1314 if (this->m_PacketOutOfBoundsThrottle >= EVENTID_PACKETOUTOFBOUNDS_THROTTLE) {
1315 return;
1316 }
1317 else {
1318 this->m_PacketOutOfBoundsThrottle++;
1319 }
1320
1321 // Get the time
1322 Fw::Time _logTime;
1323 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1324 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1325 }
1326
1327 FwEventIdType _id = static_cast<FwEventIdType>(0);
1328
1329 _id = this->getIdBase() + EVENTID_PACKETOUTOFBOUNDS;
1330
1331 // Emit the event on the log port
1332 if (this->m_eventOut_OutputPort[0].isConnected()) {
1333 Fw::LogBuffer _logBuff;
1335
1336#if FW_AMPCS_COMPATIBLE
1337 // Serialize the number of arguments
1338 _status = _logBuff.serialize(static_cast<U8>(2));
1339 FW_ASSERT(
1340 _status == Fw::FW_SERIALIZE_OK,
1341 static_cast<FwAssertArgType>(_status)
1342 );
1343#endif
1344
1345#if FW_AMPCS_COMPATIBLE
1346 // Serialize the argument size
1347 _status = _logBuff.serialize(
1348 static_cast<U8>(sizeof(U32))
1349 );
1350 FW_ASSERT(
1351 _status == Fw::FW_SERIALIZE_OK,
1352 static_cast<FwAssertArgType>(_status)
1353 );
1354#endif
1355 _status = _logBuff.serialize(packetIndex);
1356 FW_ASSERT(
1357 _status == Fw::FW_SERIALIZE_OK,
1358 static_cast<FwAssertArgType>(_status)
1359 );
1360
1361 _status = fileName.serialize(_logBuff, 40);
1362 FW_ASSERT(
1363 _status == Fw::FW_SERIALIZE_OK,
1364 static_cast<FwAssertArgType>(_status)
1365 );
1366
1367 this->m_eventOut_OutputPort[0].invoke(
1368 _id,
1369 _logTime,
1371 _logBuff
1372 );
1373 }
1374
1375 // Emit the event on the text log port
1376#if FW_ENABLE_TEXT_LOGGING
1377 if (this->m_LogText_OutputPort[0].isConnected()) {
1378#if FW_OBJECT_NAMES == 1
1379 const char* _formatString =
1380 "(%s) %s: Packet %" PRIu32 " out of bounds for file %s";
1381#else
1382 const char* _formatString =
1383 "%s: Packet %" PRIu32 " out of bounds for file %s";
1384#endif
1385
1386 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1387
1388 (void) snprintf(
1389 _textBuffer,
1391 _formatString,
1392#if FW_OBJECT_NAMES == 1
1393 this->m_objName,
1394#endif
1395 "PacketOutOfBounds ",
1396 packetIndex,
1397 fileName.toChar()
1398 );
1399
1400 // Null terminate
1401 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1402 Fw::TextLogString _logString = _textBuffer;
1403 this->m_LogText_OutputPort[0].invoke(
1404 _id,
1405 _logTime,
1407 _logString
1408 );
1409 }
1410#endif
1411 }
1412
1413 void FileUplinkComponentBase ::
1414 log_WARNING_HI_PacketOutOfOrder(
1415 U32 packetIndex,
1416 U32 lastPacketIndex
1417 )
1418 {
1419 // Check throttle value
1420 if (this->m_PacketOutOfOrderThrottle >= EVENTID_PACKETOUTOFORDER_THROTTLE) {
1421 return;
1422 }
1423 else {
1424 this->m_PacketOutOfOrderThrottle++;
1425 }
1426
1427 // Get the time
1428 Fw::Time _logTime;
1429 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1430 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1431 }
1432
1433 FwEventIdType _id = static_cast<FwEventIdType>(0);
1434
1435 _id = this->getIdBase() + EVENTID_PACKETOUTOFORDER;
1436
1437 // Emit the event on the log port
1438 if (this->m_eventOut_OutputPort[0].isConnected()) {
1439 Fw::LogBuffer _logBuff;
1441
1442#if FW_AMPCS_COMPATIBLE
1443 // Serialize the number of arguments
1444 _status = _logBuff.serialize(static_cast<U8>(2));
1445 FW_ASSERT(
1446 _status == Fw::FW_SERIALIZE_OK,
1447 static_cast<FwAssertArgType>(_status)
1448 );
1449#endif
1450
1451#if FW_AMPCS_COMPATIBLE
1452 // Serialize the argument size
1453 _status = _logBuff.serialize(
1454 static_cast<U8>(sizeof(U32))
1455 );
1456 FW_ASSERT(
1457 _status == Fw::FW_SERIALIZE_OK,
1458 static_cast<FwAssertArgType>(_status)
1459 );
1460#endif
1461 _status = _logBuff.serialize(packetIndex);
1462 FW_ASSERT(
1463 _status == Fw::FW_SERIALIZE_OK,
1464 static_cast<FwAssertArgType>(_status)
1465 );
1466
1467#if FW_AMPCS_COMPATIBLE
1468 // Serialize the argument size
1469 _status = _logBuff.serialize(
1470 static_cast<U8>(sizeof(U32))
1471 );
1472 FW_ASSERT(
1473 _status == Fw::FW_SERIALIZE_OK,
1474 static_cast<FwAssertArgType>(_status)
1475 );
1476#endif
1477 _status = _logBuff.serialize(lastPacketIndex);
1478 FW_ASSERT(
1479 _status == Fw::FW_SERIALIZE_OK,
1480 static_cast<FwAssertArgType>(_status)
1481 );
1482
1483 this->m_eventOut_OutputPort[0].invoke(
1484 _id,
1485 _logTime,
1487 _logBuff
1488 );
1489 }
1490
1491 // Emit the event on the text log port
1492#if FW_ENABLE_TEXT_LOGGING
1493 if (this->m_LogText_OutputPort[0].isConnected()) {
1494#if FW_OBJECT_NAMES == 1
1495 const char* _formatString =
1496 "(%s) %s: Received packet %" PRIu32 " after packet %" PRIu32 "";
1497#else
1498 const char* _formatString =
1499 "%s: Received packet %" PRIu32 " after packet %" PRIu32 "";
1500#endif
1501
1502 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1503
1504 (void) snprintf(
1505 _textBuffer,
1507 _formatString,
1508#if FW_OBJECT_NAMES == 1
1509 this->m_objName,
1510#endif
1511 "PacketOutOfOrder ",
1512 packetIndex,
1513 lastPacketIndex
1514 );
1515
1516 // Null terminate
1517 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1518 Fw::TextLogString _logString = _textBuffer;
1519 this->m_LogText_OutputPort[0].invoke(
1520 _id,
1521 _logTime,
1523 _logString
1524 );
1525 }
1526#endif
1527 }
1528
1529 void FileUplinkComponentBase ::
1530 log_ACTIVITY_HI_UplinkCanceled()
1531 {
1532 // Get the time
1533 Fw::Time _logTime;
1534 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1535 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1536 }
1537
1538 FwEventIdType _id = static_cast<FwEventIdType>(0);
1539
1540 _id = this->getIdBase() + EVENTID_UPLINKCANCELED;
1541
1542 // Emit the event on the log port
1543 if (this->m_eventOut_OutputPort[0].isConnected()) {
1544 Fw::LogBuffer _logBuff;
1545
1546#if FW_AMPCS_COMPATIBLE
1548 // Serialize the number of arguments
1549 _status = _logBuff.serialize(static_cast<U8>(0));
1550 FW_ASSERT(
1551 _status == Fw::FW_SERIALIZE_OK,
1552 static_cast<FwAssertArgType>(_status)
1553 );
1554#endif
1555
1556 this->m_eventOut_OutputPort[0].invoke(
1557 _id,
1558 _logTime,
1560 _logBuff
1561 );
1562 }
1563
1564 // Emit the event on the text log port
1565#if FW_ENABLE_TEXT_LOGGING
1566 if (this->m_LogText_OutputPort[0].isConnected()) {
1567#if FW_OBJECT_NAMES == 1
1568 const char* _formatString =
1569 "(%s) %s: Received CANCEL packet";
1570#else
1571 const char* _formatString =
1572 "%s: Received CANCEL packet";
1573#endif
1574
1575 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1576
1577 (void) snprintf(
1578 _textBuffer,
1580 _formatString,
1581#if FW_OBJECT_NAMES == 1
1582 this->m_objName,
1583#endif
1584 "UplinkCanceled "
1585 );
1586
1587 // Null terminate
1588 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1589 Fw::TextLogString _logString = _textBuffer;
1590 this->m_LogText_OutputPort[0].invoke(
1591 _id,
1592 _logTime,
1594 _logString
1595 );
1596 }
1597#endif
1598 }
1599
1600 void FileUplinkComponentBase ::
1601 log_WARNING_HI_DecodeError(I32 status)
1602 {
1603 // Get the time
1604 Fw::Time _logTime;
1605 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1606 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1607 }
1608
1609 FwEventIdType _id = static_cast<FwEventIdType>(0);
1610
1611 _id = this->getIdBase() + EVENTID_DECODEERROR;
1612
1613 // Emit the event on the log port
1614 if (this->m_eventOut_OutputPort[0].isConnected()) {
1615 Fw::LogBuffer _logBuff;
1617
1618#if FW_AMPCS_COMPATIBLE
1619 // Serialize the number of arguments
1620 _status = _logBuff.serialize(static_cast<U8>(1));
1621 FW_ASSERT(
1622 _status == Fw::FW_SERIALIZE_OK,
1623 static_cast<FwAssertArgType>(_status)
1624 );
1625#endif
1626
1627#if FW_AMPCS_COMPATIBLE
1628 // Serialize the argument size
1629 _status = _logBuff.serialize(
1630 static_cast<U8>(sizeof(I32))
1631 );
1632 FW_ASSERT(
1633 _status == Fw::FW_SERIALIZE_OK,
1634 static_cast<FwAssertArgType>(_status)
1635 );
1636#endif
1637 _status = _logBuff.serialize(status);
1638 FW_ASSERT(
1639 _status == Fw::FW_SERIALIZE_OK,
1640 static_cast<FwAssertArgType>(_status)
1641 );
1642
1643 this->m_eventOut_OutputPort[0].invoke(
1644 _id,
1645 _logTime,
1647 _logBuff
1648 );
1649 }
1650
1651 // Emit the event on the text log port
1652#if FW_ENABLE_TEXT_LOGGING
1653 if (this->m_LogText_OutputPort[0].isConnected()) {
1654#if FW_OBJECT_NAMES == 1
1655 const char* _formatString =
1656 "(%s) %s: Unable to decode file packet. Status: %" PRIi32 "";
1657#else
1658 const char* _formatString =
1659 "%s: Unable to decode file packet. Status: %" PRIi32 "";
1660#endif
1661
1662 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1663
1664 (void) snprintf(
1665 _textBuffer,
1667 _formatString,
1668#if FW_OBJECT_NAMES == 1
1669 this->m_objName,
1670#endif
1671 "DecodeError ",
1672 status
1673 );
1674
1675 // Null terminate
1676 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1677 Fw::TextLogString _logString = _textBuffer;
1678 this->m_LogText_OutputPort[0].invoke(
1679 _id,
1680 _logTime,
1682 _logString
1683 );
1684 }
1685#endif
1686 }
1687
1688 // ----------------------------------------------------------------------
1689 // Event throttle reset functions
1690 // ----------------------------------------------------------------------
1691
1692 void FileUplinkComponentBase ::
1693 log_WARNING_HI_FileWriteError_ThrottleClear()
1694 {
1695 // Reset throttle counter
1696 this->m_FileWriteErrorThrottle = 0;
1697 }
1698
1699 void FileUplinkComponentBase ::
1700 log_WARNING_HI_InvalidReceiveMode_ThrottleClear()
1701 {
1702 // Reset throttle counter
1703 this->m_InvalidReceiveModeThrottle = 0;
1704 }
1705
1706 void FileUplinkComponentBase ::
1707 log_WARNING_HI_PacketOutOfBounds_ThrottleClear()
1708 {
1709 // Reset throttle counter
1710 this->m_PacketOutOfBoundsThrottle = 0;
1711 }
1712
1713 void FileUplinkComponentBase ::
1714 log_WARNING_HI_PacketOutOfOrder_ThrottleClear()
1715 {
1716 // Reset throttle counter
1717 this->m_PacketOutOfOrderThrottle = 0;
1718 }
1719
1720 // ----------------------------------------------------------------------
1721 // Telemetry write functions
1722 // ----------------------------------------------------------------------
1723
1724 void FileUplinkComponentBase ::
1725 tlmWrite_FilesReceived(
1726 U32 arg,
1727 Fw::Time _tlmTime
1728 )
1729 {
1730 if (this->m_tlmOut_OutputPort[0].isConnected()) {
1731 if (
1732 this->m_timeCaller_OutputPort[0].isConnected() &&
1733 (_tlmTime == Fw::ZERO_TIME)
1734 ) {
1735 this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
1736 }
1737
1738 Fw::TlmBuffer _tlmBuff;
1739 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
1740 FW_ASSERT(
1741 _stat == Fw::FW_SERIALIZE_OK,
1742 static_cast<FwAssertArgType>(_stat)
1743 );
1744
1745 FwChanIdType _id;
1746
1747 _id = this->getIdBase() + CHANNELID_FILESRECEIVED;
1748
1749 this->m_tlmOut_OutputPort[0].invoke(
1750 _id,
1751 _tlmTime,
1752 _tlmBuff
1753 );
1754 }
1755 }
1756
1757 void FileUplinkComponentBase ::
1758 tlmWrite_PacketsReceived(
1759 U32 arg,
1760 Fw::Time _tlmTime
1761 )
1762 {
1763 if (this->m_tlmOut_OutputPort[0].isConnected()) {
1764 if (
1765 this->m_timeCaller_OutputPort[0].isConnected() &&
1766 (_tlmTime == Fw::ZERO_TIME)
1767 ) {
1768 this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
1769 }
1770
1771 Fw::TlmBuffer _tlmBuff;
1772 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
1773 FW_ASSERT(
1774 _stat == Fw::FW_SERIALIZE_OK,
1775 static_cast<FwAssertArgType>(_stat)
1776 );
1777
1778 FwChanIdType _id;
1779
1780 _id = this->getIdBase() + CHANNELID_PACKETSRECEIVED;
1781
1782 this->m_tlmOut_OutputPort[0].invoke(
1783 _id,
1784 _tlmTime,
1785 _tlmBuff
1786 );
1787 }
1788 }
1789
1790 void FileUplinkComponentBase ::
1791 tlmWrite_Warnings(
1792 U32 arg,
1793 Fw::Time _tlmTime
1794 )
1795 {
1796 if (this->m_tlmOut_OutputPort[0].isConnected()) {
1797 if (
1798 this->m_timeCaller_OutputPort[0].isConnected() &&
1799 (_tlmTime == Fw::ZERO_TIME)
1800 ) {
1801 this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
1802 }
1803
1804 Fw::TlmBuffer _tlmBuff;
1805 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
1806 FW_ASSERT(
1807 _stat == Fw::FW_SERIALIZE_OK,
1808 static_cast<FwAssertArgType>(_stat)
1809 );
1810
1811 FwChanIdType _id;
1812
1813 _id = this->getIdBase() + CHANNELID_WARNINGS;
1814
1815 this->m_tlmOut_OutputPort[0].invoke(
1816 _id,
1817 _tlmTime,
1818 _tlmBuff
1819 );
1820 }
1821 }
1822
1823 // ----------------------------------------------------------------------
1824 // Time
1825 // ----------------------------------------------------------------------
1826
1827 Fw::Time FileUplinkComponentBase ::
1828 getTime()
1829 {
1830 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1831 Fw::Time _time;
1832 this->m_timeCaller_OutputPort[0].invoke(_time);
1833 return _time;
1834 }
1835 else {
1836 return Fw::Time(TB_NONE, 0, 0);
1837 }
1838 }
1839
1840 // ----------------------------------------------------------------------
1841 // Message dispatch functions
1842 // ----------------------------------------------------------------------
1843
1844 Fw::QueuedComponentBase::MsgDispatchStatus FileUplinkComponentBase ::
1845 doDispatch()
1846 {
1847 ComponentIpcSerializableBuffer msg;
1848 NATIVE_INT_TYPE priority = 0;
1849
1850 Os::Queue::QueueStatus msgStatus = this->m_queue.receive(
1851 msg,
1852 priority,
1854 );
1855 FW_ASSERT(
1856 msgStatus == Os::Queue::QUEUE_OK,
1857 static_cast<FwAssertArgType>(msgStatus)
1858 );
1859
1860 // Reset to beginning of buffer
1861 msg.resetDeser();
1862
1863 NATIVE_INT_TYPE desMsg = 0;
1864 Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
1865 FW_ASSERT(
1866 deserStatus == Fw::FW_SERIALIZE_OK,
1867 static_cast<FwAssertArgType>(deserStatus)
1868 );
1869
1870 MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
1871
1872 if (msgType == FILEUPLINK_COMPONENT_EXIT) {
1873 return MSG_DISPATCH_EXIT;
1874 }
1875
1876 NATIVE_INT_TYPE portNum = 0;
1877 deserStatus = msg.deserialize(portNum);
1878 FW_ASSERT(
1879 deserStatus == Fw::FW_SERIALIZE_OK,
1880 static_cast<FwAssertArgType>(deserStatus)
1881 );
1882
1883 switch (msgType) {
1884 // Handle async input port bufferSendIn
1885 case BUFFERSENDIN_BUFFERSEND: {
1886 // Deserialize argument fwBuffer
1887 Fw::Buffer fwBuffer;
1888 deserStatus = msg.deserialize(fwBuffer);
1889 FW_ASSERT(
1890 deserStatus == Fw::FW_SERIALIZE_OK,
1891 static_cast<FwAssertArgType>(deserStatus)
1892 );
1893 // Call handler function
1894 this->bufferSendIn_handler(
1895 portNum,
1896 fwBuffer
1897 );
1898
1899 break;
1900 }
1901
1902 // Handle async input port pingIn
1903 case PINGIN_PING: {
1904 // Deserialize argument key
1905 U32 key;
1906 deserStatus = msg.deserialize(key);
1907 FW_ASSERT(
1908 deserStatus == Fw::FW_SERIALIZE_OK,
1909 static_cast<FwAssertArgType>(deserStatus)
1910 );
1911 // Call handler function
1912 this->pingIn_handler(
1913 portNum,
1914 key
1915 );
1916
1917 break;
1918 }
1919
1920 default:
1921 return MSG_DISPATCH_ERROR;
1922 }
1923
1924 return MSG_DISPATCH_OK;
1925 }
1926
1927 // ----------------------------------------------------------------------
1928 // Calls for messages received on typed input ports
1929 // ----------------------------------------------------------------------
1930
1931 void FileUplinkComponentBase ::
1932 m_p_bufferSendIn_in(
1933 Fw::PassiveComponentBase* callComp,
1934 NATIVE_INT_TYPE portNum,
1935 Fw::Buffer& fwBuffer
1936 )
1937 {
1938 FW_ASSERT(callComp);
1939 FileUplinkComponentBase* compPtr = static_cast<FileUplinkComponentBase*>(callComp);
1940 compPtr->bufferSendIn_handlerBase(
1941 portNum,
1942 fwBuffer
1943 );
1944 }
1945
1946 void FileUplinkComponentBase ::
1947 m_p_pingIn_in(
1948 Fw::PassiveComponentBase* callComp,
1949 NATIVE_INT_TYPE portNum,
1950 U32 key
1951 )
1952 {
1953 FW_ASSERT(callComp);
1954 FileUplinkComponentBase* compPtr = static_cast<FileUplinkComponentBase*>(callComp);
1955 compPtr->pingIn_handlerBase(
1956 portNum,
1957 key
1958 );
1959 }
1960
1961}
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
U8 BYTE
byte type
Definition BasicTypes.h:27
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition BasicTypes.h:66
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition FpConfig.h:39
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:21
U32 FwChanIdType
Definition FpConfig.h:59
U32 FwEventIdType
Definition FpConfig.h:62
#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
Input BufferSend port.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
@ WARNING_HI
A serious but recoverable event.
@ ACTIVITY_HI
Important informational events.
const char * toChar() const override
Definition LogString.cpp:49
SerializeStatus serialize(SerializeBufferBase &buffer) const override
serialization function
Definition LogString.cpp:57
void init()
Object initializer.
Definition ObjBase.cpp:27
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.
const Time ZERO_TIME
Definition Time.cpp:5