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 gpioInterrupt
134  for (
135  FwIndexType port = 0;
136  port < static_cast<FwIndexType>(this->getNum_gpioInterrupt_OutputPorts());
137  port++
138  ) {
139  this->m_gpioInterrupt_OutputPort[port].init();
140 
141 #if FW_OBJECT_NAMES == 1
142  Fw::ObjectName portName;
143  portName.format(
144  "%s_gpioInterrupt_OutputPort[%" PRI_PlatformIntType "]",
145  this->m_objName.toChar(),
146  port
147  );
148  this->m_gpioInterrupt_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_gpioInterrupt_OutputPorts(),
241  static_cast<FwAssertArgType>(portNum)
242  );
243 
244  this->m_gpioInterrupt_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_gpioInterrupt_OutputPorts(),
315  static_cast<FwAssertArgType>(portNum)
316  );
317 
318  this->m_gpioInterrupt_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 
332  }
333 
336  {
337 
338  }
339 
340  // ----------------------------------------------------------------------
341  // Getters for numbers of typed input ports
342  // ----------------------------------------------------------------------
343 
346  {
347  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_gpioRead_InputPort));
348  }
349 
352  {
353  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_gpioWrite_InputPort));
354  }
355 
356  // ----------------------------------------------------------------------
357  // Getters for numbers of special output ports
358  // ----------------------------------------------------------------------
359 
362  {
363  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Log_OutputPort));
364  }
365 
366 #if FW_ENABLE_TEXT_LOGGING == 1
367 
368  FwIndexType LinuxGpioDriverComponentBase ::
369  getNum_LogText_OutputPorts() const
370  {
371  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
372  }
373 
374 #endif
375 
378  {
379  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
380  }
381 
382  // ----------------------------------------------------------------------
383  // Getters for numbers of typed output ports
384  // ----------------------------------------------------------------------
385 
388  {
389  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_gpioInterrupt_OutputPort));
390  }
391 
392  // ----------------------------------------------------------------------
393  // Connection status queries for special output ports
394  // ----------------------------------------------------------------------
395 
398  {
399  FW_ASSERT(
400  portNum < this->getNum_Log_OutputPorts(),
401  static_cast<FwAssertArgType>(portNum)
402  );
403 
404  return this->m_Log_OutputPort[portNum].isConnected();
405  }
406 
407 #if FW_ENABLE_TEXT_LOGGING == 1
408 
409  bool LinuxGpioDriverComponentBase ::
410  isConnected_LogText_OutputPort(FwIndexType portNum)
411  {
412  FW_ASSERT(
413  portNum < this->getNum_LogText_OutputPorts(),
414  static_cast<FwAssertArgType>(portNum)
415  );
416 
417  return this->m_LogText_OutputPort[portNum].isConnected();
418  }
419 
420 #endif
421 
424  {
425  FW_ASSERT(
426  portNum < this->getNum_Time_OutputPorts(),
427  static_cast<FwAssertArgType>(portNum)
428  );
429 
430  return this->m_Time_OutputPort[portNum].isConnected();
431  }
432 
433  // ----------------------------------------------------------------------
434  // Connection status queries for typed output ports
435  // ----------------------------------------------------------------------
436 
439  {
440  FW_ASSERT(
441  portNum < this->getNum_gpioInterrupt_OutputPorts(),
442  static_cast<FwAssertArgType>(portNum)
443  );
444 
445  return this->m_gpioInterrupt_OutputPort[portNum].isConnected();
446  }
447 
448  // ----------------------------------------------------------------------
449  // Port handler base-class functions for typed input ports
450  //
451  // Call these functions directly to bypass the corresponding ports
452  // ----------------------------------------------------------------------
453 
456  FwIndexType portNum,
457  Fw::Logic& state
458  )
459  {
460  // Make sure port number is valid
461  FW_ASSERT(
462  portNum < this->getNum_gpioRead_InputPorts(),
463  static_cast<FwAssertArgType>(portNum)
464  );
465 
466  Drv::GpioStatus retVal;
467 
468  // Call handler function
469  retVal = this->gpioRead_handler(
470  portNum,
471  state
472  );
473 
474  return retVal;
475  }
476 
479  FwIndexType portNum,
480  const Fw::Logic& state
481  )
482  {
483  // Make sure port number is valid
484  FW_ASSERT(
485  portNum < this->getNum_gpioWrite_InputPorts(),
486  static_cast<FwAssertArgType>(portNum)
487  );
488 
489  Drv::GpioStatus retVal;
490 
491  // Call handler function
492  retVal = this->gpioWrite_handler(
493  portNum,
494  state
495  );
496 
497  return retVal;
498  }
499 
500  // ----------------------------------------------------------------------
501  // Invocation functions for typed output ports
502  // ----------------------------------------------------------------------
503 
506  FwIndexType portNum,
507  Os::RawTime& cycleStart
508  )
509  {
510  FW_ASSERT(
511  portNum < this->getNum_gpioInterrupt_OutputPorts(),
512  static_cast<FwAssertArgType>(portNum)
513  );
514  this->m_gpioInterrupt_OutputPort[portNum].invoke(
515  cycleStart
516  );
517  }
518 
519  // ----------------------------------------------------------------------
520  // Event logging functions
521  // ----------------------------------------------------------------------
522 
525  const Fw::StringBase& chip,
526  const Fw::StringBase& chipLabel,
527  U32 pin,
528  const Fw::StringBase& pinMessage
529  )
530  {
531  // Get the time
532  Fw::Time _logTime;
533  if (this->m_Time_OutputPort[0].isConnected()) {
534  this->m_Time_OutputPort[0].invoke(_logTime);
535  }
536 
537  FwEventIdType _id = static_cast<FwEventIdType>(0);
538 
539  _id = this->getIdBase() + EVENTID_OPENCHIP;
540 
541  // Emit the event on the log port
542  if (this->m_Log_OutputPort[0].isConnected()) {
543  Fw::LogBuffer _logBuff;
545 
546 #if FW_AMPCS_COMPATIBLE
547  // Serialize the number of arguments
548  _status = _logBuff.serialize(static_cast<U8>(4));
549  FW_ASSERT(
550  _status == Fw::FW_SERIALIZE_OK,
551  static_cast<FwAssertArgType>(_status)
552  );
553 #endif
554 
555  _status = chip.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
556  FW_ASSERT(
557  _status == Fw::FW_SERIALIZE_OK,
558  static_cast<FwAssertArgType>(_status)
559  );
560 
561  _status = chipLabel.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
562  FW_ASSERT(
563  _status == Fw::FW_SERIALIZE_OK,
564  static_cast<FwAssertArgType>(_status)
565  );
566 
567 #if FW_AMPCS_COMPATIBLE
568  // Serialize the argument size
569  _status = _logBuff.serialize(
570  static_cast<U8>(sizeof(U32))
571  );
572  FW_ASSERT(
573  _status == Fw::FW_SERIALIZE_OK,
574  static_cast<FwAssertArgType>(_status)
575  );
576 #endif
577  _status = _logBuff.serialize(pin);
578  FW_ASSERT(
579  _status == Fw::FW_SERIALIZE_OK,
580  static_cast<FwAssertArgType>(_status)
581  );
582 
583  _status = pinMessage.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
584  FW_ASSERT(
585  _status == Fw::FW_SERIALIZE_OK,
586  static_cast<FwAssertArgType>(_status)
587  );
588 
589  this->m_Log_OutputPort[0].invoke(
590  _id,
591  _logTime,
593  _logBuff
594  );
595  }
596 
597  // Emit the event on the text log port
598 #if FW_ENABLE_TEXT_LOGGING
599  if (this->m_LogText_OutputPort[0].isConnected()) {
600 #if FW_OBJECT_NAMES == 1
601  const char* _formatString =
602  "(%s) %s: Opened GPIO chip %s[%s] pin %" PRIu32 "[%s]";
603 #else
604  const char* _formatString =
605  "%s: Opened GPIO chip %s[%s] pin %" PRIu32 "[%s]";
606 #endif
607 
608  Fw::TextLogString _logString;
609  _logString.format(
610  _formatString,
611 #if FW_OBJECT_NAMES == 1
612  this->m_objName.toChar(),
613 #endif
614  "OpenChip ",
615  chip.toChar(),
616  chipLabel.toChar(),
617  pin,
618  pinMessage.toChar()
619  );
620 
621  this->m_LogText_OutputPort[0].invoke(
622  _id,
623  _logTime,
625  _logString
626  );
627  }
628 #endif
629  }
630 
633  const Fw::StringBase& chip,
634  Os::FileStatus status
635  )
636  {
637  // Get the time
638  Fw::Time _logTime;
639  if (this->m_Time_OutputPort[0].isConnected()) {
640  this->m_Time_OutputPort[0].invoke(_logTime);
641  }
642 
643  FwEventIdType _id = static_cast<FwEventIdType>(0);
644 
645  _id = this->getIdBase() + EVENTID_OPENCHIPERROR;
646 
647  // Emit the event on the log port
648  if (this->m_Log_OutputPort[0].isConnected()) {
649  Fw::LogBuffer _logBuff;
651 
652 #if FW_AMPCS_COMPATIBLE
653  // Serialize the number of arguments
654  _status = _logBuff.serialize(static_cast<U8>(2));
655  FW_ASSERT(
656  _status == Fw::FW_SERIALIZE_OK,
657  static_cast<FwAssertArgType>(_status)
658  );
659 #endif
660 
661  _status = chip.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
662  FW_ASSERT(
663  _status == Fw::FW_SERIALIZE_OK,
664  static_cast<FwAssertArgType>(_status)
665  );
666 
667 #if FW_AMPCS_COMPATIBLE
668  // Serialize the argument size
669  _status = _logBuff.serialize(
670  static_cast<U8>(Os::FileStatus::SERIALIZED_SIZE)
671  );
672  FW_ASSERT(
673  _status == Fw::FW_SERIALIZE_OK,
674  static_cast<FwAssertArgType>(_status)
675  );
676 #endif
677  _status = _logBuff.serialize(status);
678  FW_ASSERT(
679  _status == Fw::FW_SERIALIZE_OK,
680  static_cast<FwAssertArgType>(_status)
681  );
682 
683  this->m_Log_OutputPort[0].invoke(
684  _id,
685  _logTime,
687  _logBuff
688  );
689  }
690 
691  // Emit the event on the text log port
692 #if FW_ENABLE_TEXT_LOGGING
693  if (this->m_LogText_OutputPort[0].isConnected()) {
694 #if FW_OBJECT_NAMES == 1
695  const char* _formatString =
696  "(%s) %s: Failed to open GPIO chip %s: %s";
697 #else
698  const char* _formatString =
699  "%s: Failed to open GPIO chip %s: %s";
700 #endif
701 
702  Fw::String statusStr;
703  status.toString(statusStr);
704 
705  Fw::TextLogString _logString;
706  _logString.format(
707  _formatString,
708 #if FW_OBJECT_NAMES == 1
709  this->m_objName.toChar(),
710 #endif
711  "OpenChipError ",
712  chip.toChar(),
713  statusStr.toChar()
714  );
715 
716  this->m_LogText_OutputPort[0].invoke(
717  _id,
718  _logTime,
720  _logString
721  );
722  }
723 #endif
724  }
725 
728  const Fw::StringBase& chip,
729  U32 pin,
730  const Fw::StringBase& pinMessage,
731  Os::FileStatus status
732  )
733  {
734  // Get the time
735  Fw::Time _logTime;
736  if (this->m_Time_OutputPort[0].isConnected()) {
737  this->m_Time_OutputPort[0].invoke(_logTime);
738  }
739 
740  FwEventIdType _id = static_cast<FwEventIdType>(0);
741 
742  _id = this->getIdBase() + EVENTID_OPENPINERROR;
743 
744  // Emit the event on the log port
745  if (this->m_Log_OutputPort[0].isConnected()) {
746  Fw::LogBuffer _logBuff;
748 
749 #if FW_AMPCS_COMPATIBLE
750  // Serialize the number of arguments
751  _status = _logBuff.serialize(static_cast<U8>(4));
752  FW_ASSERT(
753  _status == Fw::FW_SERIALIZE_OK,
754  static_cast<FwAssertArgType>(_status)
755  );
756 #endif
757 
758  _status = chip.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
759  FW_ASSERT(
760  _status == Fw::FW_SERIALIZE_OK,
761  static_cast<FwAssertArgType>(_status)
762  );
763 
764 #if FW_AMPCS_COMPATIBLE
765  // Serialize the argument size
766  _status = _logBuff.serialize(
767  static_cast<U8>(sizeof(U32))
768  );
769  FW_ASSERT(
770  _status == Fw::FW_SERIALIZE_OK,
771  static_cast<FwAssertArgType>(_status)
772  );
773 #endif
774  _status = _logBuff.serialize(pin);
775  FW_ASSERT(
776  _status == Fw::FW_SERIALIZE_OK,
777  static_cast<FwAssertArgType>(_status)
778  );
779 
780  _status = pinMessage.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
781  FW_ASSERT(
782  _status == Fw::FW_SERIALIZE_OK,
783  static_cast<FwAssertArgType>(_status)
784  );
785 
786 #if FW_AMPCS_COMPATIBLE
787  // Serialize the argument size
788  _status = _logBuff.serialize(
789  static_cast<U8>(Os::FileStatus::SERIALIZED_SIZE)
790  );
791  FW_ASSERT(
792  _status == Fw::FW_SERIALIZE_OK,
793  static_cast<FwAssertArgType>(_status)
794  );
795 #endif
796  _status = _logBuff.serialize(status);
797  FW_ASSERT(
798  _status == Fw::FW_SERIALIZE_OK,
799  static_cast<FwAssertArgType>(_status)
800  );
801 
802  this->m_Log_OutputPort[0].invoke(
803  _id,
804  _logTime,
806  _logBuff
807  );
808  }
809 
810  // Emit the event on the text log port
811 #if FW_ENABLE_TEXT_LOGGING
812  if (this->m_LogText_OutputPort[0].isConnected()) {
813 #if FW_OBJECT_NAMES == 1
814  const char* _formatString =
815  "(%s) %s: Failed to open GPIO chip %s pin %" PRIu32 " [%s]: %s";
816 #else
817  const char* _formatString =
818  "%s: Failed to open GPIO chip %s pin %" PRIu32 " [%s]: %s";
819 #endif
820 
821  Fw::String statusStr;
822  status.toString(statusStr);
823 
824  Fw::TextLogString _logString;
825  _logString.format(
826  _formatString,
827 #if FW_OBJECT_NAMES == 1
828  this->m_objName.toChar(),
829 #endif
830  "OpenPinError ",
831  chip.toChar(),
832  pin,
833  pinMessage.toChar(),
834  statusStr.toChar()
835  );
836 
837  this->m_LogText_OutputPort[0].invoke(
838  _id,
839  _logTime,
841  _logString
842  );
843  }
844 #endif
845  }
846 
849  U32 expected,
850  U32 got
851  )
852  {
853  // Get the time
854  Fw::Time _logTime;
855  if (this->m_Time_OutputPort[0].isConnected()) {
856  this->m_Time_OutputPort[0].invoke(_logTime);
857  }
858 
859  FwEventIdType _id = static_cast<FwEventIdType>(0);
860 
861  _id = this->getIdBase() + EVENTID_INTERRUPTREADERROR;
862 
863  // Emit the event on the log port
864  if (this->m_Log_OutputPort[0].isConnected()) {
865  Fw::LogBuffer _logBuff;
867 
868 #if FW_AMPCS_COMPATIBLE
869  // Serialize the number of arguments
870  _status = _logBuff.serialize(static_cast<U8>(2));
871  FW_ASSERT(
872  _status == Fw::FW_SERIALIZE_OK,
873  static_cast<FwAssertArgType>(_status)
874  );
875 #endif
876 
877 #if FW_AMPCS_COMPATIBLE
878  // Serialize the argument size
879  _status = _logBuff.serialize(
880  static_cast<U8>(sizeof(U32))
881  );
882  FW_ASSERT(
883  _status == Fw::FW_SERIALIZE_OK,
884  static_cast<FwAssertArgType>(_status)
885  );
886 #endif
887  _status = _logBuff.serialize(expected);
888  FW_ASSERT(
889  _status == Fw::FW_SERIALIZE_OK,
890  static_cast<FwAssertArgType>(_status)
891  );
892 
893 #if FW_AMPCS_COMPATIBLE
894  // Serialize the argument size
895  _status = _logBuff.serialize(
896  static_cast<U8>(sizeof(U32))
897  );
898  FW_ASSERT(
899  _status == Fw::FW_SERIALIZE_OK,
900  static_cast<FwAssertArgType>(_status)
901  );
902 #endif
903  _status = _logBuff.serialize(got);
904  FW_ASSERT(
905  _status == Fw::FW_SERIALIZE_OK,
906  static_cast<FwAssertArgType>(_status)
907  );
908 
909  this->m_Log_OutputPort[0].invoke(
910  _id,
911  _logTime,
913  _logBuff
914  );
915  }
916 
917  // Emit the event on the text log port
918 #if FW_ENABLE_TEXT_LOGGING
919  if (this->m_LogText_OutputPort[0].isConnected()) {
920 #if FW_OBJECT_NAMES == 1
921  const char* _formatString =
922  "(%s) %s: Interrupt data read expected %" PRIu32 " byes and got %" PRIu32 "";
923 #else
924  const char* _formatString =
925  "%s: Interrupt data read expected %" PRIu32 " byes and got %" PRIu32 "";
926 #endif
927 
928  Fw::TextLogString _logString;
929  _logString.format(
930  _formatString,
931 #if FW_OBJECT_NAMES == 1
932  this->m_objName.toChar(),
933 #endif
934  "InterruptReadError ",
935  expected,
936  got
937  );
938 
939  this->m_LogText_OutputPort[0].invoke(
940  _id,
941  _logTime,
943  _logString
944  );
945  }
946 #endif
947  }
948 
950  log_WARNING_HI_PollingError(I32 error_number)
951  {
952  // Get the time
953  Fw::Time _logTime;
954  if (this->m_Time_OutputPort[0].isConnected()) {
955  this->m_Time_OutputPort[0].invoke(_logTime);
956  }
957 
958  FwEventIdType _id = static_cast<FwEventIdType>(0);
959 
960  _id = this->getIdBase() + EVENTID_POLLINGERROR;
961 
962  // Emit the event on the log port
963  if (this->m_Log_OutputPort[0].isConnected()) {
964  Fw::LogBuffer _logBuff;
966 
967 #if FW_AMPCS_COMPATIBLE
968  // Serialize the number of arguments
969  _status = _logBuff.serialize(static_cast<U8>(1));
970  FW_ASSERT(
971  _status == Fw::FW_SERIALIZE_OK,
972  static_cast<FwAssertArgType>(_status)
973  );
974 #endif
975 
976 #if FW_AMPCS_COMPATIBLE
977  // Serialize the argument size
978  _status = _logBuff.serialize(
979  static_cast<U8>(sizeof(I32))
980  );
981  FW_ASSERT(
982  _status == Fw::FW_SERIALIZE_OK,
983  static_cast<FwAssertArgType>(_status)
984  );
985 #endif
986  _status = _logBuff.serialize(error_number);
987  FW_ASSERT(
988  _status == Fw::FW_SERIALIZE_OK,
989  static_cast<FwAssertArgType>(_status)
990  );
991 
992  this->m_Log_OutputPort[0].invoke(
993  _id,
994  _logTime,
996  _logBuff
997  );
998  }
999 
1000  // Emit the event on the text log port
1001 #if FW_ENABLE_TEXT_LOGGING
1002  if (this->m_LogText_OutputPort[0].isConnected()) {
1003 #if FW_OBJECT_NAMES == 1
1004  const char* _formatString =
1005  "(%s) %s: Interrupt polling returned errno: %" PRIi32 "";
1006 #else
1007  const char* _formatString =
1008  "%s: Interrupt polling returned errno: %" PRIi32 "";
1009 #endif
1010 
1011  Fw::TextLogString _logString;
1012  _logString.format(
1013  _formatString,
1014 #if FW_OBJECT_NAMES == 1
1015  this->m_objName.toChar(),
1016 #endif
1017  "PollingError ",
1018  error_number
1019  );
1020 
1021  this->m_LogText_OutputPort[0].invoke(
1022  _id,
1023  _logTime,
1025  _logString
1026  );
1027  }
1028 #endif
1029  }
1030 
1031  // ----------------------------------------------------------------------
1032  // Time
1033  // ----------------------------------------------------------------------
1034 
1036  getTime()
1037  {
1038  if (this->m_Time_OutputPort[0].isConnected()) {
1039  Fw::Time _time;
1040  this->m_Time_OutputPort[0].invoke(_time);
1041  return _time;
1042  }
1043  else {
1044  return Fw::Time(TB_NONE, 0, 0);
1045  }
1046  }
1047 
1048  // ----------------------------------------------------------------------
1049  // Calls for messages received on typed input ports
1050  // ----------------------------------------------------------------------
1051 
1052  Drv::GpioStatus LinuxGpioDriverComponentBase ::
1053  m_p_gpioRead_in(
1054  Fw::PassiveComponentBase* callComp,
1055  FwIndexType portNum,
1056  Fw::Logic& state
1057  )
1058  {
1059  FW_ASSERT(callComp);
1060  LinuxGpioDriverComponentBase* compPtr = static_cast<LinuxGpioDriverComponentBase*>(callComp);
1061  return compPtr->gpioRead_handlerBase(
1062  portNum,
1063  state
1064  );
1065  }
1066 
1067  Drv::GpioStatus LinuxGpioDriverComponentBase ::
1068  m_p_gpioWrite_in(
1069  Fw::PassiveComponentBase* callComp,
1070  FwIndexType portNum,
1071  const Fw::Logic& state
1072  )
1073  {
1074  FW_ASSERT(callComp);
1075  LinuxGpioDriverComponentBase* compPtr = static_cast<LinuxGpioDriverComponentBase*>(callComp);
1076  return compPtr->gpioWrite_handlerBase(
1077  portNum,
1078  state
1079  );
1080  }
1081 
1082 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
#define FW_MIN(a, b)
MIN macro.
Definition: BasicTypes.h:72
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:30
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:70
#define PRI_PlatformIntType
@ TB_NONE
No time base has been established.
Definition: FpConfig.h:70
I32 FwEnumStoreType
Definition: FpConfig.h:64
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:39
U32 FwEventIdType
Definition: FpConfig.h:103
#define FW_LOG_STRING_MAX_SIZE
Max size of log string parameter type.
Definition: FpConfig.h:319
PlatformIndexType FwIndexType
Definition: FpConfig.h:25
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects)
Definition: FpConfig.h:148
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.
Drv::InputGpioWritePort * get_gpioWrite_InputPort(FwIndexType portNum)
void set_gpioInterrupt_OutputPort(FwIndexType portNum, Svc::InputCyclePort *port)
Connect port to gpioInterrupt[portNum].
virtual ~LinuxGpioDriverComponentBase()
Destroy LinuxGpioDriverComponentBase object.
void log_DIAGNOSTIC_OpenChip(const Fw::StringBase &chip, const Fw::StringBase &chipLabel, U32 pin, const Fw::StringBase &pinMessage)
Log event OpenChip.
Drv::GpioStatus gpioRead_handlerBase(FwIndexType portNum, Fw::Logic &state)
Handler base-class function for input port gpioRead.
void log_WARNING_HI_OpenPinError(const Fw::StringBase &chip, U32 pin, const Fw::StringBase &pinMessage, Os::FileStatus status)
Log event OpenPinError.
Drv::GpioStatus gpioWrite_handlerBase(FwIndexType portNum, const Fw::Logic &state)
Handler base-class function for input port gpioWrite.
void log_WARNING_HI_OpenChipError(const Fw::StringBase &chip, Os::FileStatus status)
Log event OpenChipError.
void log_WARNING_HI_InterruptReadError(U32 expected, U32 got)
Log event InterruptReadError.
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_PollingError(I32 error_number)
Log event PollingError.
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
bool isConnected_Time_OutputPort(FwIndexType portNum)
bool isConnected_gpioInterrupt_OutputPort(FwIndexType portNum)
bool isConnected_Log_OutputPort(FwIndexType portNum)
void gpioInterrupt_out(FwIndexType portNum, Os::RawTime &cycleStart)
Invoke output port gpioInterrupt.
LinuxGpioDriverComponentBase(const char *compName="")
Construct LinuxGpioDriverComponentBase object.
virtual Drv::GpioStatus gpioWrite_handler(FwIndexType portNum, const Fw::Logic &state)=0
Handler for input port gpioWrite.
virtual Drv::GpioStatus gpioRead_handler(FwIndexType portNum, Fw::Logic &state)=0
Handler for input port gpioRead.
void setPortNum(NATIVE_INT_TYPE portNum)
@ WARNING_HI
A serious but recoverable event.
@ DIAGNOSTIC
Software diagnostic 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:146
const char * toChar() const
Definition: String.hpp:50
Definition: Time.hpp:9
FPP shadow-enum representing Os::File::Status.
@ SERIALIZED_SIZE
The size of the serial representation.
void init()
Initialization function.
void invoke(Os::RawTime &cycleStart)
Invoke a port interface.
void addCallPort(InputCyclePort *callPort)
Register an input port.
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.