F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
LinuxGpioDriverComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title LinuxGpioDriverComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for LinuxGpioDriver component base class
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
10 #if FW_ENABLE_TEXT_LOGGING
11 #include "Fw/Types/String.hpp"
12 #endif
13 
14 namespace Drv {
15 
16  // ----------------------------------------------------------------------
17  // Component initialization
18  // ----------------------------------------------------------------------
19 
21  init(FwEnumStoreType instance)
22  {
23  // Initialize base class
25 
26  // Connect input port gpioRead
27  for (
28  FwIndexType port = 0;
29  port < static_cast<FwIndexType>(this->getNum_gpioRead_InputPorts());
30  port++
31  ) {
32  this->m_gpioRead_InputPort[port].init();
33  this->m_gpioRead_InputPort[port].addCallComp(
34  this,
35  m_p_gpioRead_in
36  );
37  this->m_gpioRead_InputPort[port].setPortNum(port);
38 
39 #if FW_OBJECT_NAMES == 1
40  Fw::ObjectName portName;
41  portName.format(
42  "%s_gpioRead_InputPort[%" PRI_PlatformIntType "]",
43  this->m_objName.toChar(),
44  port
45  );
46  this->m_gpioRead_InputPort[port].setObjName(portName.toChar());
47 #endif
48  }
49 
50  // Connect input port gpioWrite
51  for (
52  FwIndexType port = 0;
53  port < static_cast<FwIndexType>(this->getNum_gpioWrite_InputPorts());
54  port++
55  ) {
56  this->m_gpioWrite_InputPort[port].init();
57  this->m_gpioWrite_InputPort[port].addCallComp(
58  this,
59  m_p_gpioWrite_in
60  );
61  this->m_gpioWrite_InputPort[port].setPortNum(port);
62 
63 #if FW_OBJECT_NAMES == 1
64  Fw::ObjectName portName;
65  portName.format(
66  "%s_gpioWrite_InputPort[%" PRI_PlatformIntType "]",
67  this->m_objName.toChar(),
68  port
69  );
70  this->m_gpioWrite_InputPort[port].setObjName(portName.toChar());
71 #endif
72  }
73 
74  // Connect output port Log
75  for (
76  FwIndexType port = 0;
77  port < static_cast<FwIndexType>(this->getNum_Log_OutputPorts());
78  port++
79  ) {
80  this->m_Log_OutputPort[port].init();
81 
82 #if FW_OBJECT_NAMES == 1
83  Fw::ObjectName portName;
84  portName.format(
85  "%s_Log_OutputPort[%" PRI_PlatformIntType "]",
86  this->m_objName.toChar(),
87  port
88  );
89  this->m_Log_OutputPort[port].setObjName(portName.toChar());
90 #endif
91  }
92 
93 #if FW_ENABLE_TEXT_LOGGING == 1
94  // Connect output port LogText
95  for (
96  FwIndexType port = 0;
97  port < static_cast<FwIndexType>(this->getNum_LogText_OutputPorts());
98  port++
99  ) {
100  this->m_LogText_OutputPort[port].init();
101 
102 #if FW_OBJECT_NAMES == 1
103  Fw::ObjectName portName;
104  portName.format(
105  "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
106  this->m_objName.toChar(),
107  port
108  );
109  this->m_LogText_OutputPort[port].setObjName(portName.toChar());
110 #endif
111  }
112 #endif
113 
114  // Connect output port Time
115  for (
116  FwIndexType port = 0;
117  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
118  port++
119  ) {
120  this->m_Time_OutputPort[port].init();
121 
122 #if FW_OBJECT_NAMES == 1
123  Fw::ObjectName portName;
124  portName.format(
125  "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
126  this->m_objName.toChar(),
127  port
128  );
129  this->m_Time_OutputPort[port].setObjName(portName.toChar());
130 #endif
131  }
132 
133  // Connect output port intOut
134  for (
135  FwIndexType port = 0;
136  port < static_cast<FwIndexType>(this->getNum_intOut_OutputPorts());
137  port++
138  ) {
139  this->m_intOut_OutputPort[port].init();
140 
141 #if FW_OBJECT_NAMES == 1
142  Fw::ObjectName portName;
143  portName.format(
144  "%s_intOut_OutputPort[%" PRI_PlatformIntType "]",
145  this->m_objName.toChar(),
146  port
147  );
148  this->m_intOut_OutputPort[port].setObjName(portName.toChar());
149 #endif
150  }
151  }
152 
153  // ----------------------------------------------------------------------
154  // Getters for typed input ports
155  // ----------------------------------------------------------------------
156 
159  {
160  FW_ASSERT(
161  portNum < this->getNum_gpioRead_InputPorts(),
162  static_cast<FwAssertArgType>(portNum)
163  );
164 
165  return &this->m_gpioRead_InputPort[portNum];
166  }
167 
170  {
171  FW_ASSERT(
172  portNum < this->getNum_gpioWrite_InputPorts(),
173  static_cast<FwAssertArgType>(portNum)
174  );
175 
176  return &this->m_gpioWrite_InputPort[portNum];
177  }
178 
179  // ----------------------------------------------------------------------
180  // Connect input ports to special output ports
181  // ----------------------------------------------------------------------
182 
185  FwIndexType portNum,
186  Fw::InputLogPort* port
187  )
188  {
189  FW_ASSERT(
190  portNum < this->getNum_Log_OutputPorts(),
191  static_cast<FwAssertArgType>(portNum)
192  );
193 
194  this->m_Log_OutputPort[portNum].addCallPort(port);
195  }
196 
197 #if FW_ENABLE_TEXT_LOGGING == 1
198 
199  void LinuxGpioDriverComponentBase ::
200  set_LogText_OutputPort(
201  FwIndexType portNum,
203  )
204  {
205  FW_ASSERT(
206  portNum < this->getNum_LogText_OutputPorts(),
207  static_cast<FwAssertArgType>(portNum)
208  );
209 
210  this->m_LogText_OutputPort[portNum].addCallPort(port);
211  }
212 
213 #endif
214 
217  FwIndexType portNum,
218  Fw::InputTimePort* port
219  )
220  {
221  FW_ASSERT(
222  portNum < this->getNum_Time_OutputPorts(),
223  static_cast<FwAssertArgType>(portNum)
224  );
225 
226  this->m_Time_OutputPort[portNum].addCallPort(port);
227  }
228 
229  // ----------------------------------------------------------------------
230  // Connect typed input ports to typed output ports
231  // ----------------------------------------------------------------------
232 
235  FwIndexType portNum,
236  Svc::InputCyclePort* port
237  )
238  {
239  FW_ASSERT(
240  portNum < this->getNum_intOut_OutputPorts(),
241  static_cast<FwAssertArgType>(portNum)
242  );
243 
244  this->m_intOut_OutputPort[portNum].addCallPort(port);
245  }
246 
247 #if FW_PORT_SERIALIZATION
248 
249  // ----------------------------------------------------------------------
250  // Connect serial input ports to special output ports
251  // ----------------------------------------------------------------------
252 
255  FwIndexType portNum,
256  Fw::InputSerializePort* port
257  )
258  {
259  FW_ASSERT(
260  portNum < this->getNum_Log_OutputPorts(),
261  static_cast<FwAssertArgType>(portNum)
262  );
263 
264  this->m_Log_OutputPort[portNum].registerSerialPort(port);
265  }
266 
267 #if FW_ENABLE_TEXT_LOGGING == 1
268 
269  void LinuxGpioDriverComponentBase ::
270  set_LogText_OutputPort(
271  FwIndexType portNum,
272  Fw::InputSerializePort* port
273  )
274  {
275  FW_ASSERT(
276  portNum < this->getNum_LogText_OutputPorts(),
277  static_cast<FwAssertArgType>(portNum)
278  );
279 
280  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
281  }
282 
283 #endif
284 
287  FwIndexType portNum,
288  Fw::InputSerializePort* port
289  )
290  {
291  FW_ASSERT(
292  portNum < this->getNum_Time_OutputPorts(),
293  static_cast<FwAssertArgType>(portNum)
294  );
295 
296  this->m_Time_OutputPort[portNum].registerSerialPort(port);
297  }
298 
299 #endif
300 
301 #if FW_PORT_SERIALIZATION
302 
303  // ----------------------------------------------------------------------
304  // Connect serial input ports to typed output ports
305  // ----------------------------------------------------------------------
306 
309  FwIndexType portNum,
310  Fw::InputSerializePort* port
311  )
312  {
313  FW_ASSERT(
314  portNum < this->getNum_intOut_OutputPorts(),
315  static_cast<FwAssertArgType>(portNum)
316  );
317 
318  this->m_intOut_OutputPort[portNum].registerSerialPort(port);
319  }
320 
321 #endif
322 
323  // ----------------------------------------------------------------------
324  // Component construction and destruction
325  // ----------------------------------------------------------------------
326 
328  LinuxGpioDriverComponentBase(const char* compName) :
329  Fw::PassiveComponentBase(compName)
330  {
331  this->m_GP_WriteErrorThrottle = 0;
332  this->m_GP_ReadErrorThrottle = 0;
333  }
334 
337  {
338 
339  }
340 
341  // ----------------------------------------------------------------------
342  // Getters for numbers of typed input ports
343  // ----------------------------------------------------------------------
344 
347  {
348  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_gpioRead_InputPort));
349  }
350 
353  {
354  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_gpioWrite_InputPort));
355  }
356 
357  // ----------------------------------------------------------------------
358  // Getters for numbers of special output ports
359  // ----------------------------------------------------------------------
360 
363  {
364  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Log_OutputPort));
365  }
366 
367 #if FW_ENABLE_TEXT_LOGGING == 1
368 
369  FwIndexType LinuxGpioDriverComponentBase ::
370  getNum_LogText_OutputPorts() const
371  {
372  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
373  }
374 
375 #endif
376 
379  {
380  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
381  }
382 
383  // ----------------------------------------------------------------------
384  // Getters for numbers of typed output ports
385  // ----------------------------------------------------------------------
386 
389  {
390  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_intOut_OutputPort));
391  }
392 
393  // ----------------------------------------------------------------------
394  // Connection status queries for special output ports
395  // ----------------------------------------------------------------------
396 
399  {
400  FW_ASSERT(
401  portNum < this->getNum_Log_OutputPorts(),
402  static_cast<FwAssertArgType>(portNum)
403  );
404 
405  return this->m_Log_OutputPort[portNum].isConnected();
406  }
407 
408 #if FW_ENABLE_TEXT_LOGGING == 1
409 
410  bool LinuxGpioDriverComponentBase ::
411  isConnected_LogText_OutputPort(FwIndexType portNum)
412  {
413  FW_ASSERT(
414  portNum < this->getNum_LogText_OutputPorts(),
415  static_cast<FwAssertArgType>(portNum)
416  );
417 
418  return this->m_LogText_OutputPort[portNum].isConnected();
419  }
420 
421 #endif
422 
425  {
426  FW_ASSERT(
427  portNum < this->getNum_Time_OutputPorts(),
428  static_cast<FwAssertArgType>(portNum)
429  );
430 
431  return this->m_Time_OutputPort[portNum].isConnected();
432  }
433 
434  // ----------------------------------------------------------------------
435  // Connection status queries for typed output ports
436  // ----------------------------------------------------------------------
437 
440  {
441  FW_ASSERT(
442  portNum < this->getNum_intOut_OutputPorts(),
443  static_cast<FwAssertArgType>(portNum)
444  );
445 
446  return this->m_intOut_OutputPort[portNum].isConnected();
447  }
448 
449  // ----------------------------------------------------------------------
450  // Port handler base-class functions for typed input ports
451  //
452  // Call these functions directly to bypass the corresponding ports
453  // ----------------------------------------------------------------------
454 
457  FwIndexType portNum,
458  Fw::Logic& state
459  )
460  {
461  // Make sure port number is valid
462  FW_ASSERT(
463  portNum < this->getNum_gpioRead_InputPorts(),
464  static_cast<FwAssertArgType>(portNum)
465  );
466 
467  // Call handler function
468  this->gpioRead_handler(
469  portNum,
470  state
471  );
472  }
473 
476  FwIndexType portNum,
477  const Fw::Logic& state
478  )
479  {
480  // Make sure port number is valid
481  FW_ASSERT(
482  portNum < this->getNum_gpioWrite_InputPorts(),
483  static_cast<FwAssertArgType>(portNum)
484  );
485 
486  // Call handler function
487  this->gpioWrite_handler(
488  portNum,
489  state
490  );
491  }
492 
493  // ----------------------------------------------------------------------
494  // Invocation functions for typed output ports
495  // ----------------------------------------------------------------------
496 
499  FwIndexType portNum,
500  Svc::TimerVal& cycleStart
501  )
502  {
503  FW_ASSERT(
504  portNum < this->getNum_intOut_OutputPorts(),
505  static_cast<FwAssertArgType>(portNum)
506  );
507  this->m_intOut_OutputPort[portNum].invoke(
508  cycleStart
509  );
510  }
511 
512  // ----------------------------------------------------------------------
513  // Event logging functions
514  // ----------------------------------------------------------------------
515 
518  I32 gpio,
519  I32 error,
520  const Fw::StringBase& msg
521  )
522  {
523  // Get the time
524  Fw::Time _logTime;
525  if (this->m_Time_OutputPort[0].isConnected()) {
526  this->m_Time_OutputPort[0].invoke(_logTime);
527  }
528 
529  FwEventIdType _id = static_cast<FwEventIdType>(0);
530 
531  _id = this->getIdBase() + EVENTID_GP_OPENERROR;
532 
533  // Emit the event on the log port
534  if (this->m_Log_OutputPort[0].isConnected()) {
535  Fw::LogBuffer _logBuff;
537 
538 #if FW_AMPCS_COMPATIBLE
539  // Serialize the number of arguments
540  _status = _logBuff.serialize(static_cast<U8>(3));
541  FW_ASSERT(
542  _status == Fw::FW_SERIALIZE_OK,
543  static_cast<FwAssertArgType>(_status)
544  );
545 #endif
546 
547 #if FW_AMPCS_COMPATIBLE
548  // Serialize the argument size
549  _status = _logBuff.serialize(
550  static_cast<U8>(sizeof(I32))
551  );
552  FW_ASSERT(
553  _status == Fw::FW_SERIALIZE_OK,
554  static_cast<FwAssertArgType>(_status)
555  );
556 #endif
557  _status = _logBuff.serialize(gpio);
558  FW_ASSERT(
559  _status == Fw::FW_SERIALIZE_OK,
560  static_cast<FwAssertArgType>(_status)
561  );
562 
563 #if FW_AMPCS_COMPATIBLE
564  // Serialize the argument size
565  _status = _logBuff.serialize(
566  static_cast<U8>(sizeof(I32))
567  );
568  FW_ASSERT(
569  _status == Fw::FW_SERIALIZE_OK,
570  static_cast<FwAssertArgType>(_status)
571  );
572 #endif
573  _status = _logBuff.serialize(error);
574  FW_ASSERT(
575  _status == Fw::FW_SERIALIZE_OK,
576  static_cast<FwAssertArgType>(_status)
577  );
578 
579  _status = msg.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 40));
580  FW_ASSERT(
581  _status == Fw::FW_SERIALIZE_OK,
582  static_cast<FwAssertArgType>(_status)
583  );
584 
585  this->m_Log_OutputPort[0].invoke(
586  _id,
587  _logTime,
589  _logBuff
590  );
591  }
592 
593  // Emit the event on the text log port
594 #if FW_ENABLE_TEXT_LOGGING
595  if (this->m_LogText_OutputPort[0].isConnected()) {
596 #if FW_OBJECT_NAMES == 1
597  const char* _formatString =
598  "(%s) %s: Error opening GPIO device %" PRIi32 ": %" PRIi32 " (%s)";
599 #else
600  const char* _formatString =
601  "%s: Error opening GPIO device %" PRIi32 ": %" PRIi32 " (%s)";
602 #endif
603 
604  Fw::TextLogString _logString;
605  _logString.format(
606  _formatString,
607 #if FW_OBJECT_NAMES == 1
608  this->m_objName.toChar(),
609 #endif
610  "GP_OpenError ",
611  gpio,
612  error,
613  msg.toChar()
614  );
615 
616  this->m_LogText_OutputPort[0].invoke(
617  _id,
618  _logTime,
620  _logString
621  );
622  }
623 #endif
624  }
625 
628  I32 gpio,
629  I32 error
630  )
631  {
632  // Get the time
633  Fw::Time _logTime;
634  if (this->m_Time_OutputPort[0].isConnected()) {
635  this->m_Time_OutputPort[0].invoke(_logTime);
636  }
637 
638  FwEventIdType _id = static_cast<FwEventIdType>(0);
639 
640  _id = this->getIdBase() + EVENTID_GP_CONFIGERROR;
641 
642  // Emit the event on the log port
643  if (this->m_Log_OutputPort[0].isConnected()) {
644  Fw::LogBuffer _logBuff;
646 
647 #if FW_AMPCS_COMPATIBLE
648  // Serialize the number of arguments
649  _status = _logBuff.serialize(static_cast<U8>(2));
650  FW_ASSERT(
651  _status == Fw::FW_SERIALIZE_OK,
652  static_cast<FwAssertArgType>(_status)
653  );
654 #endif
655 
656 #if FW_AMPCS_COMPATIBLE
657  // Serialize the argument size
658  _status = _logBuff.serialize(
659  static_cast<U8>(sizeof(I32))
660  );
661  FW_ASSERT(
662  _status == Fw::FW_SERIALIZE_OK,
663  static_cast<FwAssertArgType>(_status)
664  );
665 #endif
666  _status = _logBuff.serialize(gpio);
667  FW_ASSERT(
668  _status == Fw::FW_SERIALIZE_OK,
669  static_cast<FwAssertArgType>(_status)
670  );
671 
672 #if FW_AMPCS_COMPATIBLE
673  // Serialize the argument size
674  _status = _logBuff.serialize(
675  static_cast<U8>(sizeof(I32))
676  );
677  FW_ASSERT(
678  _status == Fw::FW_SERIALIZE_OK,
679  static_cast<FwAssertArgType>(_status)
680  );
681 #endif
682  _status = _logBuff.serialize(error);
683  FW_ASSERT(
684  _status == Fw::FW_SERIALIZE_OK,
685  static_cast<FwAssertArgType>(_status)
686  );
687 
688  this->m_Log_OutputPort[0].invoke(
689  _id,
690  _logTime,
692  _logBuff
693  );
694  }
695 
696  // Emit the event on the text log port
697 #if FW_ENABLE_TEXT_LOGGING
698  if (this->m_LogText_OutputPort[0].isConnected()) {
699 #if FW_OBJECT_NAMES == 1
700  const char* _formatString =
701  "(%s) %s: Error configuring GPIO device %" PRIi32 ": %" PRIi32 "";
702 #else
703  const char* _formatString =
704  "%s: Error configuring GPIO device %" PRIi32 ": %" PRIi32 "";
705 #endif
706 
707  Fw::TextLogString _logString;
708  _logString.format(
709  _formatString,
710 #if FW_OBJECT_NAMES == 1
711  this->m_objName.toChar(),
712 #endif
713  "GP_ConfigError ",
714  gpio,
715  error
716  );
717 
718  this->m_LogText_OutputPort[0].invoke(
719  _id,
720  _logTime,
722  _logString
723  );
724  }
725 #endif
726  }
727 
730  I32 gpio,
731  I32 error
732  )
733  {
734  // Check throttle value
735  if (this->m_GP_WriteErrorThrottle >= EVENTID_GP_WRITEERROR_THROTTLE) {
736  return;
737  }
738  else {
739  this->m_GP_WriteErrorThrottle++;
740  }
741 
742  // Get the time
743  Fw::Time _logTime;
744  if (this->m_Time_OutputPort[0].isConnected()) {
745  this->m_Time_OutputPort[0].invoke(_logTime);
746  }
747 
748  FwEventIdType _id = static_cast<FwEventIdType>(0);
749 
750  _id = this->getIdBase() + EVENTID_GP_WRITEERROR;
751 
752  // Emit the event on the log port
753  if (this->m_Log_OutputPort[0].isConnected()) {
754  Fw::LogBuffer _logBuff;
756 
757 #if FW_AMPCS_COMPATIBLE
758  // Serialize the number of arguments
759  _status = _logBuff.serialize(static_cast<U8>(2));
760  FW_ASSERT(
761  _status == Fw::FW_SERIALIZE_OK,
762  static_cast<FwAssertArgType>(_status)
763  );
764 #endif
765 
766 #if FW_AMPCS_COMPATIBLE
767  // Serialize the argument size
768  _status = _logBuff.serialize(
769  static_cast<U8>(sizeof(I32))
770  );
771  FW_ASSERT(
772  _status == Fw::FW_SERIALIZE_OK,
773  static_cast<FwAssertArgType>(_status)
774  );
775 #endif
776  _status = _logBuff.serialize(gpio);
777  FW_ASSERT(
778  _status == Fw::FW_SERIALIZE_OK,
779  static_cast<FwAssertArgType>(_status)
780  );
781 
782 #if FW_AMPCS_COMPATIBLE
783  // Serialize the argument size
784  _status = _logBuff.serialize(
785  static_cast<U8>(sizeof(I32))
786  );
787  FW_ASSERT(
788  _status == Fw::FW_SERIALIZE_OK,
789  static_cast<FwAssertArgType>(_status)
790  );
791 #endif
792  _status = _logBuff.serialize(error);
793  FW_ASSERT(
794  _status == Fw::FW_SERIALIZE_OK,
795  static_cast<FwAssertArgType>(_status)
796  );
797 
798  this->m_Log_OutputPort[0].invoke(
799  _id,
800  _logTime,
802  _logBuff
803  );
804  }
805 
806  // Emit the event on the text log port
807 #if FW_ENABLE_TEXT_LOGGING
808  if (this->m_LogText_OutputPort[0].isConnected()) {
809 #if FW_OBJECT_NAMES == 1
810  const char* _formatString =
811  "(%s) %s: Error writing GPIO device %" PRIi32 ": %" PRIi32 "";
812 #else
813  const char* _formatString =
814  "%s: Error writing GPIO device %" PRIi32 ": %" PRIi32 "";
815 #endif
816 
817  Fw::TextLogString _logString;
818  _logString.format(
819  _formatString,
820 #if FW_OBJECT_NAMES == 1
821  this->m_objName.toChar(),
822 #endif
823  "GP_WriteError ",
824  gpio,
825  error
826  );
827 
828  this->m_LogText_OutputPort[0].invoke(
829  _id,
830  _logTime,
832  _logString
833  );
834  }
835 #endif
836  }
837 
840  I32 gpio,
841  I32 error
842  )
843  {
844  // Check throttle value
845  if (this->m_GP_ReadErrorThrottle >= EVENTID_GP_READERROR_THROTTLE) {
846  return;
847  }
848  else {
849  this->m_GP_ReadErrorThrottle++;
850  }
851 
852  // Get the time
853  Fw::Time _logTime;
854  if (this->m_Time_OutputPort[0].isConnected()) {
855  this->m_Time_OutputPort[0].invoke(_logTime);
856  }
857 
858  FwEventIdType _id = static_cast<FwEventIdType>(0);
859 
860  _id = this->getIdBase() + EVENTID_GP_READERROR;
861 
862  // Emit the event on the log port
863  if (this->m_Log_OutputPort[0].isConnected()) {
864  Fw::LogBuffer _logBuff;
866 
867 #if FW_AMPCS_COMPATIBLE
868  // Serialize the number of arguments
869  _status = _logBuff.serialize(static_cast<U8>(2));
870  FW_ASSERT(
871  _status == Fw::FW_SERIALIZE_OK,
872  static_cast<FwAssertArgType>(_status)
873  );
874 #endif
875 
876 #if FW_AMPCS_COMPATIBLE
877  // Serialize the argument size
878  _status = _logBuff.serialize(
879  static_cast<U8>(sizeof(I32))
880  );
881  FW_ASSERT(
882  _status == Fw::FW_SERIALIZE_OK,
883  static_cast<FwAssertArgType>(_status)
884  );
885 #endif
886  _status = _logBuff.serialize(gpio);
887  FW_ASSERT(
888  _status == Fw::FW_SERIALIZE_OK,
889  static_cast<FwAssertArgType>(_status)
890  );
891 
892 #if FW_AMPCS_COMPATIBLE
893  // Serialize the argument size
894  _status = _logBuff.serialize(
895  static_cast<U8>(sizeof(I32))
896  );
897  FW_ASSERT(
898  _status == Fw::FW_SERIALIZE_OK,
899  static_cast<FwAssertArgType>(_status)
900  );
901 #endif
902  _status = _logBuff.serialize(error);
903  FW_ASSERT(
904  _status == Fw::FW_SERIALIZE_OK,
905  static_cast<FwAssertArgType>(_status)
906  );
907 
908  this->m_Log_OutputPort[0].invoke(
909  _id,
910  _logTime,
912  _logBuff
913  );
914  }
915 
916  // Emit the event on the text log port
917 #if FW_ENABLE_TEXT_LOGGING
918  if (this->m_LogText_OutputPort[0].isConnected()) {
919 #if FW_OBJECT_NAMES == 1
920  const char* _formatString =
921  "(%s) %s: Error reading GPIO device %" PRIi32 ": %" PRIi32 "";
922 #else
923  const char* _formatString =
924  "%s: Error reading GPIO device %" PRIi32 ": %" PRIi32 "";
925 #endif
926 
927  Fw::TextLogString _logString;
928  _logString.format(
929  _formatString,
930 #if FW_OBJECT_NAMES == 1
931  this->m_objName.toChar(),
932 #endif
933  "GP_ReadError ",
934  gpio,
935  error
936  );
937 
938  this->m_LogText_OutputPort[0].invoke(
939  _id,
940  _logTime,
942  _logString
943  );
944  }
945 #endif
946  }
947 
950  {
951  // Get the time
952  Fw::Time _logTime;
953  if (this->m_Time_OutputPort[0].isConnected()) {
954  this->m_Time_OutputPort[0].invoke(_logTime);
955  }
956 
957  FwEventIdType _id = static_cast<FwEventIdType>(0);
958 
959  _id = this->getIdBase() + EVENTID_GP_PORTOPENED;
960 
961  // Emit the event on the log port
962  if (this->m_Log_OutputPort[0].isConnected()) {
963  Fw::LogBuffer _logBuff;
965 
966 #if FW_AMPCS_COMPATIBLE
967  // Serialize the number of arguments
968  _status = _logBuff.serialize(static_cast<U8>(1));
969  FW_ASSERT(
970  _status == Fw::FW_SERIALIZE_OK,
971  static_cast<FwAssertArgType>(_status)
972  );
973 #endif
974 
975 #if FW_AMPCS_COMPATIBLE
976  // Serialize the argument size
977  _status = _logBuff.serialize(
978  static_cast<U8>(sizeof(I32))
979  );
980  FW_ASSERT(
981  _status == Fw::FW_SERIALIZE_OK,
982  static_cast<FwAssertArgType>(_status)
983  );
984 #endif
985  _status = _logBuff.serialize(gpio);
986  FW_ASSERT(
987  _status == Fw::FW_SERIALIZE_OK,
988  static_cast<FwAssertArgType>(_status)
989  );
990 
991  this->m_Log_OutputPort[0].invoke(
992  _id,
993  _logTime,
995  _logBuff
996  );
997  }
998 
999  // Emit the event on the text log port
1000 #if FW_ENABLE_TEXT_LOGGING
1001  if (this->m_LogText_OutputPort[0].isConnected()) {
1002 #if FW_OBJECT_NAMES == 1
1003  const char* _formatString =
1004  "(%s) %s: GPIO Device %" PRIi32 " configured";
1005 #else
1006  const char* _formatString =
1007  "%s: GPIO Device %" PRIi32 " configured";
1008 #endif
1009 
1010  Fw::TextLogString _logString;
1011  _logString.format(
1012  _formatString,
1013 #if FW_OBJECT_NAMES == 1
1014  this->m_objName.toChar(),
1015 #endif
1016  "GP_PortOpened ",
1017  gpio
1018  );
1019 
1020  this->m_LogText_OutputPort[0].invoke(
1021  _id,
1022  _logTime,
1024  _logString
1025  );
1026  }
1027 #endif
1028  }
1029 
1032  {
1033  // Get the time
1034  Fw::Time _logTime;
1035  if (this->m_Time_OutputPort[0].isConnected()) {
1036  this->m_Time_OutputPort[0].invoke(_logTime);
1037  }
1038 
1039  FwEventIdType _id = static_cast<FwEventIdType>(0);
1040 
1041  _id = this->getIdBase() + EVENTID_GP_INTSTARTERROR;
1042 
1043  // Emit the event on the log port
1044  if (this->m_Log_OutputPort[0].isConnected()) {
1045  Fw::LogBuffer _logBuff;
1047 
1048 #if FW_AMPCS_COMPATIBLE
1049  // Serialize the number of arguments
1050  _status = _logBuff.serialize(static_cast<U8>(1));
1051  FW_ASSERT(
1052  _status == Fw::FW_SERIALIZE_OK,
1053  static_cast<FwAssertArgType>(_status)
1054  );
1055 #endif
1056 
1057 #if FW_AMPCS_COMPATIBLE
1058  // Serialize the argument size
1059  _status = _logBuff.serialize(
1060  static_cast<U8>(sizeof(I32))
1061  );
1062  FW_ASSERT(
1063  _status == Fw::FW_SERIALIZE_OK,
1064  static_cast<FwAssertArgType>(_status)
1065  );
1066 #endif
1067  _status = _logBuff.serialize(gpio);
1068  FW_ASSERT(
1069  _status == Fw::FW_SERIALIZE_OK,
1070  static_cast<FwAssertArgType>(_status)
1071  );
1072 
1073  this->m_Log_OutputPort[0].invoke(
1074  _id,
1075  _logTime,
1077  _logBuff
1078  );
1079  }
1080 
1081  // Emit the event on the text log port
1082 #if FW_ENABLE_TEXT_LOGGING
1083  if (this->m_LogText_OutputPort[0].isConnected()) {
1084 #if FW_OBJECT_NAMES == 1
1085  const char* _formatString =
1086  "(%s) %s: GPIO Device %" PRIi32 " interrupt start error";
1087 #else
1088  const char* _formatString =
1089  "%s: GPIO Device %" PRIi32 " interrupt start error";
1090 #endif
1091 
1092  Fw::TextLogString _logString;
1093  _logString.format(
1094  _formatString,
1095 #if FW_OBJECT_NAMES == 1
1096  this->m_objName.toChar(),
1097 #endif
1098  "GP_IntStartError ",
1099  gpio
1100  );
1101 
1102  this->m_LogText_OutputPort[0].invoke(
1103  _id,
1104  _logTime,
1106  _logString
1107  );
1108  }
1109 #endif
1110  }
1111 
1114  {
1115  // Get the time
1116  Fw::Time _logTime;
1117  if (this->m_Time_OutputPort[0].isConnected()) {
1118  this->m_Time_OutputPort[0].invoke(_logTime);
1119  }
1120 
1121  FwEventIdType _id = static_cast<FwEventIdType>(0);
1122 
1123  _id = this->getIdBase() + EVENTID_GP_INTWAITERROR;
1124 
1125  // Emit the event on the log port
1126  if (this->m_Log_OutputPort[0].isConnected()) {
1127  Fw::LogBuffer _logBuff;
1129 
1130 #if FW_AMPCS_COMPATIBLE
1131  // Serialize the number of arguments
1132  _status = _logBuff.serialize(static_cast<U8>(1));
1133  FW_ASSERT(
1134  _status == Fw::FW_SERIALIZE_OK,
1135  static_cast<FwAssertArgType>(_status)
1136  );
1137 #endif
1138 
1139 #if FW_AMPCS_COMPATIBLE
1140  // Serialize the argument size
1141  _status = _logBuff.serialize(
1142  static_cast<U8>(sizeof(I32))
1143  );
1144  FW_ASSERT(
1145  _status == Fw::FW_SERIALIZE_OK,
1146  static_cast<FwAssertArgType>(_status)
1147  );
1148 #endif
1149  _status = _logBuff.serialize(gpio);
1150  FW_ASSERT(
1151  _status == Fw::FW_SERIALIZE_OK,
1152  static_cast<FwAssertArgType>(_status)
1153  );
1154 
1155  this->m_Log_OutputPort[0].invoke(
1156  _id,
1157  _logTime,
1159  _logBuff
1160  );
1161  }
1162 
1163  // Emit the event on the text log port
1164 #if FW_ENABLE_TEXT_LOGGING
1165  if (this->m_LogText_OutputPort[0].isConnected()) {
1166 #if FW_OBJECT_NAMES == 1
1167  const char* _formatString =
1168  "(%s) %s: GPIO Device %" PRIi32 " interrupt wait error";
1169 #else
1170  const char* _formatString =
1171  "%s: GPIO Device %" PRIi32 " interrupt wait error";
1172 #endif
1173 
1174  Fw::TextLogString _logString;
1175  _logString.format(
1176  _formatString,
1177 #if FW_OBJECT_NAMES == 1
1178  this->m_objName.toChar(),
1179 #endif
1180  "GP_IntWaitError ",
1181  gpio
1182  );
1183 
1184  this->m_LogText_OutputPort[0].invoke(
1185  _id,
1186  _logTime,
1188  _logString
1189  );
1190  }
1191 #endif
1192  }
1193 
1194  // ----------------------------------------------------------------------
1195  // Event throttle reset functions
1196  // ----------------------------------------------------------------------
1197 
1200  {
1201  // Reset throttle counter
1202  this->m_GP_WriteErrorThrottle = 0;
1203  }
1204 
1207  {
1208  // Reset throttle counter
1209  this->m_GP_ReadErrorThrottle = 0;
1210  }
1211 
1212  // ----------------------------------------------------------------------
1213  // Time
1214  // ----------------------------------------------------------------------
1215 
1217  getTime()
1218  {
1219  if (this->m_Time_OutputPort[0].isConnected()) {
1220  Fw::Time _time;
1221  this->m_Time_OutputPort[0].invoke(_time);
1222  return _time;
1223  }
1224  else {
1225  return Fw::Time(TB_NONE, 0, 0);
1226  }
1227  }
1228 
1229  // ----------------------------------------------------------------------
1230  // Calls for messages received on typed input ports
1231  // ----------------------------------------------------------------------
1232 
1233  void LinuxGpioDriverComponentBase ::
1234  m_p_gpioRead_in(
1235  Fw::PassiveComponentBase* callComp,
1236  FwIndexType portNum,
1237  Fw::Logic& state
1238  )
1239  {
1240  FW_ASSERT(callComp);
1241  LinuxGpioDriverComponentBase* compPtr = static_cast<LinuxGpioDriverComponentBase*>(callComp);
1242  compPtr->gpioRead_handlerBase(
1243  portNum,
1244  state
1245  );
1246  }
1247 
1248  void LinuxGpioDriverComponentBase ::
1249  m_p_gpioWrite_in(
1250  Fw::PassiveComponentBase* callComp,
1251  FwIndexType portNum,
1252  const Fw::Logic& state
1253  )
1254  {
1255  FW_ASSERT(callComp);
1256  LinuxGpioDriverComponentBase* compPtr = static_cast<LinuxGpioDriverComponentBase*>(callComp);
1257  compPtr->gpioWrite_handlerBase(
1258  portNum,
1259  state
1260  );
1261  }
1262 
1263 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
#define FW_MIN(a, b)
MIN macro.
Definition: BasicTypes.h:68
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
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition: FpConfig.h:57
I32 FwEnumStoreType
Definition: FpConfig.h:51
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:34
U32 FwEventIdType
Definition: FpConfig.h:86
#define FW_LOG_STRING_MAX_SIZE
Max size of log string parameter type.
Definition: FpConfig.h:300
PlatformIndexType FwIndexType
Definition: FpConfig.h:20
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects)
Definition: FpConfig.h:135
Input GpioRead port.
void init()
Initialization function.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Input GpioWrite port.
void init()
Initialization function.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Auto-generated base for LinuxGpioDriver component.
virtual void gpioRead_handler(FwIndexType portNum, Fw::Logic &state)=0
Handler for input port gpioRead.
void gpioWrite_handlerBase(FwIndexType portNum, const Fw::Logic &state)
Handler base-class function for input port gpioWrite.
Drv::InputGpioWritePort * get_gpioWrite_InputPort(FwIndexType portNum)
@ EVENTID_GP_INTSTARTERROR
GPIO interrupt start error notification.
@ EVENTID_GP_INTWAITERROR
GPIO interrupt wait error notification.
@ EVENTID_GP_PORTOPENED
GPIO opened notification.
void intOut_out(FwIndexType portNum, Svc::TimerVal &cycleStart)
Invoke output port intOut.
void set_intOut_OutputPort(FwIndexType portNum, Svc::InputCyclePort *port)
Connect port to intOut[portNum].
virtual ~LinuxGpioDriverComponentBase()
Destroy LinuxGpioDriverComponentBase object.
virtual void gpioWrite_handler(FwIndexType portNum, const Fw::Logic &state)=0
Handler for input port gpioWrite.
@ EVENTID_GP_READERROR_THROTTLE
Throttle reset count for GP_ReadError.
@ EVENTID_GP_WRITEERROR_THROTTLE
Throttle reset count for GP_WriteError.
bool isConnected_intOut_OutputPort(FwIndexType portNum)
void log_WARNING_HI_GP_ReadError(I32 gpio, I32 error)
void log_WARNING_HI_GP_ReadError_ThrottleClear()
Reset throttle value for GP_ReadError.
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
Drv::InputGpioReadPort * get_gpioRead_InputPort(FwIndexType portNum)
void log_WARNING_HI_GP_OpenError(I32 gpio, I32 error, const Fw::StringBase &msg)
void log_WARNING_HI_GP_WriteError(I32 gpio, I32 error)
void gpioRead_handlerBase(FwIndexType portNum, Fw::Logic &state)
Handler base-class function for input port gpioRead.
void log_WARNING_HI_GP_WriteError_ThrottleClear()
Reset throttle value for GP_WriteError.
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
void log_WARNING_HI_GP_ConfigError(I32 gpio, I32 error)
bool isConnected_Time_OutputPort(FwIndexType portNum)
bool isConnected_Log_OutputPort(FwIndexType portNum)
LinuxGpioDriverComponentBase(const char *compName="")
Construct LinuxGpioDriverComponentBase object.
void setPortNum(NATIVE_INT_TYPE portNum)
@ WARNING_HI
A serious but recoverable event.
@ ACTIVITY_HI
Important informational events.
Logic states.
Definition: LogicEnumAc.hpp:19
void init()
Object initializer.
Definition: ObjBase.cpp:27
const char * toChar() const
Definition: ObjectName.hpp:50
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args)
Invoke a port interface.
Definition: LogPortAc.cpp:170
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
void invoke(Fw::Time &time)
Invoke a port interface.
Definition: TimePortAc.cpp:147
void init()
Initialization function.
Definition: TimePortAc.cpp:128
bool isConnected()
Definition: PortBase.cpp:41
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
virtual const CHAR * toChar() const =0
void format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:56
virtual SerializeStatus serialize(SerializeBufferBase &buffer) const
serialization function
Definition: StringBase.cpp:137
Definition: Time.hpp:9
void init()
Initialization function.
void addCallPort(InputCyclePort *callPort)
Register an input port.
void invoke(Svc::TimerVal &cycleStart)
Invoke a port interface.
Serializable class for carrying timer values.
Definition: TimerVal.hpp:22
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.