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