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