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