F´ Flight Software - C/C++ Documentation
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 
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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_FwIndexType "]",
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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (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  (0 <= portNum) && (portNum < this->getNum_gpioInterrupt_OutputPorts()),
512  static_cast<FwAssertArgType>(portNum)
513  );
514 
515  FW_ASSERT(
516  this->m_gpioInterrupt_OutputPort[portNum].isConnected(),
517  static_cast<FwAssertArgType>(portNum)
518  );
519  this->m_gpioInterrupt_OutputPort[portNum].invoke(
520  cycleStart
521  );
522  }
523 
524  // ----------------------------------------------------------------------
525  // Event logging functions
526  // ----------------------------------------------------------------------
527 
530  const Fw::StringBase& chip,
531  const Fw::StringBase& chipLabel,
532  U32 pin,
533  const Fw::StringBase& pinMessage
534  ) const
535  {
536  // Get the time
537  Fw::Time _logTime;
538  if (this->m_Time_OutputPort[0].isConnected()) {
539  this->m_Time_OutputPort[0].invoke(_logTime);
540  }
541 
542  FwEventIdType _id = static_cast<FwEventIdType>(0);
543 
544  _id = this->getIdBase() + EVENTID_OPENCHIP;
545 
546  // Emit the event on the log port
547  if (this->m_Log_OutputPort[0].isConnected()) {
548  Fw::LogBuffer _logBuff;
550 
551 #if FW_AMPCS_COMPATIBLE
552  // Serialize the number of arguments
553  _status = _logBuff.serialize(static_cast<U8>(4));
554  FW_ASSERT(
555  _status == Fw::FW_SERIALIZE_OK,
556  static_cast<FwAssertArgType>(_status)
557  );
558 #endif
559 
560  _status = chip.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
561  FW_ASSERT(
562  _status == Fw::FW_SERIALIZE_OK,
563  static_cast<FwAssertArgType>(_status)
564  );
565 
566  _status = chipLabel.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
567  FW_ASSERT(
568  _status == Fw::FW_SERIALIZE_OK,
569  static_cast<FwAssertArgType>(_status)
570  );
571 
572 #if FW_AMPCS_COMPATIBLE
573  // Serialize the argument size
574  _status = _logBuff.serialize(
575  static_cast<U8>(sizeof(U32))
576  );
577  FW_ASSERT(
578  _status == Fw::FW_SERIALIZE_OK,
579  static_cast<FwAssertArgType>(_status)
580  );
581 #endif
582  _status = _logBuff.serialize(pin);
583  FW_ASSERT(
584  _status == Fw::FW_SERIALIZE_OK,
585  static_cast<FwAssertArgType>(_status)
586  );
587 
588  _status = pinMessage.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
589  FW_ASSERT(
590  _status == Fw::FW_SERIALIZE_OK,
591  static_cast<FwAssertArgType>(_status)
592  );
593 
594  this->m_Log_OutputPort[0].invoke(
595  _id,
596  _logTime,
598  _logBuff
599  );
600  }
601 
602  // Emit the event on the text log port
603 #if FW_ENABLE_TEXT_LOGGING
604  if (this->m_LogText_OutputPort[0].isConnected()) {
605 #if FW_OBJECT_NAMES == 1
606  const char* _formatString =
607  "(%s) %s: Opened GPIO chip %s[%s] pin %" PRIu32 "[%s]";
608 #else
609  const char* _formatString =
610  "%s: Opened GPIO chip %s[%s] pin %" PRIu32 "[%s]";
611 #endif
612 
613  Fw::TextLogString _logString;
614  _logString.format(
615  _formatString,
616 #if FW_OBJECT_NAMES == 1
617  this->m_objName.toChar(),
618 #endif
619  "OpenChip ",
620  chip.toChar(),
621  chipLabel.toChar(),
622  pin,
623  pinMessage.toChar()
624  );
625 
626  this->m_LogText_OutputPort[0].invoke(
627  _id,
628  _logTime,
630  _logString
631  );
632  }
633 #endif
634  }
635 
638  const Fw::StringBase& chip,
639  Os::FileStatus status
640  ) const
641  {
642  // Get the time
643  Fw::Time _logTime;
644  if (this->m_Time_OutputPort[0].isConnected()) {
645  this->m_Time_OutputPort[0].invoke(_logTime);
646  }
647 
648  FwEventIdType _id = static_cast<FwEventIdType>(0);
649 
650  _id = this->getIdBase() + EVENTID_OPENCHIPERROR;
651 
652  // Emit the event on the log port
653  if (this->m_Log_OutputPort[0].isConnected()) {
654  Fw::LogBuffer _logBuff;
656 
657 #if FW_AMPCS_COMPATIBLE
658  // Serialize the number of arguments
659  _status = _logBuff.serialize(static_cast<U8>(2));
660  FW_ASSERT(
661  _status == Fw::FW_SERIALIZE_OK,
662  static_cast<FwAssertArgType>(_status)
663  );
664 #endif
665 
666  _status = chip.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
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>(Os::FileStatus::SERIALIZED_SIZE)
676  );
677  FW_ASSERT(
678  _status == Fw::FW_SERIALIZE_OK,
679  static_cast<FwAssertArgType>(_status)
680  );
681 #endif
682  _status = _logBuff.serialize(status);
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: Failed to open GPIO chip %s: %s";
702 #else
703  const char* _formatString =
704  "%s: Failed to open GPIO chip %s: %s";
705 #endif
706 
707  Fw::String statusStr;
708  status.toString(statusStr);
709 
710  Fw::TextLogString _logString;
711  _logString.format(
712  _formatString,
713 #if FW_OBJECT_NAMES == 1
714  this->m_objName.toChar(),
715 #endif
716  "OpenChipError ",
717  chip.toChar(),
718  statusStr.toChar()
719  );
720 
721  this->m_LogText_OutputPort[0].invoke(
722  _id,
723  _logTime,
725  _logString
726  );
727  }
728 #endif
729  }
730 
733  const Fw::StringBase& chip,
734  U32 pin,
735  const Fw::StringBase& pinMessage,
736  Os::FileStatus status
737  ) const
738  {
739  // Get the time
740  Fw::Time _logTime;
741  if (this->m_Time_OutputPort[0].isConnected()) {
742  this->m_Time_OutputPort[0].invoke(_logTime);
743  }
744 
745  FwEventIdType _id = static_cast<FwEventIdType>(0);
746 
747  _id = this->getIdBase() + EVENTID_OPENPINERROR;
748 
749  // Emit the event on the log port
750  if (this->m_Log_OutputPort[0].isConnected()) {
751  Fw::LogBuffer _logBuff;
753 
754 #if FW_AMPCS_COMPATIBLE
755  // Serialize the number of arguments
756  _status = _logBuff.serialize(static_cast<U8>(4));
757  FW_ASSERT(
758  _status == Fw::FW_SERIALIZE_OK,
759  static_cast<FwAssertArgType>(_status)
760  );
761 #endif
762 
763  _status = chip.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
764  FW_ASSERT(
765  _status == Fw::FW_SERIALIZE_OK,
766  static_cast<FwAssertArgType>(_status)
767  );
768 
769 #if FW_AMPCS_COMPATIBLE
770  // Serialize the argument size
771  _status = _logBuff.serialize(
772  static_cast<U8>(sizeof(U32))
773  );
774  FW_ASSERT(
775  _status == Fw::FW_SERIALIZE_OK,
776  static_cast<FwAssertArgType>(_status)
777  );
778 #endif
779  _status = _logBuff.serialize(pin);
780  FW_ASSERT(
781  _status == Fw::FW_SERIALIZE_OK,
782  static_cast<FwAssertArgType>(_status)
783  );
784 
785  _status = pinMessage.serialize(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
786  FW_ASSERT(
787  _status == Fw::FW_SERIALIZE_OK,
788  static_cast<FwAssertArgType>(_status)
789  );
790 
791 #if FW_AMPCS_COMPATIBLE
792  // Serialize the argument size
793  _status = _logBuff.serialize(
794  static_cast<U8>(Os::FileStatus::SERIALIZED_SIZE)
795  );
796  FW_ASSERT(
797  _status == Fw::FW_SERIALIZE_OK,
798  static_cast<FwAssertArgType>(_status)
799  );
800 #endif
801  _status = _logBuff.serialize(status);
802  FW_ASSERT(
803  _status == Fw::FW_SERIALIZE_OK,
804  static_cast<FwAssertArgType>(_status)
805  );
806 
807  this->m_Log_OutputPort[0].invoke(
808  _id,
809  _logTime,
811  _logBuff
812  );
813  }
814 
815  // Emit the event on the text log port
816 #if FW_ENABLE_TEXT_LOGGING
817  if (this->m_LogText_OutputPort[0].isConnected()) {
818 #if FW_OBJECT_NAMES == 1
819  const char* _formatString =
820  "(%s) %s: Failed to open GPIO chip %s pin %" PRIu32 " [%s]: %s";
821 #else
822  const char* _formatString =
823  "%s: Failed to open GPIO chip %s pin %" PRIu32 " [%s]: %s";
824 #endif
825 
826  Fw::String statusStr;
827  status.toString(statusStr);
828 
829  Fw::TextLogString _logString;
830  _logString.format(
831  _formatString,
832 #if FW_OBJECT_NAMES == 1
833  this->m_objName.toChar(),
834 #endif
835  "OpenPinError ",
836  chip.toChar(),
837  pin,
838  pinMessage.toChar(),
839  statusStr.toChar()
840  );
841 
842  this->m_LogText_OutputPort[0].invoke(
843  _id,
844  _logTime,
846  _logString
847  );
848  }
849 #endif
850  }
851 
854  U32 expected,
855  U32 got
856  ) const
857  {
858  // Get the time
859  Fw::Time _logTime;
860  if (this->m_Time_OutputPort[0].isConnected()) {
861  this->m_Time_OutputPort[0].invoke(_logTime);
862  }
863 
864  FwEventIdType _id = static_cast<FwEventIdType>(0);
865 
866  _id = this->getIdBase() + EVENTID_INTERRUPTREADERROR;
867 
868  // Emit the event on the log port
869  if (this->m_Log_OutputPort[0].isConnected()) {
870  Fw::LogBuffer _logBuff;
872 
873 #if FW_AMPCS_COMPATIBLE
874  // Serialize the number of arguments
875  _status = _logBuff.serialize(static_cast<U8>(2));
876  FW_ASSERT(
877  _status == Fw::FW_SERIALIZE_OK,
878  static_cast<FwAssertArgType>(_status)
879  );
880 #endif
881 
882 #if FW_AMPCS_COMPATIBLE
883  // Serialize the argument size
884  _status = _logBuff.serialize(
885  static_cast<U8>(sizeof(U32))
886  );
887  FW_ASSERT(
888  _status == Fw::FW_SERIALIZE_OK,
889  static_cast<FwAssertArgType>(_status)
890  );
891 #endif
892  _status = _logBuff.serialize(expected);
893  FW_ASSERT(
894  _status == Fw::FW_SERIALIZE_OK,
895  static_cast<FwAssertArgType>(_status)
896  );
897 
898 #if FW_AMPCS_COMPATIBLE
899  // Serialize the argument size
900  _status = _logBuff.serialize(
901  static_cast<U8>(sizeof(U32))
902  );
903  FW_ASSERT(
904  _status == Fw::FW_SERIALIZE_OK,
905  static_cast<FwAssertArgType>(_status)
906  );
907 #endif
908  _status = _logBuff.serialize(got);
909  FW_ASSERT(
910  _status == Fw::FW_SERIALIZE_OK,
911  static_cast<FwAssertArgType>(_status)
912  );
913 
914  this->m_Log_OutputPort[0].invoke(
915  _id,
916  _logTime,
918  _logBuff
919  );
920  }
921 
922  // Emit the event on the text log port
923 #if FW_ENABLE_TEXT_LOGGING
924  if (this->m_LogText_OutputPort[0].isConnected()) {
925 #if FW_OBJECT_NAMES == 1
926  const char* _formatString =
927  "(%s) %s: Interrupt data read expected %" PRIu32 " byes and got %" PRIu32 "";
928 #else
929  const char* _formatString =
930  "%s: Interrupt data read expected %" PRIu32 " byes and got %" PRIu32 "";
931 #endif
932 
933  Fw::TextLogString _logString;
934  _logString.format(
935  _formatString,
936 #if FW_OBJECT_NAMES == 1
937  this->m_objName.toChar(),
938 #endif
939  "InterruptReadError ",
940  expected,
941  got
942  );
943 
944  this->m_LogText_OutputPort[0].invoke(
945  _id,
946  _logTime,
948  _logString
949  );
950  }
951 #endif
952  }
953 
955  log_WARNING_HI_PollingError(I32 error_number) const
956  {
957  // Get the time
958  Fw::Time _logTime;
959  if (this->m_Time_OutputPort[0].isConnected()) {
960  this->m_Time_OutputPort[0].invoke(_logTime);
961  }
962 
963  FwEventIdType _id = static_cast<FwEventIdType>(0);
964 
965  _id = this->getIdBase() + EVENTID_POLLINGERROR;
966 
967  // Emit the event on the log port
968  if (this->m_Log_OutputPort[0].isConnected()) {
969  Fw::LogBuffer _logBuff;
971 
972 #if FW_AMPCS_COMPATIBLE
973  // Serialize the number of arguments
974  _status = _logBuff.serialize(static_cast<U8>(1));
975  FW_ASSERT(
976  _status == Fw::FW_SERIALIZE_OK,
977  static_cast<FwAssertArgType>(_status)
978  );
979 #endif
980 
981 #if FW_AMPCS_COMPATIBLE
982  // Serialize the argument size
983  _status = _logBuff.serialize(
984  static_cast<U8>(sizeof(I32))
985  );
986  FW_ASSERT(
987  _status == Fw::FW_SERIALIZE_OK,
988  static_cast<FwAssertArgType>(_status)
989  );
990 #endif
991  _status = _logBuff.serialize(error_number);
992  FW_ASSERT(
993  _status == Fw::FW_SERIALIZE_OK,
994  static_cast<FwAssertArgType>(_status)
995  );
996 
997  this->m_Log_OutputPort[0].invoke(
998  _id,
999  _logTime,
1001  _logBuff
1002  );
1003  }
1004 
1005  // Emit the event on the text log port
1006 #if FW_ENABLE_TEXT_LOGGING
1007  if (this->m_LogText_OutputPort[0].isConnected()) {
1008 #if FW_OBJECT_NAMES == 1
1009  const char* _formatString =
1010  "(%s) %s: Interrupt polling returned errno: %" PRIi32 "";
1011 #else
1012  const char* _formatString =
1013  "%s: Interrupt polling returned errno: %" PRIi32 "";
1014 #endif
1015 
1016  Fw::TextLogString _logString;
1017  _logString.format(
1018  _formatString,
1019 #if FW_OBJECT_NAMES == 1
1020  this->m_objName.toChar(),
1021 #endif
1022  "PollingError ",
1023  error_number
1024  );
1025 
1026  this->m_LogText_OutputPort[0].invoke(
1027  _id,
1028  _logTime,
1030  _logString
1031  );
1032  }
1033 #endif
1034  }
1035 
1036  // ----------------------------------------------------------------------
1037  // Time
1038  // ----------------------------------------------------------------------
1039 
1041  getTime() const
1042  {
1043  if (this->m_Time_OutputPort[0].isConnected()) {
1044  Fw::Time _time;
1045  this->m_Time_OutputPort[0].invoke(_time);
1046  return _time;
1047  }
1048  else {
1049  return Fw::Time(TB_NONE, 0, 0);
1050  }
1051  }
1052 
1053  // ----------------------------------------------------------------------
1054  // Calls for messages received on typed input ports
1055  // ----------------------------------------------------------------------
1056 
1057  Drv::GpioStatus LinuxGpioDriverComponentBase ::
1058  m_p_gpioRead_in(
1059  Fw::PassiveComponentBase* callComp,
1060  FwIndexType portNum,
1061  Fw::Logic& state
1062  )
1063  {
1064  FW_ASSERT(callComp);
1065  LinuxGpioDriverComponentBase* compPtr = static_cast<LinuxGpioDriverComponentBase*>(callComp);
1066  return compPtr->gpioRead_handlerBase(
1067  portNum,
1068  state
1069  );
1070  }
1071 
1072  Drv::GpioStatus LinuxGpioDriverComponentBase ::
1073  m_p_gpioWrite_in(
1074  Fw::PassiveComponentBase* callComp,
1075  FwIndexType portNum,
1076  const Fw::Logic& state
1077  )
1078  {
1079  FW_ASSERT(callComp);
1080  LinuxGpioDriverComponentBase* compPtr = static_cast<LinuxGpioDriverComponentBase*>(callComp);
1081  return compPtr->gpioWrite_handlerBase(
1082  portNum,
1083  state
1084  );
1085  }
1086 
1087 }
Serialization/Deserialization operation was successful.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
Drv::InputGpioReadPort * get_gpioRead_InputPort(FwIndexType portNum)
bool isConnected_gpioInterrupt_OutputPort(FwIndexType portNum)
Definition: Time.hpp:9
Drv::InputGpioWritePort * get_gpioWrite_InputPort(FwIndexType portNum)
I32 FwEnumStoreType
void init()
Initialization function.
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
void log_WARNING_HI_InterruptReadError(U32 expected, U32 got) const
Log event InterruptReadError.
const char * toChar() const
Definition: String.hpp:50
LinuxGpioDriverComponentBase(const char *compName="")
Construct LinuxGpioDriverComponentBase object.
Input GpioWrite port.
void set_gpioInterrupt_OutputPort(FwIndexType portNum, Svc::InputCyclePort *port)
Connect port to gpioInterrupt[portNum].
Drv::GpioStatus gpioWrite_handlerBase(FwIndexType portNum, const Fw::Logic &state)
Handler base-class function for input port gpioWrite.
virtual Drv::GpioStatus gpioWrite_handler(FwIndexType portNum, const Fw::Logic &state)=0
Handler for input port gpioWrite.
void log_WARNING_HI_OpenPinError(const Fw::StringBase &chip, U32 pin, const Fw::StringBase &pinMessage, Os::FileStatus status) const
Log event OpenPinError.
virtual Drv::GpioStatus gpioRead_handler(FwIndexType portNum, Fw::Logic &state)=0
Handler for input port gpioRead.
Software diagnostic events.
void init()
Object initializer.
Definition: ObjBase.cpp:26
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
Drv::GpioStatus gpioRead_handlerBase(FwIndexType portNum, Fw::Logic &state)
Handler base-class function for input port gpioRead.
U32 FwEventIdType
The type of an event identifier.
SerializeStatus
forward declaration for string
void addCallPort(InputCyclePort *callPort)
Register an input port.
bool isConnected_Log_OutputPort(FwIndexType portNum)
Auto-generated base for LinuxGpioDriver component.
void init()
Initialization function.
Definition: TimePortAc.cpp:128
#define FW_MIN(a, b)
MIN macro.
Definition: BasicTypes.h:95
bool isConnected_Time_OutputPort(FwIndexType portNum)
void log_WARNING_HI_OpenChipError(const Fw::StringBase &chip, Os::FileStatus status) const
Log event OpenChipError.
void invoke(Fw::Time &time) const
Invoke a port interface.
Definition: TimePortAc.cpp:147
const char * toChar() const
Definition: ObjectName.hpp:50
No time base has been established.
Definition: FpConfig.h:30
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void init()
Initialization function.
void log_DIAGNOSTIC_OpenChip(const Fw::StringBase &chip, const Fw::StringBase &chipLabel, U32 pin, const Fw::StringBase &pinMessage) const
Log event OpenChip.
void gpioInterrupt_out(FwIndexType portNum, Os::RawTime &cycleStart)
Invoke output port gpioInterrupt.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
A serious but recoverable event.
bool isConnected() const
Definition: PortBase.cpp:42
#define PRI_FwIndexType
Input GpioRead port.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void setPortNum(FwIndexType portNum)
void init()
Initialization function.
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port interface.
Definition: LogPortAc.cpp:170
The size of the serial representation.
PlatformIndexType FwIndexType
void log_WARNING_HI_PollingError(I32 error_number) const
Log event PollingError.
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:93
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
Logic states.
Definition: LogicEnumAc.hpp:17
virtual SerializeStatus serialize(SerializeBufferBase &buffer) const
serialization function
Definition: StringBase.cpp:142
void invoke(Os::RawTime &cycleStart) const
Invoke a port interface.
virtual ~LinuxGpioDriverComponentBase()
Destroy LinuxGpioDriverComponentBase object.
FPP shadow-enum representing Os::File::Status.
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:53
#define FW_ASSERT(...)
Definition: Assert.hpp:14
#define FW_LOG_STRING_MAX_SIZE
Max size of log string parameter type.
Definition: FpConfig.h:224
virtual const CHAR * toChar() const =0