F´ Flight Software - C/C++ Documentation devel
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
FileDownlinkComponentAc.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title FileDownlinkComponentAc.cpp
3// \author Generated by fpp-to-cpp
4// \brief cpp file for FileDownlink 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 FILEDOWNLINK_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
20 RUN_SCHED,
21 BUFFERRETURN_BUFFERSEND,
22 PINGIN_PING,
23 CMD_SENDFILE,
24 CMD_CANCEL,
25 CMD_SENDPARTIAL,
26 };
27
28 // Get the max size by constructing a union of the async input, command, and
29 // internal port serialization sizes
30 union BuffUnion {
35 };
36
37 // Define a message buffer class large enough to handle all the
38 // asynchronous inputs to the component
39 class ComponentIpcSerializableBuffer :
41 {
42
43 public:
44
45 enum {
46 // Max. message size = size of data + message id + port
47 SERIALIZATION_SIZE =
48 sizeof(BuffUnion) +
49 sizeof(NATIVE_INT_TYPE) +
50 sizeof(NATIVE_INT_TYPE)
51 };
52
53 NATIVE_UINT_TYPE getBuffCapacity() const {
54 return sizeof(m_buff);
55 }
56
57 U8* getBuffAddr() {
58 return m_buff;
59 }
60
61 const U8* getBuffAddr() const {
62 return m_buff;
63 }
64
65 private:
66 // Should be the max of all the input ports serialized sizes...
67 U8 m_buff[SERIALIZATION_SIZE];
68
69 };
70 }
71
72 // ----------------------------------------------------------------------
73 // Component initialization
74 // ----------------------------------------------------------------------
75
76 void FileDownlinkComponentBase ::
77 init(
78 NATIVE_INT_TYPE queueDepth,
79 NATIVE_INT_TYPE instance
80 )
81 {
82 // Initialize base class
84
85 // Connect input port cmdIn
86 for (
87 PlatformIntType port = 0;
88 port < static_cast<PlatformIntType>(this->getNum_cmdIn_InputPorts());
89 port++
90 ) {
91 this->m_cmdIn_InputPort[port].init();
92 this->m_cmdIn_InputPort[port].addCallComp(
93 this,
94 m_p_cmdIn_in
95 );
96 this->m_cmdIn_InputPort[port].setPortNum(port);
97
98#if FW_OBJECT_NAMES == 1
99 // The port name consists of this->m_objName and some extra info.
100 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
101 // However, the compiler may assume that this->m_objName fills
102 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
103 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
104 // bytes to cover the extra info.
105 char portName[2*FW_OBJ_NAME_MAX_SIZE];
106 (void) snprintf(
107 portName,
108 sizeof(portName),
109 "%s_cmdIn_InputPort[%" PRI_PlatformIntType "]",
110 this->m_objName,
111 port
112 );
113 this->m_cmdIn_InputPort[port].setObjName(portName);
114#endif
115 }
116
117 // Connect input port Run
118 for (
119 PlatformIntType port = 0;
120 port < static_cast<PlatformIntType>(this->getNum_Run_InputPorts());
121 port++
122 ) {
123 this->m_Run_InputPort[port].init();
124 this->m_Run_InputPort[port].addCallComp(
125 this,
126 m_p_Run_in
127 );
128 this->m_Run_InputPort[port].setPortNum(port);
129
130#if FW_OBJECT_NAMES == 1
131 // The port name consists of this->m_objName and some extra info.
132 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
133 // However, the compiler may assume that this->m_objName fills
134 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
135 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
136 // bytes to cover the extra info.
137 char portName[2*FW_OBJ_NAME_MAX_SIZE];
138 (void) snprintf(
139 portName,
140 sizeof(portName),
141 "%s_Run_InputPort[%" PRI_PlatformIntType "]",
142 this->m_objName,
143 port
144 );
145 this->m_Run_InputPort[port].setObjName(portName);
146#endif
147 }
148
149 // Connect input port SendFile
150 for (
151 PlatformIntType port = 0;
152 port < static_cast<PlatformIntType>(this->getNum_SendFile_InputPorts());
153 port++
154 ) {
155 this->m_SendFile_InputPort[port].init();
156 this->m_SendFile_InputPort[port].addCallComp(
157 this,
158 m_p_SendFile_in
159 );
160 this->m_SendFile_InputPort[port].setPortNum(port);
161
162#if FW_OBJECT_NAMES == 1
163 // The port name consists of this->m_objName and some extra info.
164 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
165 // However, the compiler may assume that this->m_objName fills
166 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
167 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
168 // bytes to cover the extra info.
169 char portName[2*FW_OBJ_NAME_MAX_SIZE];
170 (void) snprintf(
171 portName,
172 sizeof(portName),
173 "%s_SendFile_InputPort[%" PRI_PlatformIntType "]",
174 this->m_objName,
175 port
176 );
177 this->m_SendFile_InputPort[port].setObjName(portName);
178#endif
179 }
180
181 // Connect input port bufferReturn
182 for (
183 PlatformIntType port = 0;
184 port < static_cast<PlatformIntType>(this->getNum_bufferReturn_InputPorts());
185 port++
186 ) {
187 this->m_bufferReturn_InputPort[port].init();
188 this->m_bufferReturn_InputPort[port].addCallComp(
189 this,
190 m_p_bufferReturn_in
191 );
192 this->m_bufferReturn_InputPort[port].setPortNum(port);
193
194#if FW_OBJECT_NAMES == 1
195 // The port name consists of this->m_objName and some extra info.
196 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
197 // However, the compiler may assume that this->m_objName fills
198 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
199 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
200 // bytes to cover the extra info.
201 char portName[2*FW_OBJ_NAME_MAX_SIZE];
202 (void) snprintf(
203 portName,
204 sizeof(portName),
205 "%s_bufferReturn_InputPort[%" PRI_PlatformIntType "]",
206 this->m_objName,
207 port
208 );
209 this->m_bufferReturn_InputPort[port].setObjName(portName);
210#endif
211 }
212
213 // Connect input port pingIn
214 for (
215 PlatformIntType port = 0;
216 port < static_cast<PlatformIntType>(this->getNum_pingIn_InputPorts());
217 port++
218 ) {
219 this->m_pingIn_InputPort[port].init();
220 this->m_pingIn_InputPort[port].addCallComp(
221 this,
222 m_p_pingIn_in
223 );
224 this->m_pingIn_InputPort[port].setPortNum(port);
225
226#if FW_OBJECT_NAMES == 1
227 // The port name consists of this->m_objName and some extra info.
228 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
229 // However, the compiler may assume that this->m_objName fills
230 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
231 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
232 // bytes to cover the extra info.
233 char portName[2*FW_OBJ_NAME_MAX_SIZE];
234 (void) snprintf(
235 portName,
236 sizeof(portName),
237 "%s_pingIn_InputPort[%" PRI_PlatformIntType "]",
238 this->m_objName,
239 port
240 );
241 this->m_pingIn_InputPort[port].setObjName(portName);
242#endif
243 }
244
245 // Connect output port cmdRegOut
246 for (
247 PlatformIntType port = 0;
248 port < static_cast<PlatformIntType>(this->getNum_cmdRegOut_OutputPorts());
249 port++
250 ) {
251 this->m_cmdRegOut_OutputPort[port].init();
252
253#if FW_OBJECT_NAMES == 1
254 // The port name consists of this->m_objName and some extra info.
255 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
256 // However, the compiler may assume that this->m_objName fills
257 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
258 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
259 // bytes to cover the extra info.
260 char portName[2*FW_OBJ_NAME_MAX_SIZE];
261 (void) snprintf(
262 portName,
263 sizeof(portName),
264 "%s_cmdRegOut_OutputPort[%" PRI_PlatformIntType "]",
265 this->m_objName,
266 port
267 );
268 this->m_cmdRegOut_OutputPort[port].setObjName(portName);
269#endif
270 }
271
272 // Connect output port cmdResponseOut
273 for (
274 PlatformIntType port = 0;
275 port < static_cast<PlatformIntType>(this->getNum_cmdResponseOut_OutputPorts());
276 port++
277 ) {
278 this->m_cmdResponseOut_OutputPort[port].init();
279
280#if FW_OBJECT_NAMES == 1
281 // The port name consists of this->m_objName and some extra info.
282 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
283 // However, the compiler may assume that this->m_objName fills
284 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
285 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
286 // bytes to cover the extra info.
287 char portName[2*FW_OBJ_NAME_MAX_SIZE];
288 (void) snprintf(
289 portName,
290 sizeof(portName),
291 "%s_cmdResponseOut_OutputPort[%" PRI_PlatformIntType "]",
292 this->m_objName,
293 port
294 );
295 this->m_cmdResponseOut_OutputPort[port].setObjName(portName);
296#endif
297 }
298
299 // Connect output port eventOut
300 for (
301 PlatformIntType port = 0;
302 port < static_cast<PlatformIntType>(this->getNum_eventOut_OutputPorts());
303 port++
304 ) {
305 this->m_eventOut_OutputPort[port].init();
306
307#if FW_OBJECT_NAMES == 1
308 // The port name consists of this->m_objName and some extra info.
309 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
310 // However, the compiler may assume that this->m_objName fills
311 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
312 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
313 // bytes to cover the extra info.
314 char portName[2*FW_OBJ_NAME_MAX_SIZE];
315 (void) snprintf(
316 portName,
317 sizeof(portName),
318 "%s_eventOut_OutputPort[%" PRI_PlatformIntType "]",
319 this->m_objName,
320 port
321 );
322 this->m_eventOut_OutputPort[port].setObjName(portName);
323#endif
324 }
325
326#if FW_ENABLE_TEXT_LOGGING == 1
327 // Connect output port textEventOut
328 for (
329 PlatformIntType port = 0;
330 port < static_cast<PlatformIntType>(this->getNum_textEventOut_OutputPorts());
331 port++
332 ) {
333 this->m_textEventOut_OutputPort[port].init();
334
335#if FW_OBJECT_NAMES == 1
336 // The port name consists of this->m_objName and some extra info.
337 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
338 // However, the compiler may assume that this->m_objName fills
339 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
340 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
341 // bytes to cover the extra info.
342 char portName[2*FW_OBJ_NAME_MAX_SIZE];
343 (void) snprintf(
344 portName,
345 sizeof(portName),
346 "%s_textEventOut_OutputPort[%" PRI_PlatformIntType "]",
347 this->m_objName,
348 port
349 );
350 this->m_textEventOut_OutputPort[port].setObjName(portName);
351#endif
352 }
353#endif
354
355 // Connect output port timeCaller
356 for (
357 PlatformIntType port = 0;
358 port < static_cast<PlatformIntType>(this->getNum_timeCaller_OutputPorts());
359 port++
360 ) {
361 this->m_timeCaller_OutputPort[port].init();
362
363#if FW_OBJECT_NAMES == 1
364 // The port name consists of this->m_objName and some extra info.
365 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
366 // However, the compiler may assume that this->m_objName fills
367 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
368 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
369 // bytes to cover the extra info.
370 char portName[2*FW_OBJ_NAME_MAX_SIZE];
371 (void) snprintf(
372 portName,
373 sizeof(portName),
374 "%s_timeCaller_OutputPort[%" PRI_PlatformIntType "]",
375 this->m_objName,
376 port
377 );
378 this->m_timeCaller_OutputPort[port].setObjName(portName);
379#endif
380 }
381
382 // Connect output port tlmOut
383 for (
384 PlatformIntType port = 0;
385 port < static_cast<PlatformIntType>(this->getNum_tlmOut_OutputPorts());
386 port++
387 ) {
388 this->m_tlmOut_OutputPort[port].init();
389
390#if FW_OBJECT_NAMES == 1
391 // The port name consists of this->m_objName and some extra info.
392 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
393 // However, the compiler may assume that this->m_objName fills
394 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
395 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
396 // bytes to cover the extra info.
397 char portName[2*FW_OBJ_NAME_MAX_SIZE];
398 (void) snprintf(
399 portName,
400 sizeof(portName),
401 "%s_tlmOut_OutputPort[%" PRI_PlatformIntType "]",
402 this->m_objName,
403 port
404 );
405 this->m_tlmOut_OutputPort[port].setObjName(portName);
406#endif
407 }
408
409 // Connect output port FileComplete
410 for (
411 PlatformIntType port = 0;
412 port < static_cast<PlatformIntType>(this->getNum_FileComplete_OutputPorts());
413 port++
414 ) {
415 this->m_FileComplete_OutputPort[port].init();
416
417#if FW_OBJECT_NAMES == 1
418 // The port name consists of this->m_objName and some extra info.
419 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
420 // However, the compiler may assume that this->m_objName fills
421 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
422 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
423 // bytes to cover the extra info.
424 char portName[2*FW_OBJ_NAME_MAX_SIZE];
425 (void) snprintf(
426 portName,
427 sizeof(portName),
428 "%s_FileComplete_OutputPort[%" PRI_PlatformIntType "]",
429 this->m_objName,
430 port
431 );
432 this->m_FileComplete_OutputPort[port].setObjName(portName);
433#endif
434 }
435
436 // Connect output port bufferSendOut
437 for (
438 PlatformIntType port = 0;
439 port < static_cast<PlatformIntType>(this->getNum_bufferSendOut_OutputPorts());
440 port++
441 ) {
442 this->m_bufferSendOut_OutputPort[port].init();
443
444#if FW_OBJECT_NAMES == 1
445 // The port name consists of this->m_objName and some extra info.
446 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
447 // However, the compiler may assume that this->m_objName fills
448 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
449 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
450 // bytes to cover the extra info.
451 char portName[2*FW_OBJ_NAME_MAX_SIZE];
452 (void) snprintf(
453 portName,
454 sizeof(portName),
455 "%s_bufferSendOut_OutputPort[%" PRI_PlatformIntType "]",
456 this->m_objName,
457 port
458 );
459 this->m_bufferSendOut_OutputPort[port].setObjName(portName);
460#endif
461 }
462
463 // Connect output port pingOut
464 for (
465 PlatformIntType port = 0;
466 port < static_cast<PlatformIntType>(this->getNum_pingOut_OutputPorts());
467 port++
468 ) {
469 this->m_pingOut_OutputPort[port].init();
470
471#if FW_OBJECT_NAMES == 1
472 // The port name consists of this->m_objName and some extra info.
473 // We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
474 // However, the compiler may assume that this->m_objName fills
475 // the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
476 // avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
477 // bytes to cover the extra info.
478 char portName[2*FW_OBJ_NAME_MAX_SIZE];
479 (void) snprintf(
480 portName,
481 sizeof(portName),
482 "%s_pingOut_OutputPort[%" PRI_PlatformIntType "]",
483 this->m_objName,
484 port
485 );
486 this->m_pingOut_OutputPort[port].setObjName(portName);
487#endif
488 }
489
490 Os::Queue::QueueStatus qStat = this->createQueue(
491 queueDepth,
492 ComponentIpcSerializableBuffer::SERIALIZATION_SIZE
493 );
494 FW_ASSERT(
495 Os::Queue::QUEUE_OK == qStat,
496 static_cast<FwAssertArgType>(qStat)
497 );
498 }
499
500 // ----------------------------------------------------------------------
501 // Getters for special input ports
502 // ----------------------------------------------------------------------
503
504 Fw::InputCmdPort* FileDownlinkComponentBase ::
505 get_cmdIn_InputPort(NATIVE_INT_TYPE portNum)
506 {
507 FW_ASSERT(
508 portNum < this->getNum_cmdIn_InputPorts(),
509 static_cast<FwAssertArgType>(portNum)
510 );
511
512 return &this->m_cmdIn_InputPort[portNum];
513 }
514
515 // ----------------------------------------------------------------------
516 // Getters for typed input ports
517 // ----------------------------------------------------------------------
518
519 Svc::InputSchedPort* FileDownlinkComponentBase ::
520 get_Run_InputPort(NATIVE_INT_TYPE portNum)
521 {
522 FW_ASSERT(
523 portNum < this->getNum_Run_InputPorts(),
524 static_cast<FwAssertArgType>(portNum)
525 );
526
527 return &this->m_Run_InputPort[portNum];
528 }
529
530 Svc::InputSendFileRequestPort* FileDownlinkComponentBase ::
531 get_SendFile_InputPort(NATIVE_INT_TYPE portNum)
532 {
533 FW_ASSERT(
534 portNum < this->getNum_SendFile_InputPorts(),
535 static_cast<FwAssertArgType>(portNum)
536 );
537
538 return &this->m_SendFile_InputPort[portNum];
539 }
540
541 Fw::InputBufferSendPort* FileDownlinkComponentBase ::
542 get_bufferReturn_InputPort(NATIVE_INT_TYPE portNum)
543 {
544 FW_ASSERT(
545 portNum < this->getNum_bufferReturn_InputPorts(),
546 static_cast<FwAssertArgType>(portNum)
547 );
548
549 return &this->m_bufferReturn_InputPort[portNum];
550 }
551
552 Svc::InputPingPort* FileDownlinkComponentBase ::
553 get_pingIn_InputPort(NATIVE_INT_TYPE portNum)
554 {
555 FW_ASSERT(
556 portNum < this->getNum_pingIn_InputPorts(),
557 static_cast<FwAssertArgType>(portNum)
558 );
559
560 return &this->m_pingIn_InputPort[portNum];
561 }
562
563 // ----------------------------------------------------------------------
564 // Connect input ports to special output ports
565 // ----------------------------------------------------------------------
566
567 void FileDownlinkComponentBase ::
568 set_cmdRegOut_OutputPort(
569 NATIVE_INT_TYPE portNum,
571 )
572 {
573 FW_ASSERT(
574 portNum < this->getNum_cmdRegOut_OutputPorts(),
575 static_cast<FwAssertArgType>(portNum)
576 );
577
578 this->m_cmdRegOut_OutputPort[portNum].addCallPort(port);
579 }
580
581 void FileDownlinkComponentBase ::
582 set_cmdResponseOut_OutputPort(
583 NATIVE_INT_TYPE portNum,
585 )
586 {
587 FW_ASSERT(
588 portNum < this->getNum_cmdResponseOut_OutputPorts(),
589 static_cast<FwAssertArgType>(portNum)
590 );
591
592 this->m_cmdResponseOut_OutputPort[portNum].addCallPort(port);
593 }
594
595 void FileDownlinkComponentBase ::
596 set_eventOut_OutputPort(
597 NATIVE_INT_TYPE portNum,
598 Fw::InputLogPort* port
599 )
600 {
601 FW_ASSERT(
602 portNum < this->getNum_eventOut_OutputPorts(),
603 static_cast<FwAssertArgType>(portNum)
604 );
605
606 this->m_eventOut_OutputPort[portNum].addCallPort(port);
607 }
608
609#if FW_ENABLE_TEXT_LOGGING == 1
610
611 void FileDownlinkComponentBase ::
612 set_textEventOut_OutputPort(
613 NATIVE_INT_TYPE portNum,
615 )
616 {
617 FW_ASSERT(
618 portNum < this->getNum_textEventOut_OutputPorts(),
619 static_cast<FwAssertArgType>(portNum)
620 );
621
622 this->m_textEventOut_OutputPort[portNum].addCallPort(port);
623 }
624
625#endif
626
627 void FileDownlinkComponentBase ::
628 set_timeCaller_OutputPort(
629 NATIVE_INT_TYPE portNum,
631 )
632 {
633 FW_ASSERT(
634 portNum < this->getNum_timeCaller_OutputPorts(),
635 static_cast<FwAssertArgType>(portNum)
636 );
637
638 this->m_timeCaller_OutputPort[portNum].addCallPort(port);
639 }
640
641 void FileDownlinkComponentBase ::
642 set_tlmOut_OutputPort(
643 NATIVE_INT_TYPE portNum,
644 Fw::InputTlmPort* port
645 )
646 {
647 FW_ASSERT(
648 portNum < this->getNum_tlmOut_OutputPorts(),
649 static_cast<FwAssertArgType>(portNum)
650 );
651
652 this->m_tlmOut_OutputPort[portNum].addCallPort(port);
653 }
654
655 // ----------------------------------------------------------------------
656 // Connect typed input ports to typed output ports
657 // ----------------------------------------------------------------------
658
659 void FileDownlinkComponentBase ::
660 set_FileComplete_OutputPort(
661 NATIVE_INT_TYPE portNum,
663 )
664 {
665 FW_ASSERT(
666 portNum < this->getNum_FileComplete_OutputPorts(),
667 static_cast<FwAssertArgType>(portNum)
668 );
669
670 this->m_FileComplete_OutputPort[portNum].addCallPort(port);
671 }
672
673 void FileDownlinkComponentBase ::
674 set_bufferSendOut_OutputPort(
675 NATIVE_INT_TYPE portNum,
677 )
678 {
679 FW_ASSERT(
680 portNum < this->getNum_bufferSendOut_OutputPorts(),
681 static_cast<FwAssertArgType>(portNum)
682 );
683
684 this->m_bufferSendOut_OutputPort[portNum].addCallPort(port);
685 }
686
687 void FileDownlinkComponentBase ::
688 set_pingOut_OutputPort(
689 NATIVE_INT_TYPE portNum,
691 )
692 {
693 FW_ASSERT(
694 portNum < this->getNum_pingOut_OutputPorts(),
695 static_cast<FwAssertArgType>(portNum)
696 );
697
698 this->m_pingOut_OutputPort[portNum].addCallPort(port);
699 }
700
701#if FW_PORT_SERIALIZATION
702
703 // ----------------------------------------------------------------------
704 // Connect serial input ports to special output ports
705 // ----------------------------------------------------------------------
706
707 void FileDownlinkComponentBase ::
708 set_cmdRegOut_OutputPort(
709 NATIVE_INT_TYPE portNum,
710 Fw::InputSerializePort* port
711 )
712 {
713 FW_ASSERT(
714 portNum < this->getNum_cmdRegOut_OutputPorts(),
715 static_cast<FwAssertArgType>(portNum)
716 );
717
718 this->m_cmdRegOut_OutputPort[portNum].registerSerialPort(port);
719 }
720
721 void FileDownlinkComponentBase ::
722 set_cmdResponseOut_OutputPort(
723 NATIVE_INT_TYPE portNum,
724 Fw::InputSerializePort* port
725 )
726 {
727 FW_ASSERT(
728 portNum < this->getNum_cmdResponseOut_OutputPorts(),
729 static_cast<FwAssertArgType>(portNum)
730 );
731
732 this->m_cmdResponseOut_OutputPort[portNum].registerSerialPort(port);
733 }
734
735 void FileDownlinkComponentBase ::
736 set_eventOut_OutputPort(
737 NATIVE_INT_TYPE portNum,
738 Fw::InputSerializePort* port
739 )
740 {
741 FW_ASSERT(
742 portNum < this->getNum_eventOut_OutputPorts(),
743 static_cast<FwAssertArgType>(portNum)
744 );
745
746 this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
747 }
748
749#if FW_ENABLE_TEXT_LOGGING == 1
750
751 void FileDownlinkComponentBase ::
752 set_textEventOut_OutputPort(
753 NATIVE_INT_TYPE portNum,
754 Fw::InputSerializePort* port
755 )
756 {
757 FW_ASSERT(
758 portNum < this->getNum_textEventOut_OutputPorts(),
759 static_cast<FwAssertArgType>(portNum)
760 );
761
762 this->m_textEventOut_OutputPort[portNum].registerSerialPort(port);
763 }
764
765#endif
766
767 void FileDownlinkComponentBase ::
768 set_timeCaller_OutputPort(
769 NATIVE_INT_TYPE portNum,
770 Fw::InputSerializePort* port
771 )
772 {
773 FW_ASSERT(
774 portNum < this->getNum_timeCaller_OutputPorts(),
775 static_cast<FwAssertArgType>(portNum)
776 );
777
778 this->m_timeCaller_OutputPort[portNum].registerSerialPort(port);
779 }
780
781 void FileDownlinkComponentBase ::
782 set_tlmOut_OutputPort(
783 NATIVE_INT_TYPE portNum,
784 Fw::InputSerializePort* port
785 )
786 {
787 FW_ASSERT(
788 portNum < this->getNum_tlmOut_OutputPorts(),
789 static_cast<FwAssertArgType>(portNum)
790 );
791
792 this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
793 }
794
795#endif
796
797#if FW_PORT_SERIALIZATION
798
799 // ----------------------------------------------------------------------
800 // Connect serial input ports to typed output ports
801 // ----------------------------------------------------------------------
802
803 void FileDownlinkComponentBase ::
804 set_FileComplete_OutputPort(
805 NATIVE_INT_TYPE portNum,
806 Fw::InputSerializePort* port
807 )
808 {
809 FW_ASSERT(
810 portNum < this->getNum_FileComplete_OutputPorts(),
811 static_cast<FwAssertArgType>(portNum)
812 );
813
814 this->m_FileComplete_OutputPort[portNum].registerSerialPort(port);
815 }
816
817 void FileDownlinkComponentBase ::
818 set_bufferSendOut_OutputPort(
819 NATIVE_INT_TYPE portNum,
820 Fw::InputSerializePort* port
821 )
822 {
823 FW_ASSERT(
824 portNum < this->getNum_bufferSendOut_OutputPorts(),
825 static_cast<FwAssertArgType>(portNum)
826 );
827
828 this->m_bufferSendOut_OutputPort[portNum].registerSerialPort(port);
829 }
830
831 void FileDownlinkComponentBase ::
832 set_pingOut_OutputPort(
833 NATIVE_INT_TYPE portNum,
834 Fw::InputSerializePort* port
835 )
836 {
837 FW_ASSERT(
838 portNum < this->getNum_pingOut_OutputPorts(),
839 static_cast<FwAssertArgType>(portNum)
840 );
841
842 this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
843 }
844
845#endif
846
847 // ----------------------------------------------------------------------
848 // Command registration
849 // ----------------------------------------------------------------------
850
851 void FileDownlinkComponentBase ::
852 regCommands()
853 {
854 FW_ASSERT(this->m_cmdRegOut_OutputPort[0].isConnected());
855
856 this->m_cmdRegOut_OutputPort[0].invoke(
857 this->getIdBase() + OPCODE_SENDFILE
858 );
859
860 this->m_cmdRegOut_OutputPort[0].invoke(
861 this->getIdBase() + OPCODE_CANCEL
862 );
863
864 this->m_cmdRegOut_OutputPort[0].invoke(
865 this->getIdBase() + OPCODE_SENDPARTIAL
866 );
867 }
868
869 // ----------------------------------------------------------------------
870 // Component construction and destruction
871 // ----------------------------------------------------------------------
872
873 FileDownlinkComponentBase ::
874 FileDownlinkComponentBase(const char* compName) :
875 Fw::ActiveComponentBase(compName)
876 {
877
878 }
879
880 FileDownlinkComponentBase ::
881 ~FileDownlinkComponentBase()
882 {
883
884 }
885
886 // ----------------------------------------------------------------------
887 // Getters for numbers of special input ports
888 // ----------------------------------------------------------------------
889
890 NATIVE_INT_TYPE FileDownlinkComponentBase ::
891 getNum_cmdIn_InputPorts() const
892 {
893 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdIn_InputPort));
894 }
895
896 // ----------------------------------------------------------------------
897 // Getters for numbers of typed input ports
898 // ----------------------------------------------------------------------
899
900 NATIVE_INT_TYPE FileDownlinkComponentBase ::
901 getNum_Run_InputPorts() const
902 {
903 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_Run_InputPort));
904 }
905
906 NATIVE_INT_TYPE FileDownlinkComponentBase ::
907 getNum_SendFile_InputPorts() const
908 {
909 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_SendFile_InputPort));
910 }
911
912 NATIVE_INT_TYPE FileDownlinkComponentBase ::
913 getNum_bufferReturn_InputPorts() const
914 {
915 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferReturn_InputPort));
916 }
917
918 NATIVE_INT_TYPE FileDownlinkComponentBase ::
919 getNum_pingIn_InputPorts() const
920 {
921 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_pingIn_InputPort));
922 }
923
924 // ----------------------------------------------------------------------
925 // Getters for numbers of special output ports
926 // ----------------------------------------------------------------------
927
928 NATIVE_INT_TYPE FileDownlinkComponentBase ::
929 getNum_cmdRegOut_OutputPorts() const
930 {
931 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdRegOut_OutputPort));
932 }
933
934 NATIVE_INT_TYPE FileDownlinkComponentBase ::
935 getNum_cmdResponseOut_OutputPorts() const
936 {
937 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_cmdResponseOut_OutputPort));
938 }
939
940 NATIVE_INT_TYPE FileDownlinkComponentBase ::
941 getNum_eventOut_OutputPorts() const
942 {
943 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_eventOut_OutputPort));
944 }
945
946#if FW_ENABLE_TEXT_LOGGING == 1
947
948 NATIVE_INT_TYPE FileDownlinkComponentBase ::
949 getNum_textEventOut_OutputPorts() const
950 {
951 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_textEventOut_OutputPort));
952 }
953
954#endif
955
956 NATIVE_INT_TYPE FileDownlinkComponentBase ::
957 getNum_timeCaller_OutputPorts() const
958 {
959 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_timeCaller_OutputPort));
960 }
961
962 NATIVE_INT_TYPE FileDownlinkComponentBase ::
963 getNum_tlmOut_OutputPorts() const
964 {
965 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_tlmOut_OutputPort));
966 }
967
968 // ----------------------------------------------------------------------
969 // Getters for numbers of typed output ports
970 // ----------------------------------------------------------------------
971
972 NATIVE_INT_TYPE FileDownlinkComponentBase ::
973 getNum_FileComplete_OutputPorts() const
974 {
975 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_FileComplete_OutputPort));
976 }
977
978 NATIVE_INT_TYPE FileDownlinkComponentBase ::
979 getNum_bufferSendOut_OutputPorts() const
980 {
981 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_bufferSendOut_OutputPort));
982 }
983
984 NATIVE_INT_TYPE FileDownlinkComponentBase ::
985 getNum_pingOut_OutputPorts() const
986 {
987 return static_cast<NATIVE_INT_TYPE>(FW_NUM_ARRAY_ELEMENTS(this->m_pingOut_OutputPort));
988 }
989
990 // ----------------------------------------------------------------------
991 // Connection status queries for special output ports
992 // ----------------------------------------------------------------------
993
994 bool FileDownlinkComponentBase ::
995 isConnected_cmdRegOut_OutputPort(NATIVE_INT_TYPE portNum)
996 {
997 FW_ASSERT(
998 portNum < this->getNum_cmdRegOut_OutputPorts(),
999 static_cast<FwAssertArgType>(portNum)
1000 );
1001
1002 return this->m_cmdRegOut_OutputPort[portNum].isConnected();
1003 }
1004
1005 bool FileDownlinkComponentBase ::
1006 isConnected_cmdResponseOut_OutputPort(NATIVE_INT_TYPE portNum)
1007 {
1008 FW_ASSERT(
1009 portNum < this->getNum_cmdResponseOut_OutputPorts(),
1010 static_cast<FwAssertArgType>(portNum)
1011 );
1012
1013 return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
1014 }
1015
1016 bool FileDownlinkComponentBase ::
1017 isConnected_eventOut_OutputPort(NATIVE_INT_TYPE portNum)
1018 {
1019 FW_ASSERT(
1020 portNum < this->getNum_eventOut_OutputPorts(),
1021 static_cast<FwAssertArgType>(portNum)
1022 );
1023
1024 return this->m_eventOut_OutputPort[portNum].isConnected();
1025 }
1026
1027#if FW_ENABLE_TEXT_LOGGING == 1
1028
1029 bool FileDownlinkComponentBase ::
1030 isConnected_textEventOut_OutputPort(NATIVE_INT_TYPE portNum)
1031 {
1032 FW_ASSERT(
1033 portNum < this->getNum_textEventOut_OutputPorts(),
1034 static_cast<FwAssertArgType>(portNum)
1035 );
1036
1037 return this->m_textEventOut_OutputPort[portNum].isConnected();
1038 }
1039
1040#endif
1041
1042 bool FileDownlinkComponentBase ::
1043 isConnected_timeCaller_OutputPort(NATIVE_INT_TYPE portNum)
1044 {
1045 FW_ASSERT(
1046 portNum < this->getNum_timeCaller_OutputPorts(),
1047 static_cast<FwAssertArgType>(portNum)
1048 );
1049
1050 return this->m_timeCaller_OutputPort[portNum].isConnected();
1051 }
1052
1053 bool FileDownlinkComponentBase ::
1054 isConnected_tlmOut_OutputPort(NATIVE_INT_TYPE portNum)
1055 {
1056 FW_ASSERT(
1057 portNum < this->getNum_tlmOut_OutputPorts(),
1058 static_cast<FwAssertArgType>(portNum)
1059 );
1060
1061 return this->m_tlmOut_OutputPort[portNum].isConnected();
1062 }
1063
1064 // ----------------------------------------------------------------------
1065 // Connection status queries for typed output ports
1066 // ----------------------------------------------------------------------
1067
1068 bool FileDownlinkComponentBase ::
1069 isConnected_FileComplete_OutputPort(NATIVE_INT_TYPE portNum)
1070 {
1071 FW_ASSERT(
1072 portNum < this->getNum_FileComplete_OutputPorts(),
1073 static_cast<FwAssertArgType>(portNum)
1074 );
1075
1076 return this->m_FileComplete_OutputPort[portNum].isConnected();
1077 }
1078
1079 bool FileDownlinkComponentBase ::
1080 isConnected_bufferSendOut_OutputPort(NATIVE_INT_TYPE portNum)
1081 {
1082 FW_ASSERT(
1083 portNum < this->getNum_bufferSendOut_OutputPorts(),
1084 static_cast<FwAssertArgType>(portNum)
1085 );
1086
1087 return this->m_bufferSendOut_OutputPort[portNum].isConnected();
1088 }
1089
1090 bool FileDownlinkComponentBase ::
1091 isConnected_pingOut_OutputPort(NATIVE_INT_TYPE portNum)
1092 {
1093 FW_ASSERT(
1094 portNum < this->getNum_pingOut_OutputPorts(),
1095 static_cast<FwAssertArgType>(portNum)
1096 );
1097
1098 return this->m_pingOut_OutputPort[portNum].isConnected();
1099 }
1100
1101 // ----------------------------------------------------------------------
1102 // Port handler base-class functions for typed input ports
1103 //
1104 // Call these functions directly to bypass the corresponding ports
1105 // ----------------------------------------------------------------------
1106
1107 void FileDownlinkComponentBase ::
1108 Run_handlerBase(
1109 NATIVE_INT_TYPE portNum,
1110 NATIVE_UINT_TYPE context
1111 )
1112 {
1113 // Make sure port number is valid
1114 FW_ASSERT(
1115 portNum < this->getNum_Run_InputPorts(),
1116 static_cast<FwAssertArgType>(portNum)
1117 );
1118
1119 // Call pre-message hook
1120 Run_preMsgHook(
1121 portNum,
1122 context
1123 );
1124 ComponentIpcSerializableBuffer msg;
1126
1127 // Serialize message ID
1128 _status = msg.serialize(
1129 static_cast<NATIVE_INT_TYPE>(RUN_SCHED)
1130 );
1131 FW_ASSERT(
1132 _status == Fw::FW_SERIALIZE_OK,
1133 static_cast<FwAssertArgType>(_status)
1134 );
1135
1136 // Serialize port number
1137 _status = msg.serialize(portNum);
1138 FW_ASSERT(
1139 _status == Fw::FW_SERIALIZE_OK,
1140 static_cast<FwAssertArgType>(_status)
1141 );
1142
1143 // Serialize argument context
1144 _status = msg.serialize(context);
1145 FW_ASSERT(
1146 _status == Fw::FW_SERIALIZE_OK,
1147 static_cast<FwAssertArgType>(_status)
1148 );
1149
1150 // Send message
1152 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1153
1154 FW_ASSERT(
1155 qStatus == Os::Queue::QUEUE_OK,
1156 static_cast<FwAssertArgType>(qStatus)
1157 );
1158 }
1159
1160 Svc::SendFileResponse FileDownlinkComponentBase ::
1161 SendFile_handlerBase(
1162 NATIVE_INT_TYPE portNum,
1165 U32 offset,
1166 U32 length
1167 )
1168 {
1169 // Make sure port number is valid
1170 FW_ASSERT(
1171 portNum < this->getNum_SendFile_InputPorts(),
1172 static_cast<FwAssertArgType>(portNum)
1173 );
1174
1175 Svc::SendFileResponse retVal;
1176
1177 // Lock guard mutex before calling
1178 this->lock();
1179
1180 // Call handler function
1181 retVal = this->SendFile_handler(
1182 portNum,
1183 sourceFileName,
1184 destFileName,
1185 offset,
1186 length
1187 );
1188
1189 // Unlock guard mutex
1190 this->unLock();
1191
1192 return retVal;
1193 }
1194
1195 void FileDownlinkComponentBase ::
1196 bufferReturn_handlerBase(
1197 NATIVE_INT_TYPE portNum,
1198 Fw::Buffer& fwBuffer
1199 )
1200 {
1201 // Make sure port number is valid
1202 FW_ASSERT(
1203 portNum < this->getNum_bufferReturn_InputPorts(),
1204 static_cast<FwAssertArgType>(portNum)
1205 );
1206
1207 // Call pre-message hook
1208 bufferReturn_preMsgHook(
1209 portNum,
1210 fwBuffer
1211 );
1212 ComponentIpcSerializableBuffer msg;
1214
1215 // Serialize message ID
1216 _status = msg.serialize(
1217 static_cast<NATIVE_INT_TYPE>(BUFFERRETURN_BUFFERSEND)
1218 );
1219 FW_ASSERT(
1220 _status == Fw::FW_SERIALIZE_OK,
1221 static_cast<FwAssertArgType>(_status)
1222 );
1223
1224 // Serialize port number
1225 _status = msg.serialize(portNum);
1226 FW_ASSERT(
1227 _status == Fw::FW_SERIALIZE_OK,
1228 static_cast<FwAssertArgType>(_status)
1229 );
1230
1231 // Serialize argument fwBuffer
1232 _status = msg.serialize(fwBuffer);
1233 FW_ASSERT(
1234 _status == Fw::FW_SERIALIZE_OK,
1235 static_cast<FwAssertArgType>(_status)
1236 );
1237
1238 // Send message
1240 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1241
1242 FW_ASSERT(
1243 qStatus == Os::Queue::QUEUE_OK,
1244 static_cast<FwAssertArgType>(qStatus)
1245 );
1246 }
1247
1248 void FileDownlinkComponentBase ::
1249 pingIn_handlerBase(
1250 NATIVE_INT_TYPE portNum,
1251 U32 key
1252 )
1253 {
1254 // Make sure port number is valid
1255 FW_ASSERT(
1256 portNum < this->getNum_pingIn_InputPorts(),
1257 static_cast<FwAssertArgType>(portNum)
1258 );
1259
1260 // Call pre-message hook
1261 pingIn_preMsgHook(
1262 portNum,
1263 key
1264 );
1265 ComponentIpcSerializableBuffer msg;
1267
1268 // Serialize message ID
1269 _status = msg.serialize(
1270 static_cast<NATIVE_INT_TYPE>(PINGIN_PING)
1271 );
1272 FW_ASSERT(
1273 _status == Fw::FW_SERIALIZE_OK,
1274 static_cast<FwAssertArgType>(_status)
1275 );
1276
1277 // Serialize port number
1278 _status = msg.serialize(portNum);
1279 FW_ASSERT(
1280 _status == Fw::FW_SERIALIZE_OK,
1281 static_cast<FwAssertArgType>(_status)
1282 );
1283
1284 // Serialize argument key
1285 _status = msg.serialize(key);
1286 FW_ASSERT(
1287 _status == Fw::FW_SERIALIZE_OK,
1288 static_cast<FwAssertArgType>(_status)
1289 );
1290
1291 // Send message
1293 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1294
1295 FW_ASSERT(
1296 qStatus == Os::Queue::QUEUE_OK,
1297 static_cast<FwAssertArgType>(qStatus)
1298 );
1299 }
1300
1301 // ----------------------------------------------------------------------
1302 // Pre-message hooks for typed async input ports
1303 //
1304 // Each of these functions is invoked just before processing a message
1305 // on the corresponding port. By default, they do nothing. You can
1306 // override them to provide specific pre-message behavior.
1307 // ----------------------------------------------------------------------
1308
1309 void FileDownlinkComponentBase ::
1310 Run_preMsgHook(
1311 NATIVE_INT_TYPE portNum,
1312 NATIVE_UINT_TYPE context
1313 )
1314 {
1315 // Default: no-op
1316 }
1317
1318 void FileDownlinkComponentBase ::
1319 bufferReturn_preMsgHook(
1320 NATIVE_INT_TYPE portNum,
1321 Fw::Buffer& fwBuffer
1322 )
1323 {
1324 // Default: no-op
1325 }
1326
1327 void FileDownlinkComponentBase ::
1328 pingIn_preMsgHook(
1329 NATIVE_INT_TYPE portNum,
1330 U32 key
1331 )
1332 {
1333 // Default: no-op
1334 }
1335
1336 // ----------------------------------------------------------------------
1337 // Invocation functions for typed output ports
1338 // ----------------------------------------------------------------------
1339
1340 void FileDownlinkComponentBase ::
1341 FileComplete_out(
1342 NATIVE_INT_TYPE portNum,
1343 const Svc::SendFileResponse& resp
1344 )
1345 {
1346 FW_ASSERT(
1347 portNum < this->getNum_FileComplete_OutputPorts(),
1348 static_cast<FwAssertArgType>(portNum)
1349 );
1350 this->m_FileComplete_OutputPort[portNum].invoke(
1351 resp
1352 );
1353 }
1354
1355 void FileDownlinkComponentBase ::
1356 bufferSendOut_out(
1357 NATIVE_INT_TYPE portNum,
1358 Fw::Buffer& fwBuffer
1359 )
1360 {
1361 FW_ASSERT(
1362 portNum < this->getNum_bufferSendOut_OutputPorts(),
1363 static_cast<FwAssertArgType>(portNum)
1364 );
1365 this->m_bufferSendOut_OutputPort[portNum].invoke(
1366 fwBuffer
1367 );
1368 }
1369
1370 void FileDownlinkComponentBase ::
1371 pingOut_out(
1372 NATIVE_INT_TYPE portNum,
1373 U32 key
1374 )
1375 {
1376 FW_ASSERT(
1377 portNum < this->getNum_pingOut_OutputPorts(),
1378 static_cast<FwAssertArgType>(portNum)
1379 );
1380 this->m_pingOut_OutputPort[portNum].invoke(
1381 key
1382 );
1383 }
1384
1385 // ----------------------------------------------------------------------
1386 // Command response
1387 // ----------------------------------------------------------------------
1388
1389 void FileDownlinkComponentBase ::
1390 cmdResponse_out(
1391 FwOpcodeType opCode,
1392 U32 cmdSeq,
1393 Fw::CmdResponse response
1394 )
1395 {
1396 FW_ASSERT(this->m_cmdResponseOut_OutputPort[0].isConnected());
1397 this->m_cmdResponseOut_OutputPort[0].invoke(opCode, cmdSeq, response);
1398 }
1399
1400 // ----------------------------------------------------------------------
1401 // Command handler base-class functions
1402 //
1403 // Call these functions directly to bypass the command input port
1404 // ----------------------------------------------------------------------
1405
1406 void FileDownlinkComponentBase ::
1407 SendFile_cmdHandlerBase(
1408 FwOpcodeType opCode,
1409 U32 cmdSeq,
1410 Fw::CmdArgBuffer& args
1411 )
1412 {
1413 // Call pre-message hook
1414 this->SendFile_preMsgHook(opCode,cmdSeq);
1415
1416 // Defer deserializing arguments to the message dispatcher
1417 // to avoid deserializing and reserializing just for IPC
1418 ComponentIpcSerializableBuffer msg;
1420
1421 // Serialize for IPC
1422 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_SENDFILE));
1423 FW_ASSERT (
1424 _status == Fw::FW_SERIALIZE_OK,
1425 static_cast<FwAssertArgType>(_status)
1426 );
1427
1428 // Fake port number to make message dequeue work
1429 NATIVE_INT_TYPE port = 0;
1430
1431 _status = msg.serialize(port);
1432 FW_ASSERT (
1433 _status == Fw::FW_SERIALIZE_OK,
1434 static_cast<FwAssertArgType>(_status)
1435 );
1436
1437 _status = msg.serialize(opCode);
1438 FW_ASSERT (
1439 _status == Fw::FW_SERIALIZE_OK,
1440 static_cast<FwAssertArgType>(_status)
1441 );
1442
1443 _status = msg.serialize(cmdSeq);
1444 FW_ASSERT (
1445 _status == Fw::FW_SERIALIZE_OK,
1446 static_cast<FwAssertArgType>(_status)
1447 );
1448
1449 _status = msg.serialize(args);
1450 FW_ASSERT (
1451 _status == Fw::FW_SERIALIZE_OK,
1452 static_cast<FwAssertArgType>(_status)
1453 );
1454
1455 // Send message
1457 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1458
1459 FW_ASSERT(
1460 qStatus == Os::Queue::QUEUE_OK,
1461 static_cast<FwAssertArgType>(qStatus)
1462 );
1463 }
1464
1465 void FileDownlinkComponentBase ::
1466 Cancel_cmdHandlerBase(
1467 FwOpcodeType opCode,
1468 U32 cmdSeq,
1469 Fw::CmdArgBuffer& args
1470 )
1471 {
1472 // Call pre-message hook
1473 this->Cancel_preMsgHook(opCode,cmdSeq);
1474
1475 // Defer deserializing arguments to the message dispatcher
1476 // to avoid deserializing and reserializing just for IPC
1477 ComponentIpcSerializableBuffer msg;
1479
1480 // Serialize for IPC
1481 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_CANCEL));
1482 FW_ASSERT (
1483 _status == Fw::FW_SERIALIZE_OK,
1484 static_cast<FwAssertArgType>(_status)
1485 );
1486
1487 // Fake port number to make message dequeue work
1488 NATIVE_INT_TYPE port = 0;
1489
1490 _status = msg.serialize(port);
1491 FW_ASSERT (
1492 _status == Fw::FW_SERIALIZE_OK,
1493 static_cast<FwAssertArgType>(_status)
1494 );
1495
1496 _status = msg.serialize(opCode);
1497 FW_ASSERT (
1498 _status == Fw::FW_SERIALIZE_OK,
1499 static_cast<FwAssertArgType>(_status)
1500 );
1501
1502 _status = msg.serialize(cmdSeq);
1503 FW_ASSERT (
1504 _status == Fw::FW_SERIALIZE_OK,
1505 static_cast<FwAssertArgType>(_status)
1506 );
1507
1508 _status = msg.serialize(args);
1509 FW_ASSERT (
1510 _status == Fw::FW_SERIALIZE_OK,
1511 static_cast<FwAssertArgType>(_status)
1512 );
1513
1514 // Send message
1516 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1517
1518 FW_ASSERT(
1519 qStatus == Os::Queue::QUEUE_OK,
1520 static_cast<FwAssertArgType>(qStatus)
1521 );
1522 }
1523
1524 void FileDownlinkComponentBase ::
1525 SendPartial_cmdHandlerBase(
1526 FwOpcodeType opCode,
1527 U32 cmdSeq,
1528 Fw::CmdArgBuffer& args
1529 )
1530 {
1531 // Call pre-message hook
1532 this->SendPartial_preMsgHook(opCode,cmdSeq);
1533
1534 // Defer deserializing arguments to the message dispatcher
1535 // to avoid deserializing and reserializing just for IPC
1536 ComponentIpcSerializableBuffer msg;
1538
1539 // Serialize for IPC
1540 _status = msg.serialize(static_cast<NATIVE_INT_TYPE>(CMD_SENDPARTIAL));
1541 FW_ASSERT (
1542 _status == Fw::FW_SERIALIZE_OK,
1543 static_cast<FwAssertArgType>(_status)
1544 );
1545
1546 // Fake port number to make message dequeue work
1547 NATIVE_INT_TYPE port = 0;
1548
1549 _status = msg.serialize(port);
1550 FW_ASSERT (
1551 _status == Fw::FW_SERIALIZE_OK,
1552 static_cast<FwAssertArgType>(_status)
1553 );
1554
1555 _status = msg.serialize(opCode);
1556 FW_ASSERT (
1557 _status == Fw::FW_SERIALIZE_OK,
1558 static_cast<FwAssertArgType>(_status)
1559 );
1560
1561 _status = msg.serialize(cmdSeq);
1562 FW_ASSERT (
1563 _status == Fw::FW_SERIALIZE_OK,
1564 static_cast<FwAssertArgType>(_status)
1565 );
1566
1567 _status = msg.serialize(args);
1568 FW_ASSERT (
1569 _status == Fw::FW_SERIALIZE_OK,
1570 static_cast<FwAssertArgType>(_status)
1571 );
1572
1573 // Send message
1575 Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
1576
1577 FW_ASSERT(
1578 qStatus == Os::Queue::QUEUE_OK,
1579 static_cast<FwAssertArgType>(qStatus)
1580 );
1581 }
1582
1583 // ----------------------------------------------------------------------
1584 // Pre-message hooks for async commands
1585 //
1586 // Each of these functions is invoked just before processing the
1587 // corresponding command. By default they do nothing. You can
1588 // override them to provide specific pre-command behavior.
1589 // ----------------------------------------------------------------------
1590
1591 void FileDownlinkComponentBase ::
1592 SendFile_preMsgHook(
1593 FwOpcodeType opCode,
1594 U32 cmdSeq
1595 )
1596 {
1597 // Defaults to no-op; can be overridden
1598 (void) opCode;
1599 (void) cmdSeq;
1600 }
1601
1602 void FileDownlinkComponentBase ::
1603 Cancel_preMsgHook(
1604 FwOpcodeType opCode,
1605 U32 cmdSeq
1606 )
1607 {
1608 // Defaults to no-op; can be overridden
1609 (void) opCode;
1610 (void) cmdSeq;
1611 }
1612
1613 void FileDownlinkComponentBase ::
1614 SendPartial_preMsgHook(
1615 FwOpcodeType opCode,
1616 U32 cmdSeq
1617 )
1618 {
1619 // Defaults to no-op; can be overridden
1620 (void) opCode;
1621 (void) cmdSeq;
1622 }
1623
1624 // ----------------------------------------------------------------------
1625 // Event logging functions
1626 // ----------------------------------------------------------------------
1627
1628 void FileDownlinkComponentBase ::
1629 log_WARNING_HI_FileOpenError(const Fw::LogStringArg& fileName)
1630 {
1631 // Get the time
1632 Fw::Time _logTime;
1633 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1634 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1635 }
1636
1637 FwEventIdType _id = static_cast<FwEventIdType>(0);
1638
1639 _id = this->getIdBase() + EVENTID_FILEOPENERROR;
1640
1641 // Emit the event on the log port
1642 if (this->m_eventOut_OutputPort[0].isConnected()) {
1643 Fw::LogBuffer _logBuff;
1645
1646#if FW_AMPCS_COMPATIBLE
1647 // Serialize the number of arguments
1648 _status = _logBuff.serialize(static_cast<U8>(1));
1649 FW_ASSERT(
1650 _status == Fw::FW_SERIALIZE_OK,
1651 static_cast<FwAssertArgType>(_status)
1652 );
1653#endif
1654
1655 _status = fileName.serialize(_logBuff, 100);
1656 FW_ASSERT(
1657 _status == Fw::FW_SERIALIZE_OK,
1658 static_cast<FwAssertArgType>(_status)
1659 );
1660
1661 this->m_eventOut_OutputPort[0].invoke(
1662 _id,
1663 _logTime,
1665 _logBuff
1666 );
1667 }
1668
1669 // Emit the event on the text log port
1670#if FW_ENABLE_TEXT_LOGGING
1671 if (this->m_textEventOut_OutputPort[0].isConnected()) {
1672#if FW_OBJECT_NAMES == 1
1673 const char* _formatString =
1674 "(%s) %s: Could not open file %s";
1675#else
1676 const char* _formatString =
1677 "%s: Could not open file %s";
1678#endif
1679
1680 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1681
1682 (void) snprintf(
1683 _textBuffer,
1685 _formatString,
1686#if FW_OBJECT_NAMES == 1
1687 this->m_objName,
1688#endif
1689 "FileOpenError ",
1690 fileName.toChar()
1691 );
1692
1693 // Null terminate
1694 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1695 Fw::TextLogString _logString = _textBuffer;
1696 this->m_textEventOut_OutputPort[0].invoke(
1697 _id,
1698 _logTime,
1700 _logString
1701 );
1702 }
1703#endif
1704 }
1705
1706 void FileDownlinkComponentBase ::
1707 log_WARNING_HI_FileReadError(
1708 const Fw::LogStringArg& fileName,
1709 I32 status
1710 )
1711 {
1712 // Get the time
1713 Fw::Time _logTime;
1714 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1715 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1716 }
1717
1718 FwEventIdType _id = static_cast<FwEventIdType>(0);
1719
1720 _id = this->getIdBase() + EVENTID_FILEREADERROR;
1721
1722 // Emit the event on the log port
1723 if (this->m_eventOut_OutputPort[0].isConnected()) {
1724 Fw::LogBuffer _logBuff;
1726
1727#if FW_AMPCS_COMPATIBLE
1728 // Serialize the number of arguments
1729 _status = _logBuff.serialize(static_cast<U8>(2));
1730 FW_ASSERT(
1731 _status == Fw::FW_SERIALIZE_OK,
1732 static_cast<FwAssertArgType>(_status)
1733 );
1734#endif
1735
1736 _status = fileName.serialize(_logBuff, 100);
1737 FW_ASSERT(
1738 _status == Fw::FW_SERIALIZE_OK,
1739 static_cast<FwAssertArgType>(_status)
1740 );
1741
1742#if FW_AMPCS_COMPATIBLE
1743 // Serialize the argument size
1744 _status = _logBuff.serialize(
1745 static_cast<U8>(sizeof(I32))
1746 );
1747 FW_ASSERT(
1748 _status == Fw::FW_SERIALIZE_OK,
1749 static_cast<FwAssertArgType>(_status)
1750 );
1751#endif
1752 _status = _logBuff.serialize(status);
1753 FW_ASSERT(
1754 _status == Fw::FW_SERIALIZE_OK,
1755 static_cast<FwAssertArgType>(_status)
1756 );
1757
1758 this->m_eventOut_OutputPort[0].invoke(
1759 _id,
1760 _logTime,
1762 _logBuff
1763 );
1764 }
1765
1766 // Emit the event on the text log port
1767#if FW_ENABLE_TEXT_LOGGING
1768 if (this->m_textEventOut_OutputPort[0].isConnected()) {
1769#if FW_OBJECT_NAMES == 1
1770 const char* _formatString =
1771 "(%s) %s: Could not read file %s with status %" PRIi32 "";
1772#else
1773 const char* _formatString =
1774 "%s: Could not read file %s with status %" PRIi32 "";
1775#endif
1776
1777 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1778
1779 (void) snprintf(
1780 _textBuffer,
1782 _formatString,
1783#if FW_OBJECT_NAMES == 1
1784 this->m_objName,
1785#endif
1786 "FileReadError ",
1787 fileName.toChar(),
1788 status
1789 );
1790
1791 // Null terminate
1792 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1793 Fw::TextLogString _logString = _textBuffer;
1794 this->m_textEventOut_OutputPort[0].invoke(
1795 _id,
1796 _logTime,
1798 _logString
1799 );
1800 }
1801#endif
1802 }
1803
1804 void FileDownlinkComponentBase ::
1805 log_ACTIVITY_HI_FileSent(
1806 const Fw::LogStringArg& sourceFileName,
1807 const Fw::LogStringArg& destFileName
1808 )
1809 {
1810 // Get the time
1811 Fw::Time _logTime;
1812 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1813 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1814 }
1815
1816 FwEventIdType _id = static_cast<FwEventIdType>(0);
1817
1818 _id = this->getIdBase() + EVENTID_FILESENT;
1819
1820 // Emit the event on the log port
1821 if (this->m_eventOut_OutputPort[0].isConnected()) {
1822 Fw::LogBuffer _logBuff;
1824
1825#if FW_AMPCS_COMPATIBLE
1826 // Serialize the number of arguments
1827 _status = _logBuff.serialize(static_cast<U8>(2));
1828 FW_ASSERT(
1829 _status == Fw::FW_SERIALIZE_OK,
1830 static_cast<FwAssertArgType>(_status)
1831 );
1832#endif
1833
1834 _status = sourceFileName.serialize(_logBuff, 100);
1835 FW_ASSERT(
1836 _status == Fw::FW_SERIALIZE_OK,
1837 static_cast<FwAssertArgType>(_status)
1838 );
1839
1840 _status = destFileName.serialize(_logBuff, 100);
1841 FW_ASSERT(
1842 _status == Fw::FW_SERIALIZE_OK,
1843 static_cast<FwAssertArgType>(_status)
1844 );
1845
1846 this->m_eventOut_OutputPort[0].invoke(
1847 _id,
1848 _logTime,
1850 _logBuff
1851 );
1852 }
1853
1854 // Emit the event on the text log port
1855#if FW_ENABLE_TEXT_LOGGING
1856 if (this->m_textEventOut_OutputPort[0].isConnected()) {
1857#if FW_OBJECT_NAMES == 1
1858 const char* _formatString =
1859 "(%s) %s: Sent file %s to file %s";
1860#else
1861 const char* _formatString =
1862 "%s: Sent file %s to file %s";
1863#endif
1864
1865 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1866
1867 (void) snprintf(
1868 _textBuffer,
1870 _formatString,
1871#if FW_OBJECT_NAMES == 1
1872 this->m_objName,
1873#endif
1874 "FileSent ",
1875 sourceFileName.toChar(),
1876 destFileName.toChar()
1877 );
1878
1879 // Null terminate
1880 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1881 Fw::TextLogString _logString = _textBuffer;
1882 this->m_textEventOut_OutputPort[0].invoke(
1883 _id,
1884 _logTime,
1886 _logString
1887 );
1888 }
1889#endif
1890 }
1891
1892 void FileDownlinkComponentBase ::
1893 log_ACTIVITY_HI_DownlinkCanceled(
1894 const Fw::LogStringArg& sourceFileName,
1895 const Fw::LogStringArg& destFileName
1896 )
1897 {
1898 // Get the time
1899 Fw::Time _logTime;
1900 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1901 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1902 }
1903
1904 FwEventIdType _id = static_cast<FwEventIdType>(0);
1905
1906 _id = this->getIdBase() + EVENTID_DOWNLINKCANCELED;
1907
1908 // Emit the event on the log port
1909 if (this->m_eventOut_OutputPort[0].isConnected()) {
1910 Fw::LogBuffer _logBuff;
1912
1913#if FW_AMPCS_COMPATIBLE
1914 // Serialize the number of arguments
1915 _status = _logBuff.serialize(static_cast<U8>(2));
1916 FW_ASSERT(
1917 _status == Fw::FW_SERIALIZE_OK,
1918 static_cast<FwAssertArgType>(_status)
1919 );
1920#endif
1921
1922 _status = sourceFileName.serialize(_logBuff, 100);
1923 FW_ASSERT(
1924 _status == Fw::FW_SERIALIZE_OK,
1925 static_cast<FwAssertArgType>(_status)
1926 );
1927
1928 _status = destFileName.serialize(_logBuff, 100);
1929 FW_ASSERT(
1930 _status == Fw::FW_SERIALIZE_OK,
1931 static_cast<FwAssertArgType>(_status)
1932 );
1933
1934 this->m_eventOut_OutputPort[0].invoke(
1935 _id,
1936 _logTime,
1938 _logBuff
1939 );
1940 }
1941
1942 // Emit the event on the text log port
1943#if FW_ENABLE_TEXT_LOGGING
1944 if (this->m_textEventOut_OutputPort[0].isConnected()) {
1945#if FW_OBJECT_NAMES == 1
1946 const char* _formatString =
1947 "(%s) %s: Canceled downlink of file %s to file %s";
1948#else
1949 const char* _formatString =
1950 "%s: Canceled downlink of file %s to file %s";
1951#endif
1952
1953 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
1954
1955 (void) snprintf(
1956 _textBuffer,
1958 _formatString,
1959#if FW_OBJECT_NAMES == 1
1960 this->m_objName,
1961#endif
1962 "DownlinkCanceled ",
1963 sourceFileName.toChar(),
1964 destFileName.toChar()
1965 );
1966
1967 // Null terminate
1968 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
1969 Fw::TextLogString _logString = _textBuffer;
1970 this->m_textEventOut_OutputPort[0].invoke(
1971 _id,
1972 _logTime,
1974 _logString
1975 );
1976 }
1977#endif
1978 }
1979
1980 void FileDownlinkComponentBase ::
1981 log_WARNING_HI_DownlinkTimeout(
1982 const Fw::LogStringArg& sourceFileName,
1983 const Fw::LogStringArg& destFileName
1984 )
1985 {
1986 // Get the time
1987 Fw::Time _logTime;
1988 if (this->m_timeCaller_OutputPort[0].isConnected()) {
1989 this->m_timeCaller_OutputPort[0].invoke(_logTime);
1990 }
1991
1992 FwEventIdType _id = static_cast<FwEventIdType>(0);
1993
1994 _id = this->getIdBase() + EVENTID_DOWNLINKTIMEOUT;
1995
1996 // Emit the event on the log port
1997 if (this->m_eventOut_OutputPort[0].isConnected()) {
1998 Fw::LogBuffer _logBuff;
2000
2001#if FW_AMPCS_COMPATIBLE
2002 // Serialize the number of arguments
2003 _status = _logBuff.serialize(static_cast<U8>(2));
2004 FW_ASSERT(
2005 _status == Fw::FW_SERIALIZE_OK,
2006 static_cast<FwAssertArgType>(_status)
2007 );
2008#endif
2009
2010 _status = sourceFileName.serialize(_logBuff, 100);
2011 FW_ASSERT(
2012 _status == Fw::FW_SERIALIZE_OK,
2013 static_cast<FwAssertArgType>(_status)
2014 );
2015
2016 _status = destFileName.serialize(_logBuff, 100);
2017 FW_ASSERT(
2018 _status == Fw::FW_SERIALIZE_OK,
2019 static_cast<FwAssertArgType>(_status)
2020 );
2021
2022 this->m_eventOut_OutputPort[0].invoke(
2023 _id,
2024 _logTime,
2026 _logBuff
2027 );
2028 }
2029
2030 // Emit the event on the text log port
2031#if FW_ENABLE_TEXT_LOGGING
2032 if (this->m_textEventOut_OutputPort[0].isConnected()) {
2033#if FW_OBJECT_NAMES == 1
2034 const char* _formatString =
2035 "(%s) %s: Timeout occurred during downlink of file %s to file %s. Downlink has been canceled.";
2036#else
2037 const char* _formatString =
2038 "%s: Timeout occurred during downlink of file %s to file %s. Downlink has been canceled.";
2039#endif
2040
2041 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2042
2043 (void) snprintf(
2044 _textBuffer,
2046 _formatString,
2047#if FW_OBJECT_NAMES == 1
2048 this->m_objName,
2049#endif
2050 "DownlinkTimeout ",
2051 sourceFileName.toChar(),
2052 destFileName.toChar()
2053 );
2054
2055 // Null terminate
2056 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2057 Fw::TextLogString _logString = _textBuffer;
2058 this->m_textEventOut_OutputPort[0].invoke(
2059 _id,
2060 _logTime,
2062 _logString
2063 );
2064 }
2065#endif
2066 }
2067
2068 void FileDownlinkComponentBase ::
2069 log_WARNING_LO_DownlinkPartialWarning(
2070 U32 startOffset,
2071 U32 length,
2072 U32 filesize,
2073 const Fw::LogStringArg& sourceFileName,
2074 const Fw::LogStringArg& destFileName
2075 )
2076 {
2077 // Get the time
2078 Fw::Time _logTime;
2079 if (this->m_timeCaller_OutputPort[0].isConnected()) {
2080 this->m_timeCaller_OutputPort[0].invoke(_logTime);
2081 }
2082
2083 FwEventIdType _id = static_cast<FwEventIdType>(0);
2084
2085 _id = this->getIdBase() + EVENTID_DOWNLINKPARTIALWARNING;
2086
2087 // Emit the event on the log port
2088 if (this->m_eventOut_OutputPort[0].isConnected()) {
2089 Fw::LogBuffer _logBuff;
2091
2092#if FW_AMPCS_COMPATIBLE
2093 // Serialize the number of arguments
2094 _status = _logBuff.serialize(static_cast<U8>(5));
2095 FW_ASSERT(
2096 _status == Fw::FW_SERIALIZE_OK,
2097 static_cast<FwAssertArgType>(_status)
2098 );
2099#endif
2100
2101#if FW_AMPCS_COMPATIBLE
2102 // Serialize the argument size
2103 _status = _logBuff.serialize(
2104 static_cast<U8>(sizeof(U32))
2105 );
2106 FW_ASSERT(
2107 _status == Fw::FW_SERIALIZE_OK,
2108 static_cast<FwAssertArgType>(_status)
2109 );
2110#endif
2111 _status = _logBuff.serialize(startOffset);
2112 FW_ASSERT(
2113 _status == Fw::FW_SERIALIZE_OK,
2114 static_cast<FwAssertArgType>(_status)
2115 );
2116
2117#if FW_AMPCS_COMPATIBLE
2118 // Serialize the argument size
2119 _status = _logBuff.serialize(
2120 static_cast<U8>(sizeof(U32))
2121 );
2122 FW_ASSERT(
2123 _status == Fw::FW_SERIALIZE_OK,
2124 static_cast<FwAssertArgType>(_status)
2125 );
2126#endif
2127 _status = _logBuff.serialize(length);
2128 FW_ASSERT(
2129 _status == Fw::FW_SERIALIZE_OK,
2130 static_cast<FwAssertArgType>(_status)
2131 );
2132
2133#if FW_AMPCS_COMPATIBLE
2134 // Serialize the argument size
2135 _status = _logBuff.serialize(
2136 static_cast<U8>(sizeof(U32))
2137 );
2138 FW_ASSERT(
2139 _status == Fw::FW_SERIALIZE_OK,
2140 static_cast<FwAssertArgType>(_status)
2141 );
2142#endif
2143 _status = _logBuff.serialize(filesize);
2144 FW_ASSERT(
2145 _status == Fw::FW_SERIALIZE_OK,
2146 static_cast<FwAssertArgType>(_status)
2147 );
2148
2149 _status = sourceFileName.serialize(_logBuff, 100);
2150 FW_ASSERT(
2151 _status == Fw::FW_SERIALIZE_OK,
2152 static_cast<FwAssertArgType>(_status)
2153 );
2154
2155 _status = destFileName.serialize(_logBuff, 100);
2156 FW_ASSERT(
2157 _status == Fw::FW_SERIALIZE_OK,
2158 static_cast<FwAssertArgType>(_status)
2159 );
2160
2161 this->m_eventOut_OutputPort[0].invoke(
2162 _id,
2163 _logTime,
2165 _logBuff
2166 );
2167 }
2168
2169 // Emit the event on the text log port
2170#if FW_ENABLE_TEXT_LOGGING
2171 if (this->m_textEventOut_OutputPort[0].isConnected()) {
2172#if FW_OBJECT_NAMES == 1
2173 const char* _formatString =
2174 "(%s) %s: Offset %" PRIu32 " plus length %" PRIu32 " is greater than source size %" PRIu32 " for partial downlink of file %s to file %s. ";
2175#else
2176 const char* _formatString =
2177 "%s: Offset %" PRIu32 " plus length %" PRIu32 " is greater than source size %" PRIu32 " for partial downlink of file %s to file %s. ";
2178#endif
2179
2180 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2181
2182 (void) snprintf(
2183 _textBuffer,
2185 _formatString,
2186#if FW_OBJECT_NAMES == 1
2187 this->m_objName,
2188#endif
2189 "DownlinkPartialWarning ",
2190 startOffset,
2191 length,
2192 filesize,
2193 sourceFileName.toChar(),
2194 destFileName.toChar()
2195 );
2196
2197 // Null terminate
2198 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2199 Fw::TextLogString _logString = _textBuffer;
2200 this->m_textEventOut_OutputPort[0].invoke(
2201 _id,
2202 _logTime,
2204 _logString
2205 );
2206 }
2207#endif
2208 }
2209
2210 void FileDownlinkComponentBase ::
2211 log_WARNING_HI_DownlinkPartialFail(
2212 const Fw::LogStringArg& sourceFileName,
2213 const Fw::LogStringArg& destFileName,
2214 U32 startOffset,
2215 U32 filesize
2216 )
2217 {
2218 // Get the time
2219 Fw::Time _logTime;
2220 if (this->m_timeCaller_OutputPort[0].isConnected()) {
2221 this->m_timeCaller_OutputPort[0].invoke(_logTime);
2222 }
2223
2224 FwEventIdType _id = static_cast<FwEventIdType>(0);
2225
2226 _id = this->getIdBase() + EVENTID_DOWNLINKPARTIALFAIL;
2227
2228 // Emit the event on the log port
2229 if (this->m_eventOut_OutputPort[0].isConnected()) {
2230 Fw::LogBuffer _logBuff;
2232
2233#if FW_AMPCS_COMPATIBLE
2234 // Serialize the number of arguments
2235 _status = _logBuff.serialize(static_cast<U8>(4));
2236 FW_ASSERT(
2237 _status == Fw::FW_SERIALIZE_OK,
2238 static_cast<FwAssertArgType>(_status)
2239 );
2240#endif
2241
2242 _status = sourceFileName.serialize(_logBuff, 100);
2243 FW_ASSERT(
2244 _status == Fw::FW_SERIALIZE_OK,
2245 static_cast<FwAssertArgType>(_status)
2246 );
2247
2248 _status = destFileName.serialize(_logBuff, 100);
2249 FW_ASSERT(
2250 _status == Fw::FW_SERIALIZE_OK,
2251 static_cast<FwAssertArgType>(_status)
2252 );
2253
2254#if FW_AMPCS_COMPATIBLE
2255 // Serialize the argument size
2256 _status = _logBuff.serialize(
2257 static_cast<U8>(sizeof(U32))
2258 );
2259 FW_ASSERT(
2260 _status == Fw::FW_SERIALIZE_OK,
2261 static_cast<FwAssertArgType>(_status)
2262 );
2263#endif
2264 _status = _logBuff.serialize(startOffset);
2265 FW_ASSERT(
2266 _status == Fw::FW_SERIALIZE_OK,
2267 static_cast<FwAssertArgType>(_status)
2268 );
2269
2270#if FW_AMPCS_COMPATIBLE
2271 // Serialize the argument size
2272 _status = _logBuff.serialize(
2273 static_cast<U8>(sizeof(U32))
2274 );
2275 FW_ASSERT(
2276 _status == Fw::FW_SERIALIZE_OK,
2277 static_cast<FwAssertArgType>(_status)
2278 );
2279#endif
2280 _status = _logBuff.serialize(filesize);
2281 FW_ASSERT(
2282 _status == Fw::FW_SERIALIZE_OK,
2283 static_cast<FwAssertArgType>(_status)
2284 );
2285
2286 this->m_eventOut_OutputPort[0].invoke(
2287 _id,
2288 _logTime,
2290 _logBuff
2291 );
2292 }
2293
2294 // Emit the event on the text log port
2295#if FW_ENABLE_TEXT_LOGGING
2296 if (this->m_textEventOut_OutputPort[0].isConnected()) {
2297#if FW_OBJECT_NAMES == 1
2298 const char* _formatString =
2299 "(%s) %s: Error occurred during partial downlink of file %s to file %s. Offset %" PRIu32 " greater than or equal to source filesize %" PRIu32 ".";
2300#else
2301 const char* _formatString =
2302 "%s: Error occurred during partial downlink of file %s to file %s. Offset %" PRIu32 " greater than or equal to source filesize %" PRIu32 ".";
2303#endif
2304
2305 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2306
2307 (void) snprintf(
2308 _textBuffer,
2310 _formatString,
2311#if FW_OBJECT_NAMES == 1
2312 this->m_objName,
2313#endif
2314 "DownlinkPartialFail ",
2315 sourceFileName.toChar(),
2316 destFileName.toChar(),
2317 startOffset,
2318 filesize
2319 );
2320
2321 // Null terminate
2322 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2323 Fw::TextLogString _logString = _textBuffer;
2324 this->m_textEventOut_OutputPort[0].invoke(
2325 _id,
2326 _logTime,
2328 _logString
2329 );
2330 }
2331#endif
2332 }
2333
2334 void FileDownlinkComponentBase ::
2335 log_WARNING_HI_SendDataFail(
2336 const Fw::LogStringArg& sourceFileName,
2337 U32 byteOffset
2338 )
2339 {
2340 // Get the time
2341 Fw::Time _logTime;
2342 if (this->m_timeCaller_OutputPort[0].isConnected()) {
2343 this->m_timeCaller_OutputPort[0].invoke(_logTime);
2344 }
2345
2346 FwEventIdType _id = static_cast<FwEventIdType>(0);
2347
2348 _id = this->getIdBase() + EVENTID_SENDDATAFAIL;
2349
2350 // Emit the event on the log port
2351 if (this->m_eventOut_OutputPort[0].isConnected()) {
2352 Fw::LogBuffer _logBuff;
2354
2355#if FW_AMPCS_COMPATIBLE
2356 // Serialize the number of arguments
2357 _status = _logBuff.serialize(static_cast<U8>(2));
2358 FW_ASSERT(
2359 _status == Fw::FW_SERIALIZE_OK,
2360 static_cast<FwAssertArgType>(_status)
2361 );
2362#endif
2363
2364 _status = sourceFileName.serialize(_logBuff, 100);
2365 FW_ASSERT(
2366 _status == Fw::FW_SERIALIZE_OK,
2367 static_cast<FwAssertArgType>(_status)
2368 );
2369
2370#if FW_AMPCS_COMPATIBLE
2371 // Serialize the argument size
2372 _status = _logBuff.serialize(
2373 static_cast<U8>(sizeof(U32))
2374 );
2375 FW_ASSERT(
2376 _status == Fw::FW_SERIALIZE_OK,
2377 static_cast<FwAssertArgType>(_status)
2378 );
2379#endif
2380 _status = _logBuff.serialize(byteOffset);
2381 FW_ASSERT(
2382 _status == Fw::FW_SERIALIZE_OK,
2383 static_cast<FwAssertArgType>(_status)
2384 );
2385
2386 this->m_eventOut_OutputPort[0].invoke(
2387 _id,
2388 _logTime,
2390 _logBuff
2391 );
2392 }
2393
2394 // Emit the event on the text log port
2395#if FW_ENABLE_TEXT_LOGGING
2396 if (this->m_textEventOut_OutputPort[0].isConnected()) {
2397#if FW_OBJECT_NAMES == 1
2398 const char* _formatString =
2399 "(%s) %s: Failed to send data packet from file %s at byte offset %" PRIu32 ".";
2400#else
2401 const char* _formatString =
2402 "%s: Failed to send data packet from file %s at byte offset %" PRIu32 ".";
2403#endif
2404
2405 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2406
2407 (void) snprintf(
2408 _textBuffer,
2410 _formatString,
2411#if FW_OBJECT_NAMES == 1
2412 this->m_objName,
2413#endif
2414 "SendDataFail ",
2415 sourceFileName.toChar(),
2416 byteOffset
2417 );
2418
2419 // Null terminate
2420 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2421 Fw::TextLogString _logString = _textBuffer;
2422 this->m_textEventOut_OutputPort[0].invoke(
2423 _id,
2424 _logTime,
2426 _logString
2427 );
2428 }
2429#endif
2430 }
2431
2432 void FileDownlinkComponentBase ::
2433 log_ACTIVITY_HI_SendStarted(
2434 U32 fileSize,
2435 const Fw::LogStringArg& sourceFileName,
2436 const Fw::LogStringArg& destFileName
2437 )
2438 {
2439 // Get the time
2440 Fw::Time _logTime;
2441 if (this->m_timeCaller_OutputPort[0].isConnected()) {
2442 this->m_timeCaller_OutputPort[0].invoke(_logTime);
2443 }
2444
2445 FwEventIdType _id = static_cast<FwEventIdType>(0);
2446
2447 _id = this->getIdBase() + EVENTID_SENDSTARTED;
2448
2449 // Emit the event on the log port
2450 if (this->m_eventOut_OutputPort[0].isConnected()) {
2451 Fw::LogBuffer _logBuff;
2453
2454#if FW_AMPCS_COMPATIBLE
2455 // Serialize the number of arguments
2456 _status = _logBuff.serialize(static_cast<U8>(3));
2457 FW_ASSERT(
2458 _status == Fw::FW_SERIALIZE_OK,
2459 static_cast<FwAssertArgType>(_status)
2460 );
2461#endif
2462
2463#if FW_AMPCS_COMPATIBLE
2464 // Serialize the argument size
2465 _status = _logBuff.serialize(
2466 static_cast<U8>(sizeof(U32))
2467 );
2468 FW_ASSERT(
2469 _status == Fw::FW_SERIALIZE_OK,
2470 static_cast<FwAssertArgType>(_status)
2471 );
2472#endif
2473 _status = _logBuff.serialize(fileSize);
2474 FW_ASSERT(
2475 _status == Fw::FW_SERIALIZE_OK,
2476 static_cast<FwAssertArgType>(_status)
2477 );
2478
2479 _status = sourceFileName.serialize(_logBuff, 100);
2480 FW_ASSERT(
2481 _status == Fw::FW_SERIALIZE_OK,
2482 static_cast<FwAssertArgType>(_status)
2483 );
2484
2485 _status = destFileName.serialize(_logBuff, 100);
2486 FW_ASSERT(
2487 _status == Fw::FW_SERIALIZE_OK,
2488 static_cast<FwAssertArgType>(_status)
2489 );
2490
2491 this->m_eventOut_OutputPort[0].invoke(
2492 _id,
2493 _logTime,
2495 _logBuff
2496 );
2497 }
2498
2499 // Emit the event on the text log port
2500#if FW_ENABLE_TEXT_LOGGING
2501 if (this->m_textEventOut_OutputPort[0].isConnected()) {
2502#if FW_OBJECT_NAMES == 1
2503 const char* _formatString =
2504 "(%s) %s: Downlink of %" PRIu32 " bytes started from %s to %s";
2505#else
2506 const char* _formatString =
2507 "%s: Downlink of %" PRIu32 " bytes started from %s to %s";
2508#endif
2509
2510 char _textBuffer[FW_LOG_TEXT_BUFFER_SIZE];
2511
2512 (void) snprintf(
2513 _textBuffer,
2515 _formatString,
2516#if FW_OBJECT_NAMES == 1
2517 this->m_objName,
2518#endif
2519 "SendStarted ",
2520 fileSize,
2521 sourceFileName.toChar(),
2522 destFileName.toChar()
2523 );
2524
2525 // Null terminate
2526 _textBuffer[FW_LOG_TEXT_BUFFER_SIZE-1] = 0;
2527 Fw::TextLogString _logString = _textBuffer;
2528 this->m_textEventOut_OutputPort[0].invoke(
2529 _id,
2530 _logTime,
2532 _logString
2533 );
2534 }
2535#endif
2536 }
2537
2538 // ----------------------------------------------------------------------
2539 // Telemetry write functions
2540 // ----------------------------------------------------------------------
2541
2542 void FileDownlinkComponentBase ::
2543 tlmWrite_FilesSent(
2544 U32 arg,
2545 Fw::Time _tlmTime
2546 )
2547 {
2548 if (this->m_tlmOut_OutputPort[0].isConnected()) {
2549 if (
2550 this->m_timeCaller_OutputPort[0].isConnected() &&
2551 (_tlmTime == Fw::ZERO_TIME)
2552 ) {
2553 this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2554 }
2555
2556 Fw::TlmBuffer _tlmBuff;
2557 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2558 FW_ASSERT(
2559 _stat == Fw::FW_SERIALIZE_OK,
2560 static_cast<FwAssertArgType>(_stat)
2561 );
2562
2563 FwChanIdType _id;
2564
2565 _id = this->getIdBase() + CHANNELID_FILESSENT;
2566
2567 this->m_tlmOut_OutputPort[0].invoke(
2568 _id,
2569 _tlmTime,
2570 _tlmBuff
2571 );
2572 }
2573 }
2574
2575 void FileDownlinkComponentBase ::
2576 tlmWrite_PacketsSent(
2577 U32 arg,
2578 Fw::Time _tlmTime
2579 )
2580 {
2581 if (this->m_tlmOut_OutputPort[0].isConnected()) {
2582 if (
2583 this->m_timeCaller_OutputPort[0].isConnected() &&
2584 (_tlmTime == Fw::ZERO_TIME)
2585 ) {
2586 this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2587 }
2588
2589 Fw::TlmBuffer _tlmBuff;
2590 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2591 FW_ASSERT(
2592 _stat == Fw::FW_SERIALIZE_OK,
2593 static_cast<FwAssertArgType>(_stat)
2594 );
2595
2596 FwChanIdType _id;
2597
2598 _id = this->getIdBase() + CHANNELID_PACKETSSENT;
2599
2600 this->m_tlmOut_OutputPort[0].invoke(
2601 _id,
2602 _tlmTime,
2603 _tlmBuff
2604 );
2605 }
2606 }
2607
2608 void FileDownlinkComponentBase ::
2609 tlmWrite_Warnings(
2610 U32 arg,
2611 Fw::Time _tlmTime
2612 )
2613 {
2614 if (this->m_tlmOut_OutputPort[0].isConnected()) {
2615 if (
2616 this->m_timeCaller_OutputPort[0].isConnected() &&
2617 (_tlmTime == Fw::ZERO_TIME)
2618 ) {
2619 this->m_timeCaller_OutputPort[0].invoke(_tlmTime);
2620 }
2621
2622 Fw::TlmBuffer _tlmBuff;
2623 Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
2624 FW_ASSERT(
2625 _stat == Fw::FW_SERIALIZE_OK,
2626 static_cast<FwAssertArgType>(_stat)
2627 );
2628
2629 FwChanIdType _id;
2630
2631 _id = this->getIdBase() + CHANNELID_WARNINGS;
2632
2633 this->m_tlmOut_OutputPort[0].invoke(
2634 _id,
2635 _tlmTime,
2636 _tlmBuff
2637 );
2638 }
2639 }
2640
2641 // ----------------------------------------------------------------------
2642 // Time
2643 // ----------------------------------------------------------------------
2644
2645 Fw::Time FileDownlinkComponentBase ::
2646 getTime()
2647 {
2648 if (this->m_timeCaller_OutputPort[0].isConnected()) {
2649 Fw::Time _time;
2650 this->m_timeCaller_OutputPort[0].invoke(_time);
2651 return _time;
2652 }
2653 else {
2654 return Fw::Time(TB_NONE, 0, 0);
2655 }
2656 }
2657
2658 // ----------------------------------------------------------------------
2659 // Mutex operations for guarded ports
2660 //
2661 // You can override these operations to provide more sophisticated
2662 // synchronization
2663 // ----------------------------------------------------------------------
2664
2665 void FileDownlinkComponentBase ::
2666 lock()
2667 {
2668 this->m_guardedPortMutex.lock();
2669 }
2670
2671 void FileDownlinkComponentBase ::
2672 unLock()
2673 {
2674 this->m_guardedPortMutex.unLock();
2675 }
2676
2677 // ----------------------------------------------------------------------
2678 // Message dispatch functions
2679 // ----------------------------------------------------------------------
2680
2681 Fw::QueuedComponentBase::MsgDispatchStatus FileDownlinkComponentBase ::
2682 doDispatch()
2683 {
2684 ComponentIpcSerializableBuffer msg;
2685 NATIVE_INT_TYPE priority = 0;
2686
2687 Os::Queue::QueueStatus msgStatus = this->m_queue.receive(
2688 msg,
2689 priority,
2691 );
2692 FW_ASSERT(
2693 msgStatus == Os::Queue::QUEUE_OK,
2694 static_cast<FwAssertArgType>(msgStatus)
2695 );
2696
2697 // Reset to beginning of buffer
2698 msg.resetDeser();
2699
2700 NATIVE_INT_TYPE desMsg = 0;
2701 Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
2702 FW_ASSERT(
2703 deserStatus == Fw::FW_SERIALIZE_OK,
2704 static_cast<FwAssertArgType>(deserStatus)
2705 );
2706
2707 MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
2708
2709 if (msgType == FILEDOWNLINK_COMPONENT_EXIT) {
2710 return MSG_DISPATCH_EXIT;
2711 }
2712
2713 NATIVE_INT_TYPE portNum = 0;
2714 deserStatus = msg.deserialize(portNum);
2715 FW_ASSERT(
2716 deserStatus == Fw::FW_SERIALIZE_OK,
2717 static_cast<FwAssertArgType>(deserStatus)
2718 );
2719
2720 switch (msgType) {
2721 // Handle async input port Run
2722 case RUN_SCHED: {
2723 // Deserialize argument context
2724 NATIVE_UINT_TYPE context;
2725 deserStatus = msg.deserialize(context);
2726 FW_ASSERT(
2727 deserStatus == Fw::FW_SERIALIZE_OK,
2728 static_cast<FwAssertArgType>(deserStatus)
2729 );
2730 // Call handler function
2731 this->Run_handler(
2732 portNum,
2733 context
2734 );
2735
2736 break;
2737 }
2738
2739 // Handle async input port bufferReturn
2740 case BUFFERRETURN_BUFFERSEND: {
2741 // Deserialize argument fwBuffer
2742 Fw::Buffer fwBuffer;
2743 deserStatus = msg.deserialize(fwBuffer);
2744 FW_ASSERT(
2745 deserStatus == Fw::FW_SERIALIZE_OK,
2746 static_cast<FwAssertArgType>(deserStatus)
2747 );
2748 // Call handler function
2749 this->bufferReturn_handler(
2750 portNum,
2751 fwBuffer
2752 );
2753
2754 break;
2755 }
2756
2757 // Handle async input port pingIn
2758 case PINGIN_PING: {
2759 // Deserialize argument key
2760 U32 key;
2761 deserStatus = msg.deserialize(key);
2762 FW_ASSERT(
2763 deserStatus == Fw::FW_SERIALIZE_OK,
2764 static_cast<FwAssertArgType>(deserStatus)
2765 );
2766 // Call handler function
2767 this->pingIn_handler(
2768 portNum,
2769 key
2770 );
2771
2772 break;
2773 }
2774
2775 // Handle command SendFile
2776 case CMD_SENDFILE: {
2777 // Deserialize opcode
2778 FwOpcodeType opCode = 0;
2779 deserStatus = msg.deserialize(opCode);
2780 FW_ASSERT (
2781 deserStatus == Fw::FW_SERIALIZE_OK,
2782 static_cast<FwAssertArgType>(deserStatus)
2783 );
2784
2785 // Deserialize command sequence
2786 U32 cmdSeq = 0;
2787 deserStatus = msg.deserialize(cmdSeq);
2788 FW_ASSERT (
2789 deserStatus == Fw::FW_SERIALIZE_OK,
2790 static_cast<FwAssertArgType>(deserStatus)
2791 );
2792
2793 // Deserialize command argument buffer
2794 Fw::CmdArgBuffer args;
2795 deserStatus = msg.deserialize(args);
2796 FW_ASSERT (
2797 deserStatus == Fw::FW_SERIALIZE_OK,
2798 static_cast<FwAssertArgType>(deserStatus)
2799 );
2800
2801 // Reset buffer
2802 args.resetDeser();
2803
2804 // Deserialize argument sourceFileName
2805 Fw::CmdStringArg sourceFileName;
2806 deserStatus = args.deserialize(sourceFileName);
2807 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2808 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2809 this->cmdResponse_out(
2810 opCode,
2811 cmdSeq,
2813 );
2814 }
2815 // Don't crash the task if bad arguments were passed from the ground
2816 break;
2817 }
2818
2819 // Deserialize argument destFileName
2820 Fw::CmdStringArg destFileName;
2821 deserStatus = args.deserialize(destFileName);
2822 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2823 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2824 this->cmdResponse_out(
2825 opCode,
2826 cmdSeq,
2828 );
2829 }
2830 // Don't crash the task if bad arguments were passed from the ground
2831 break;
2832 }
2833
2834 // Make sure there was no data left over.
2835 // That means the argument buffer size was incorrect.
2836#if FW_CMD_CHECK_RESIDUAL
2837 if (args.getBuffLeft() != 0) {
2838 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2839 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2840 }
2841 // Don't crash the task if bad arguments were passed from the ground
2842 break;
2843 }
2844#endif
2845
2846 // Call handler function
2847 this->SendFile_cmdHandler(
2848 opCode, cmdSeq,
2849 sourceFileName,
2850 destFileName
2851 );
2852
2853 break;
2854 }
2855
2856 // Handle command Cancel
2857 case CMD_CANCEL: {
2858 // Deserialize opcode
2859 FwOpcodeType opCode = 0;
2860 deserStatus = msg.deserialize(opCode);
2861 FW_ASSERT (
2862 deserStatus == Fw::FW_SERIALIZE_OK,
2863 static_cast<FwAssertArgType>(deserStatus)
2864 );
2865
2866 // Deserialize command sequence
2867 U32 cmdSeq = 0;
2868 deserStatus = msg.deserialize(cmdSeq);
2869 FW_ASSERT (
2870 deserStatus == Fw::FW_SERIALIZE_OK,
2871 static_cast<FwAssertArgType>(deserStatus)
2872 );
2873
2874 // Deserialize command argument buffer
2875 Fw::CmdArgBuffer args;
2876 deserStatus = msg.deserialize(args);
2877 FW_ASSERT (
2878 deserStatus == Fw::FW_SERIALIZE_OK,
2879 static_cast<FwAssertArgType>(deserStatus)
2880 );
2881
2882 // Reset buffer
2883 args.resetDeser();
2884
2885 // Make sure there was no data left over.
2886 // That means the argument buffer size was incorrect.
2887#if FW_CMD_CHECK_RESIDUAL
2888 if (args.getBuffLeft() != 0) {
2889 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2890 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2891 }
2892 // Don't crash the task if bad arguments were passed from the ground
2893 break;
2894 }
2895#endif
2896
2897 // Call handler function
2898 this->Cancel_cmdHandler(opCode, cmdSeq);
2899
2900 break;
2901 }
2902
2903 // Handle command SendPartial
2904 case CMD_SENDPARTIAL: {
2905 // Deserialize opcode
2906 FwOpcodeType opCode = 0;
2907 deserStatus = msg.deserialize(opCode);
2908 FW_ASSERT (
2909 deserStatus == Fw::FW_SERIALIZE_OK,
2910 static_cast<FwAssertArgType>(deserStatus)
2911 );
2912
2913 // Deserialize command sequence
2914 U32 cmdSeq = 0;
2915 deserStatus = msg.deserialize(cmdSeq);
2916 FW_ASSERT (
2917 deserStatus == Fw::FW_SERIALIZE_OK,
2918 static_cast<FwAssertArgType>(deserStatus)
2919 );
2920
2921 // Deserialize command argument buffer
2922 Fw::CmdArgBuffer args;
2923 deserStatus = msg.deserialize(args);
2924 FW_ASSERT (
2925 deserStatus == Fw::FW_SERIALIZE_OK,
2926 static_cast<FwAssertArgType>(deserStatus)
2927 );
2928
2929 // Reset buffer
2930 args.resetDeser();
2931
2932 // Deserialize argument sourceFileName
2933 Fw::CmdStringArg sourceFileName;
2934 deserStatus = args.deserialize(sourceFileName);
2935 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2936 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2937 this->cmdResponse_out(
2938 opCode,
2939 cmdSeq,
2941 );
2942 }
2943 // Don't crash the task if bad arguments were passed from the ground
2944 break;
2945 }
2946
2947 // Deserialize argument destFileName
2948 Fw::CmdStringArg destFileName;
2949 deserStatus = args.deserialize(destFileName);
2950 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2951 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2952 this->cmdResponse_out(
2953 opCode,
2954 cmdSeq,
2956 );
2957 }
2958 // Don't crash the task if bad arguments were passed from the ground
2959 break;
2960 }
2961
2962 // Deserialize argument startOffset
2963 U32 startOffset;
2964 deserStatus = args.deserialize(startOffset);
2965 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2966 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2967 this->cmdResponse_out(
2968 opCode,
2969 cmdSeq,
2971 );
2972 }
2973 // Don't crash the task if bad arguments were passed from the ground
2974 break;
2975 }
2976
2977 // Deserialize argument length
2978 U32 length;
2979 deserStatus = args.deserialize(length);
2980 if (deserStatus != Fw::FW_SERIALIZE_OK) {
2981 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2982 this->cmdResponse_out(
2983 opCode,
2984 cmdSeq,
2986 );
2987 }
2988 // Don't crash the task if bad arguments were passed from the ground
2989 break;
2990 }
2991
2992 // Make sure there was no data left over.
2993 // That means the argument buffer size was incorrect.
2994#if FW_CMD_CHECK_RESIDUAL
2995 if (args.getBuffLeft() != 0) {
2996 if (this->m_cmdResponseOut_OutputPort[0].isConnected()) {
2997 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2998 }
2999 // Don't crash the task if bad arguments were passed from the ground
3000 break;
3001 }
3002#endif
3003
3004 // Call handler function
3005 this->SendPartial_cmdHandler(
3006 opCode, cmdSeq,
3007 sourceFileName,
3008 destFileName,
3009 startOffset,
3010 length
3011 );
3012
3013 break;
3014 }
3015
3016 default:
3017 return MSG_DISPATCH_ERROR;
3018 }
3019
3020 return MSG_DISPATCH_OK;
3021 }
3022
3023 // ----------------------------------------------------------------------
3024 // Calls for messages received on special input ports
3025 // ----------------------------------------------------------------------
3026
3027 void FileDownlinkComponentBase ::
3028 m_p_cmdIn_in(
3029 Fw::PassiveComponentBase* callComp,
3030 NATIVE_INT_TYPE portNum,
3031 FwOpcodeType opCode,
3032 U32 cmdSeq,
3033 Fw::CmdArgBuffer& args
3034 )
3035 {
3036 FW_ASSERT(callComp);
3037 FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
3038
3039 const U32 idBase = callComp->getIdBase();
3040 FW_ASSERT(opCode >= idBase, opCode, idBase);
3041
3042 // Select base class function based on opcode
3043 switch (opCode - idBase) {
3044 case OPCODE_SENDFILE: {
3045 compPtr->SendFile_cmdHandlerBase(
3046 opCode,
3047 cmdSeq,
3048 args
3049 );
3050 break;
3051 }
3052
3053 case OPCODE_CANCEL: {
3054 compPtr->Cancel_cmdHandlerBase(
3055 opCode,
3056 cmdSeq,
3057 args
3058 );
3059 break;
3060 }
3061
3062 case OPCODE_SENDPARTIAL: {
3063 compPtr->SendPartial_cmdHandlerBase(
3064 opCode,
3065 cmdSeq,
3066 args
3067 );
3068 break;
3069 }
3070 }
3071 }
3072
3073 // ----------------------------------------------------------------------
3074 // Calls for messages received on typed input ports
3075 // ----------------------------------------------------------------------
3076
3077 void FileDownlinkComponentBase ::
3078 m_p_Run_in(
3079 Fw::PassiveComponentBase* callComp,
3080 NATIVE_INT_TYPE portNum,
3081 NATIVE_UINT_TYPE context
3082 )
3083 {
3084 FW_ASSERT(callComp);
3085 FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
3086 compPtr->Run_handlerBase(
3087 portNum,
3088 context
3089 );
3090 }
3091
3092 Svc::SendFileResponse FileDownlinkComponentBase ::
3093 m_p_SendFile_in(
3094 Fw::PassiveComponentBase* callComp,
3095 NATIVE_INT_TYPE portNum,
3098 U32 offset,
3099 U32 length
3100 )
3101 {
3102 FW_ASSERT(callComp);
3103 FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
3104 return compPtr->SendFile_handlerBase(
3105 portNum,
3106 sourceFileName,
3107 destFileName,
3108 offset,
3109 length
3110 );
3111 }
3112
3113 void FileDownlinkComponentBase ::
3114 m_p_bufferReturn_in(
3115 Fw::PassiveComponentBase* callComp,
3116 NATIVE_INT_TYPE portNum,
3117 Fw::Buffer& fwBuffer
3118 )
3119 {
3120 FW_ASSERT(callComp);
3121 FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
3122 compPtr->bufferReturn_handlerBase(
3123 portNum,
3124 fwBuffer
3125 );
3126 }
3127
3128 void FileDownlinkComponentBase ::
3129 m_p_pingIn_in(
3130 Fw::PassiveComponentBase* callComp,
3131 NATIVE_INT_TYPE portNum,
3132 U32 key
3133 )
3134 {
3135 FW_ASSERT(callComp);
3136 FileDownlinkComponentBase* compPtr = static_cast<FileDownlinkComponentBase*>(callComp);
3137 compPtr->pingIn_handlerBase(
3138 portNum,
3139 key
3140 );
3141 }
3142
3143}
#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
U32 FwOpcodeType
Definition FpConfig.h:56
#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
Enum representing a command response.
@ FORMAT_ERROR
Command failed to deserialize.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition CmdPortAc.hpp:37
@ WARNING_HI
A serious but recoverable event.
@ ACTIVITY_HI
Important informational events.
@ WARNING_LO
A less serious but recoverable event.
const char * toChar() const override
Definition LogString.cpp:49
SerializeStatus serialize(SerializeBufferBase &buffer) const override
serialization function
Definition LogString.cpp:57
void init()
Object initializer.
Definition ObjBase.cpp:27
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
void resetDeser()
reset deserialization to beginning
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
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.
@ 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