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 #if !FW_DIRECT_PORT_CALLS
27  // Connect input port gpioRead
28  for (
29  FwIndexType port = 0;
30  port < static_cast<FwIndexType>(this->getNum_gpioRead_InputPorts());
31  port++
32  ) {
33  this->m_gpioRead_InputPort[port].init();
34  this->m_gpioRead_InputPort[port].addCallComp(
35  this,
36  m_p_gpioRead_in
37  );
38  this->m_gpioRead_InputPort[port].setPortNum(port);
39 
40 #if FW_OBJECT_NAMES == 1
41  Fw::ObjectName portName;
42  portName.format(
43  "%s_gpioRead_InputPort[%" PRI_FwIndexType "]",
44  this->m_objName.toChar(),
45  port
46  );
47  this->m_gpioRead_InputPort[port].setObjName(portName.toChar());
48 #endif
49  }
50 #endif
51 
52 #if !FW_DIRECT_PORT_CALLS
53  // Connect input port gpioWrite
54  for (
55  FwIndexType port = 0;
56  port < static_cast<FwIndexType>(this->getNum_gpioWrite_InputPorts());
57  port++
58  ) {
59  this->m_gpioWrite_InputPort[port].init();
60  this->m_gpioWrite_InputPort[port].addCallComp(
61  this,
62  m_p_gpioWrite_in
63  );
64  this->m_gpioWrite_InputPort[port].setPortNum(port);
65 
66 #if FW_OBJECT_NAMES == 1
67  Fw::ObjectName portName;
68  portName.format(
69  "%s_gpioWrite_InputPort[%" PRI_FwIndexType "]",
70  this->m_objName.toChar(),
71  port
72  );
73  this->m_gpioWrite_InputPort[port].setObjName(portName.toChar());
74 #endif
75  }
76 #endif
77 
78 #if !FW_DIRECT_PORT_CALLS
79  // Connect output port Log
80  for (
81  FwIndexType port = 0;
82  port < static_cast<FwIndexType>(this->getNum_Log_OutputPorts());
83  port++
84  ) {
85  this->m_Log_OutputPort[port].init();
86 
87 #if FW_OBJECT_NAMES == 1
88  Fw::ObjectName portName;
89  portName.format(
90  "%s_Log_OutputPort[%" PRI_FwIndexType "]",
91  this->m_objName.toChar(),
92  port
93  );
94  this->m_Log_OutputPort[port].setObjName(portName.toChar());
95 #endif
96  }
97 #endif
98 
99 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
100  // Connect output port LogText
101  for (
102  FwIndexType port = 0;
103  port < static_cast<FwIndexType>(this->getNum_LogText_OutputPorts());
104  port++
105  ) {
106  this->m_LogText_OutputPort[port].init();
107 
108 #if FW_OBJECT_NAMES == 1
109  Fw::ObjectName portName;
110  portName.format(
111  "%s_LogText_OutputPort[%" PRI_FwIndexType "]",
112  this->m_objName.toChar(),
113  port
114  );
115  this->m_LogText_OutputPort[port].setObjName(portName.toChar());
116 #endif
117  }
118 #endif
119 
120 #if !FW_DIRECT_PORT_CALLS
121  // Connect output port Time
122  for (
123  FwIndexType port = 0;
124  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
125  port++
126  ) {
127  this->m_Time_OutputPort[port].init();
128 
129 #if FW_OBJECT_NAMES == 1
130  Fw::ObjectName portName;
131  portName.format(
132  "%s_Time_OutputPort[%" PRI_FwIndexType "]",
133  this->m_objName.toChar(),
134  port
135  );
136  this->m_Time_OutputPort[port].setObjName(portName.toChar());
137 #endif
138  }
139 #endif
140 
141 #if !FW_DIRECT_PORT_CALLS
142  // Connect output port gpioInterrupt
143  for (
144  FwIndexType port = 0;
145  port < static_cast<FwIndexType>(this->getNum_gpioInterrupt_OutputPorts());
146  port++
147  ) {
148  this->m_gpioInterrupt_OutputPort[port].init();
149 
150 #if FW_OBJECT_NAMES == 1
151  Fw::ObjectName portName;
152  portName.format(
153  "%s_gpioInterrupt_OutputPort[%" PRI_FwIndexType "]",
154  this->m_objName.toChar(),
155  port
156  );
157  this->m_gpioInterrupt_OutputPort[port].setObjName(portName.toChar());
158 #endif
159  }
160 #endif
161  }
162 
163 #if !FW_DIRECT_PORT_CALLS
164 
165  // ----------------------------------------------------------------------
166  // Getters for typed input ports
167  // ----------------------------------------------------------------------
168 
171  {
172  FW_ASSERT(
173  (0 <= portNum) && (portNum < this->getNum_gpioRead_InputPorts()),
174  static_cast<FwAssertArgType>(portNum)
175  );
176 
177  return &this->m_gpioRead_InputPort[portNum];
178  }
179 
182  {
183  FW_ASSERT(
184  (0 <= portNum) && (portNum < this->getNum_gpioWrite_InputPorts()),
185  static_cast<FwAssertArgType>(portNum)
186  );
187 
188  return &this->m_gpioWrite_InputPort[portNum];
189  }
190 
191 #endif
192 
193 #if !FW_DIRECT_PORT_CALLS
194 
195  // ----------------------------------------------------------------------
196  // Connect input ports to special output ports
197  // ----------------------------------------------------------------------
198 
201  FwIndexType portNum,
202  Fw::InputLogPort* port
203  )
204  {
205  FW_ASSERT(
206  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
207  static_cast<FwAssertArgType>(portNum)
208  );
209 
210  this->m_Log_OutputPort[portNum].addCallPort(port);
211  }
212 
213 #if FW_ENABLE_TEXT_LOGGING == 1
214 
215  void LinuxGpioDriverComponentBase ::
216  set_LogText_OutputPort(
217  FwIndexType portNum,
219  )
220  {
221  FW_ASSERT(
222  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
223  static_cast<FwAssertArgType>(portNum)
224  );
225 
226  this->m_LogText_OutputPort[portNum].addCallPort(port);
227  }
228 
229 #endif
230 
233  FwIndexType portNum,
234  Fw::InputTimePort* port
235  )
236  {
237  FW_ASSERT(
238  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
239  static_cast<FwAssertArgType>(portNum)
240  );
241 
242  this->m_Time_OutputPort[portNum].addCallPort(port);
243  }
244 
245 #endif
246 
247 #if !FW_DIRECT_PORT_CALLS
248 
249  // ----------------------------------------------------------------------
250  // Connect typed input ports to typed output ports
251  // ----------------------------------------------------------------------
252 
255  FwIndexType portNum,
256  Svc::InputCyclePort* port
257  )
258  {
259  FW_ASSERT(
260  (0 <= portNum) && (portNum < this->getNum_gpioInterrupt_OutputPorts()),
261  static_cast<FwAssertArgType>(portNum)
262  );
263 
264  this->m_gpioInterrupt_OutputPort[portNum].addCallPort(port);
265  }
266 
267 #endif
268 
269 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
270 
271  // ----------------------------------------------------------------------
272  // Connect serial input ports to special output ports
273  // ----------------------------------------------------------------------
274 
277  FwIndexType portNum,
278  Fw::InputSerializePort* port
279  )
280  {
281  FW_ASSERT(
282  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
283  static_cast<FwAssertArgType>(portNum)
284  );
285 
286  this->m_Log_OutputPort[portNum].registerSerialPort(port);
287  }
288 
289 #if FW_ENABLE_TEXT_LOGGING == 1
290 
291  void LinuxGpioDriverComponentBase ::
292  set_LogText_OutputPort(
293  FwIndexType portNum,
294  Fw::InputSerializePort* port
295  )
296  {
297  FW_ASSERT(
298  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
299  static_cast<FwAssertArgType>(portNum)
300  );
301 
302  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
303  }
304 
305 #endif
306 
309  FwIndexType portNum,
310  Fw::InputSerializePort* port
311  )
312  {
313  FW_ASSERT(
314  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
315  static_cast<FwAssertArgType>(portNum)
316  );
317 
318  this->m_Time_OutputPort[portNum].registerSerialPort(port);
319  }
320 
321 #endif
322 
323 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
324 
325  // ----------------------------------------------------------------------
326  // Connect serial input ports to typed output ports
327  // ----------------------------------------------------------------------
328 
331  FwIndexType portNum,
332  Fw::InputSerializePort* port
333  )
334  {
335  FW_ASSERT(
336  (0 <= portNum) && (portNum < this->getNum_gpioInterrupt_OutputPorts()),
337  static_cast<FwAssertArgType>(portNum)
338  );
339 
340  this->m_gpioInterrupt_OutputPort[portNum].registerSerialPort(port);
341  }
342 
343 #endif
344 
345  // ----------------------------------------------------------------------
346  // Component construction and destruction
347  // ----------------------------------------------------------------------
348 
350  LinuxGpioDriverComponentBase(const char* compName) :
351  Fw::PassiveComponentBase(compName)
352  {
353 
354  }
355 
358  {
359 
360  }
361 
362 #if !FW_DIRECT_PORT_CALLS
363 
364  // ----------------------------------------------------------------------
365  // Connection status queries for special output ports
366  // ----------------------------------------------------------------------
367 
370  {
371  FW_ASSERT(
372  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
373  static_cast<FwAssertArgType>(portNum)
374  );
375 
376  return this->m_Log_OutputPort[portNum].isConnected();
377  }
378 
379 #if FW_ENABLE_TEXT_LOGGING == 1
380 
381  bool LinuxGpioDriverComponentBase ::
382  isConnected_LogText_OutputPort(FwIndexType portNum) const
383  {
384  FW_ASSERT(
385  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
386  static_cast<FwAssertArgType>(portNum)
387  );
388 
389  return this->m_LogText_OutputPort[portNum].isConnected();
390  }
391 
392 #endif
393 
396  {
397  FW_ASSERT(
398  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
399  static_cast<FwAssertArgType>(portNum)
400  );
401 
402  return this->m_Time_OutputPort[portNum].isConnected();
403  }
404 
405 #endif
406 
407 #if !FW_DIRECT_PORT_CALLS
408 
409  // ----------------------------------------------------------------------
410  // Connection status queries for typed output ports
411  // ----------------------------------------------------------------------
412 
415  {
416  FW_ASSERT(
417  (0 <= portNum) && (portNum < this->getNum_gpioInterrupt_OutputPorts()),
418  static_cast<FwAssertArgType>(portNum)
419  );
420 
421  return this->m_gpioInterrupt_OutputPort[portNum].isConnected();
422  }
423 
424 #endif
425 
426  // ----------------------------------------------------------------------
427  // Port handler base-class functions for typed input ports
428  //
429  // Call these functions directly to bypass the corresponding ports
430  // ----------------------------------------------------------------------
431 
434  FwIndexType portNum,
435  Fw::Logic& state
436  )
437  {
438  // Make sure port number is valid
439  FW_ASSERT(
440  (0 <= portNum) && (portNum < this->getNum_gpioRead_InputPorts()),
441  static_cast<FwAssertArgType>(portNum)
442  );
443 
444  Drv::GpioStatus retVal;
445 
446  // Call handler function
447  retVal = this->gpioRead_handler(
448  portNum,
449  state
450  );
451 
452  return retVal;
453  }
454 
457  FwIndexType portNum,
458  const Fw::Logic& state
459  )
460  {
461  // Make sure port number is valid
462  FW_ASSERT(
463  (0 <= portNum) && (portNum < this->getNum_gpioWrite_InputPorts()),
464  static_cast<FwAssertArgType>(portNum)
465  );
466 
467  Drv::GpioStatus retVal;
468 
469  // Call handler function
470  retVal = this->gpioWrite_handler(
471  portNum,
472  state
473  );
474 
475  return retVal;
476  }
477 
478 #if !FW_DIRECT_PORT_CALLS
479 
480  // ----------------------------------------------------------------------
481  // Invocation functions for typed output ports
482  // ----------------------------------------------------------------------
483 
486  FwIndexType portNum,
487  Os::RawTime& cycleStart
488  ) const
489  {
490  FW_ASSERT(
491  (0 <= portNum) && (portNum < this->getNum_gpioInterrupt_OutputPorts()),
492  static_cast<FwAssertArgType>(portNum)
493  );
494 
495  FW_ASSERT(
496  this->m_gpioInterrupt_OutputPort[portNum].isConnected(),
497  static_cast<FwAssertArgType>(portNum)
498  );
499  this->m_gpioInterrupt_OutputPort[portNum].invoke(
500  cycleStart
501  );
502  }
503 
504 #endif
505 
506  // ----------------------------------------------------------------------
507  // Event logging functions
508  // ----------------------------------------------------------------------
509 
512  const Fw::StringBase& chip,
513  const Fw::StringBase& chipLabel,
514  U32 pin,
515  const Fw::StringBase& pinMessage
516  ) const
517  {
518  // Get the time
519  Fw::Time _logTime;
520  if (this->isConnected_Time_OutputPort(0)) {
521  this->Time_out(0, _logTime);
522  }
523 
524  const FwEventIdType _id = this->getIdBase() + EVENTID_OPENCHIP;
525 
526  // Emit the event on the log port
527  if (this->isConnected_Log_OutputPort(0)) {
528  Fw::LogBuffer _logBuff;
530 
531 #if FW_AMPCS_COMPATIBLE
532  // Serialize the number of arguments
533  _status = _logBuff.serializeFrom(static_cast<U8>(4));
534  FW_ASSERT(
535  _status == Fw::FW_SERIALIZE_OK,
536  static_cast<FwAssertArgType>(_status)
537  );
538 #endif
539 
540  _status = chip.serializeTo(
541  _logBuff,
542  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), static_cast<FwSizeType>(FW_FIXED_LENGTH_STRING_SIZE))
543  );
544  FW_ASSERT(
545  _status == Fw::FW_SERIALIZE_OK,
546  static_cast<FwAssertArgType>(_status)
547  );
548 
549  _status = chipLabel.serializeTo(
550  _logBuff,
551  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), static_cast<FwSizeType>(FW_FIXED_LENGTH_STRING_SIZE))
552  );
553  FW_ASSERT(
554  _status == Fw::FW_SERIALIZE_OK,
555  static_cast<FwAssertArgType>(_status)
556  );
557 
558 #if FW_AMPCS_COMPATIBLE
559  // Serialize the argument size
560  _status = _logBuff.serializeFrom(
561  static_cast<U8>(sizeof(U32))
562  );
563  FW_ASSERT(
564  _status == Fw::FW_SERIALIZE_OK,
565  static_cast<FwAssertArgType>(_status)
566  );
567 #endif
568  _status = _logBuff.serializeFrom(pin);
569  FW_ASSERT(
570  _status == Fw::FW_SERIALIZE_OK,
571  static_cast<FwAssertArgType>(_status)
572  );
573 
574  _status = pinMessage.serializeTo(
575  _logBuff,
576  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), static_cast<FwSizeType>(FW_FIXED_LENGTH_STRING_SIZE))
577  );
578  FW_ASSERT(
579  _status == Fw::FW_SERIALIZE_OK,
580  static_cast<FwAssertArgType>(_status)
581  );
582 
583  this->Log_out(
584  0,
585  _id,
586  _logTime,
588  _logBuff
589  );
590  }
591 
592  // Emit the event on the text log port
593 #if FW_ENABLE_TEXT_LOGGING
594  if (this->isConnected_LogText_OutputPort(0)) {
595 #if FW_OBJECT_NAMES == 1
596  const char* _formatString =
597  "(%s) %s: Opened GPIO chip %s[%s] pin %" PRIu32 "[%s]";
598 #else
599  const char* _formatString =
600  "%s: Opened GPIO chip %s[%s] pin %" PRIu32 "[%s]";
601 #endif
602 
603  Fw::TextLogString _logString;
604  (void) _logString.format(
605  _formatString,
606 #if FW_OBJECT_NAMES == 1
607  this->m_objName.toChar(),
608 #endif
609  "OpenChip ",
610  chip.toChar(),
611  chipLabel.toChar(),
612  pin,
613  pinMessage.toChar()
614  );
615 
616  this->LogText_out(
617  0,
618  _id,
619  _logTime,
621  _logString
622  );
623  }
624 #endif
625  }
626 
629  const Fw::StringBase& chip,
630  const Os::FileStatus& status
631  ) const
632  {
633  // Get the time
634  Fw::Time _logTime;
635  if (this->isConnected_Time_OutputPort(0)) {
636  this->Time_out(0, _logTime);
637  }
638 
639  const FwEventIdType _id = this->getIdBase() + EVENTID_OPENCHIPERROR;
640 
641  // Emit the event on the log port
642  if (this->isConnected_Log_OutputPort(0)) {
643  Fw::LogBuffer _logBuff;
645 
646 #if FW_AMPCS_COMPATIBLE
647  // Serialize the number of arguments
648  _status = _logBuff.serializeFrom(static_cast<U8>(2));
649  FW_ASSERT(
650  _status == Fw::FW_SERIALIZE_OK,
651  static_cast<FwAssertArgType>(_status)
652  );
653 #endif
654 
655  _status = chip.serializeTo(
656  _logBuff,
657  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), static_cast<FwSizeType>(FW_FIXED_LENGTH_STRING_SIZE))
658  );
659  FW_ASSERT(
660  _status == Fw::FW_SERIALIZE_OK,
661  static_cast<FwAssertArgType>(_status)
662  );
663 
664 #if FW_AMPCS_COMPATIBLE
665  // Serialize the argument size
666  _status = _logBuff.serializeFrom(
667  static_cast<U8>(Os::FileStatus::SERIALIZED_SIZE)
668  );
669  FW_ASSERT(
670  _status == Fw::FW_SERIALIZE_OK,
671  static_cast<FwAssertArgType>(_status)
672  );
673 #endif
674  _status = _logBuff.serializeFrom(status);
675  FW_ASSERT(
676  _status == Fw::FW_SERIALIZE_OK,
677  static_cast<FwAssertArgType>(_status)
678  );
679 
680  this->Log_out(
681  0,
682  _id,
683  _logTime,
685  _logBuff
686  );
687  }
688 
689  // Emit the event on the text log port
690 #if FW_ENABLE_TEXT_LOGGING
691  if (this->isConnected_LogText_OutputPort(0)) {
692 #if FW_OBJECT_NAMES == 1
693  const char* _formatString =
694  "(%s) %s: Failed to open GPIO chip %s: %s";
695 #else
696  const char* _formatString =
697  "%s: Failed to open GPIO chip %s: %s";
698 #endif
699 
700  Fw::String statusStr;
701  status.toString(statusStr);
702 
703  Fw::TextLogString _logString;
704  (void) _logString.format(
705  _formatString,
706 #if FW_OBJECT_NAMES == 1
707  this->m_objName.toChar(),
708 #endif
709  "OpenChipError ",
710  chip.toChar(),
711  statusStr.toChar()
712  );
713 
714  this->LogText_out(
715  0,
716  _id,
717  _logTime,
719  _logString
720  );
721  }
722 #endif
723  }
724 
727  const Fw::StringBase& chip,
728  U32 pin,
729  const Fw::StringBase& pinMessage,
730  const Os::FileStatus& status
731  ) const
732  {
733  // Get the time
734  Fw::Time _logTime;
735  if (this->isConnected_Time_OutputPort(0)) {
736  this->Time_out(0, _logTime);
737  }
738 
739  const FwEventIdType _id = this->getIdBase() + EVENTID_OPENPINERROR;
740 
741  // Emit the event on the log port
742  if (this->isConnected_Log_OutputPort(0)) {
743  Fw::LogBuffer _logBuff;
745 
746 #if FW_AMPCS_COMPATIBLE
747  // Serialize the number of arguments
748  _status = _logBuff.serializeFrom(static_cast<U8>(4));
749  FW_ASSERT(
750  _status == Fw::FW_SERIALIZE_OK,
751  static_cast<FwAssertArgType>(_status)
752  );
753 #endif
754 
755  _status = chip.serializeTo(
756  _logBuff,
757  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), static_cast<FwSizeType>(FW_FIXED_LENGTH_STRING_SIZE))
758  );
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.serializeFrom(
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.serializeFrom(pin);
775  FW_ASSERT(
776  _status == Fw::FW_SERIALIZE_OK,
777  static_cast<FwAssertArgType>(_status)
778  );
779 
780  _status = pinMessage.serializeTo(
781  _logBuff,
782  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), static_cast<FwSizeType>(FW_FIXED_LENGTH_STRING_SIZE))
783  );
784  FW_ASSERT(
785  _status == Fw::FW_SERIALIZE_OK,
786  static_cast<FwAssertArgType>(_status)
787  );
788 
789 #if FW_AMPCS_COMPATIBLE
790  // Serialize the argument size
791  _status = _logBuff.serializeFrom(
792  static_cast<U8>(Os::FileStatus::SERIALIZED_SIZE)
793  );
794  FW_ASSERT(
795  _status == Fw::FW_SERIALIZE_OK,
796  static_cast<FwAssertArgType>(_status)
797  );
798 #endif
799  _status = _logBuff.serializeFrom(status);
800  FW_ASSERT(
801  _status == Fw::FW_SERIALIZE_OK,
802  static_cast<FwAssertArgType>(_status)
803  );
804 
805  this->Log_out(
806  0,
807  _id,
808  _logTime,
810  _logBuff
811  );
812  }
813 
814  // Emit the event on the text log port
815 #if FW_ENABLE_TEXT_LOGGING
816  if (this->isConnected_LogText_OutputPort(0)) {
817 #if FW_OBJECT_NAMES == 1
818  const char* _formatString =
819  "(%s) %s: Failed to open GPIO chip %s pin %" PRIu32 " [%s]: %s";
820 #else
821  const char* _formatString =
822  "%s: Failed to open GPIO chip %s pin %" PRIu32 " [%s]: %s";
823 #endif
824 
825  Fw::String statusStr;
826  status.toString(statusStr);
827 
828  Fw::TextLogString _logString;
829  (void) _logString.format(
830  _formatString,
831 #if FW_OBJECT_NAMES == 1
832  this->m_objName.toChar(),
833 #endif
834  "OpenPinError ",
835  chip.toChar(),
836  pin,
837  pinMessage.toChar(),
838  statusStr.toChar()
839  );
840 
841  this->LogText_out(
842  0,
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->isConnected_Time_OutputPort(0)) {
861  this->Time_out(0, _logTime);
862  }
863 
864  const FwEventIdType _id = this->getIdBase() + EVENTID_INTERRUPTREADERROR;
865 
866  // Emit the event on the log port
867  if (this->isConnected_Log_OutputPort(0)) {
868  Fw::LogBuffer _logBuff;
870 
871 #if FW_AMPCS_COMPATIBLE
872  // Serialize the number of arguments
873  _status = _logBuff.serializeFrom(static_cast<U8>(2));
874  FW_ASSERT(
875  _status == Fw::FW_SERIALIZE_OK,
876  static_cast<FwAssertArgType>(_status)
877  );
878 #endif
879 
880 #if FW_AMPCS_COMPATIBLE
881  // Serialize the argument size
882  _status = _logBuff.serializeFrom(
883  static_cast<U8>(sizeof(U32))
884  );
885  FW_ASSERT(
886  _status == Fw::FW_SERIALIZE_OK,
887  static_cast<FwAssertArgType>(_status)
888  );
889 #endif
890  _status = _logBuff.serializeFrom(expected);
891  FW_ASSERT(
892  _status == Fw::FW_SERIALIZE_OK,
893  static_cast<FwAssertArgType>(_status)
894  );
895 
896 #if FW_AMPCS_COMPATIBLE
897  // Serialize the argument size
898  _status = _logBuff.serializeFrom(
899  static_cast<U8>(sizeof(U32))
900  );
901  FW_ASSERT(
902  _status == Fw::FW_SERIALIZE_OK,
903  static_cast<FwAssertArgType>(_status)
904  );
905 #endif
906  _status = _logBuff.serializeFrom(got);
907  FW_ASSERT(
908  _status == Fw::FW_SERIALIZE_OK,
909  static_cast<FwAssertArgType>(_status)
910  );
911 
912  this->Log_out(
913  0,
914  _id,
915  _logTime,
917  _logBuff
918  );
919  }
920 
921  // Emit the event on the text log port
922 #if FW_ENABLE_TEXT_LOGGING
923  if (this->isConnected_LogText_OutputPort(0)) {
924 #if FW_OBJECT_NAMES == 1
925  const char* _formatString =
926  "(%s) %s: Interrupt data read expected %" PRIu32 " byes and got %" PRIu32 "";
927 #else
928  const char* _formatString =
929  "%s: Interrupt data read expected %" PRIu32 " byes and got %" PRIu32 "";
930 #endif
931 
932  Fw::TextLogString _logString;
933  (void) _logString.format(
934  _formatString,
935 #if FW_OBJECT_NAMES == 1
936  this->m_objName.toChar(),
937 #endif
938  "InterruptReadError ",
939  expected,
940  got
941  );
942 
943  this->LogText_out(
944  0,
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->isConnected_Time_OutputPort(0)) {
960  this->Time_out(0, _logTime);
961  }
962 
963  const FwEventIdType _id = this->getIdBase() + EVENTID_POLLINGERROR;
964 
965  // Emit the event on the log port
966  if (this->isConnected_Log_OutputPort(0)) {
967  Fw::LogBuffer _logBuff;
969 
970 #if FW_AMPCS_COMPATIBLE
971  // Serialize the number of arguments
972  _status = _logBuff.serializeFrom(static_cast<U8>(1));
973  FW_ASSERT(
974  _status == Fw::FW_SERIALIZE_OK,
975  static_cast<FwAssertArgType>(_status)
976  );
977 #endif
978 
979 #if FW_AMPCS_COMPATIBLE
980  // Serialize the argument size
981  _status = _logBuff.serializeFrom(
982  static_cast<U8>(sizeof(I32))
983  );
984  FW_ASSERT(
985  _status == Fw::FW_SERIALIZE_OK,
986  static_cast<FwAssertArgType>(_status)
987  );
988 #endif
989  _status = _logBuff.serializeFrom(error_number);
990  FW_ASSERT(
991  _status == Fw::FW_SERIALIZE_OK,
992  static_cast<FwAssertArgType>(_status)
993  );
994 
995  this->Log_out(
996  0,
997  _id,
998  _logTime,
1000  _logBuff
1001  );
1002  }
1003 
1004  // Emit the event on the text log port
1005 #if FW_ENABLE_TEXT_LOGGING
1006  if (this->isConnected_LogText_OutputPort(0)) {
1007 #if FW_OBJECT_NAMES == 1
1008  const char* _formatString =
1009  "(%s) %s: Interrupt polling returned errno: %" PRIi32 "";
1010 #else
1011  const char* _formatString =
1012  "%s: Interrupt polling returned errno: %" PRIi32 "";
1013 #endif
1014 
1015  Fw::TextLogString _logString;
1016  (void) _logString.format(
1017  _formatString,
1018 #if FW_OBJECT_NAMES == 1
1019  this->m_objName.toChar(),
1020 #endif
1021  "PollingError ",
1022  error_number
1023  );
1024 
1025  this->LogText_out(
1026  0,
1027  _id,
1028  _logTime,
1030  _logString
1031  );
1032  }
1033 #endif
1034  }
1035 
1038  {
1039  // Get the time
1040  Fw::Time _logTime;
1041  if (this->isConnected_Time_OutputPort(0)) {
1042  this->Time_out(0, _logTime);
1043  }
1044 
1045  const FwEventIdType _id = this->getIdBase() + EVENTID_INTERRUPTTIMEERROR;
1046 
1047  // Emit the event on the log port
1048  if (this->isConnected_Log_OutputPort(0)) {
1049  Fw::LogBuffer _logBuff;
1051 
1052 #if FW_AMPCS_COMPATIBLE
1053  // Serialize the number of arguments
1054  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1055  FW_ASSERT(
1056  _status == Fw::FW_SERIALIZE_OK,
1057  static_cast<FwAssertArgType>(_status)
1058  );
1059 #endif
1060 
1061 #if FW_AMPCS_COMPATIBLE
1062  // Serialize the argument size
1063  _status = _logBuff.serializeFrom(
1064  static_cast<U8>(Os::RawTimeStatus::SERIALIZED_SIZE)
1065  );
1066  FW_ASSERT(
1067  _status == Fw::FW_SERIALIZE_OK,
1068  static_cast<FwAssertArgType>(_status)
1069  );
1070 #endif
1071  _status = _logBuff.serializeFrom(status);
1072  FW_ASSERT(
1073  _status == Fw::FW_SERIALIZE_OK,
1074  static_cast<FwAssertArgType>(_status)
1075  );
1076 
1077  this->Log_out(
1078  0,
1079  _id,
1080  _logTime,
1082  _logBuff
1083  );
1084  }
1085 
1086  // Emit the event on the text log port
1087 #if FW_ENABLE_TEXT_LOGGING
1088  if (this->isConnected_LogText_OutputPort(0)) {
1089 #if FW_OBJECT_NAMES == 1
1090  const char* _formatString =
1091  "(%s) %s: Failed to read interrupt timestamp: %s";
1092 #else
1093  const char* _formatString =
1094  "%s: Failed to read interrupt timestamp: %s";
1095 #endif
1096 
1097  Fw::String statusStr;
1098  status.toString(statusStr);
1099 
1100  Fw::TextLogString _logString;
1101  (void) _logString.format(
1102  _formatString,
1103 #if FW_OBJECT_NAMES == 1
1104  this->m_objName.toChar(),
1105 #endif
1106  "InterruptTimeError ",
1107  statusStr.toChar()
1108  );
1109 
1110  this->LogText_out(
1111  0,
1112  _id,
1113  _logTime,
1115  _logString
1116  );
1117  }
1118 #endif
1119  }
1120 
1121  // ----------------------------------------------------------------------
1122  // Time
1123  // ----------------------------------------------------------------------
1124 
1126  getTime() const
1127  {
1128  if (this->isConnected_Time_OutputPort(0)) {
1129  Fw::Time _time;
1130  this->Time_out(0, _time);
1131  return _time;
1132  }
1133  else {
1134  return Fw::Time(TimeBase::TB_NONE, 0, 0);
1135  }
1136  }
1137 
1138  // ----------------------------------------------------------------------
1139  // Calls for messages received on typed input ports
1140  // ----------------------------------------------------------------------
1141 
1142  Drv::GpioStatus LinuxGpioDriverComponentBase ::
1143  m_p_gpioRead_in(
1144  Fw::PassiveComponentBase* callComp,
1145  FwIndexType portNum,
1146  Fw::Logic& state
1147  )
1148  {
1149  FW_ASSERT(callComp != nullptr);
1150  LinuxGpioDriverComponentBase* compPtr = static_cast<LinuxGpioDriverComponentBase*>(callComp);
1151  return compPtr->gpioRead_handlerBase(
1152  portNum,
1153  state
1154  );
1155  }
1156 
1157  Drv::GpioStatus LinuxGpioDriverComponentBase ::
1158  m_p_gpioWrite_in(
1159  Fw::PassiveComponentBase* callComp,
1160  FwIndexType portNum,
1161  const Fw::Logic& state
1162  )
1163  {
1164  FW_ASSERT(callComp != nullptr);
1165  LinuxGpioDriverComponentBase* compPtr = static_cast<LinuxGpioDriverComponentBase*>(callComp);
1166  return compPtr->gpioWrite_handlerBase(
1167  portNum,
1168  state
1169  );
1170  }
1171 
1172 #if !FW_DIRECT_PORT_CALLS
1173 
1174  // ----------------------------------------------------------------------
1175  // Invocation functions for special output ports
1176  // ----------------------------------------------------------------------
1177 
1178  void LinuxGpioDriverComponentBase ::
1179  Log_out(
1180  FwIndexType portNum,
1181  FwEventIdType id,
1182  Fw::Time& timeTag,
1183  const Fw::LogSeverity& severity,
1184  Fw::LogBuffer& args
1185  ) const
1186  {
1187  FW_ASSERT(
1188  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
1189  static_cast<FwAssertArgType>(portNum)
1190  );
1191 
1192  FW_ASSERT(
1193  this->m_Log_OutputPort[portNum].isConnected(),
1194  static_cast<FwAssertArgType>(portNum)
1195  );
1196  this->m_Log_OutputPort[portNum].invoke(
1197  id,
1198  timeTag,
1199  severity,
1200  args
1201  );
1202  }
1203 
1204 #if FW_ENABLE_TEXT_LOGGING
1205 
1206  void LinuxGpioDriverComponentBase ::
1207  LogText_out(
1208  FwIndexType portNum,
1209  FwEventIdType id,
1210  Fw::Time& timeTag,
1211  const Fw::LogSeverity& severity,
1212  Fw::TextLogString& text
1213  ) const
1214  {
1215  FW_ASSERT(
1216  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
1217  static_cast<FwAssertArgType>(portNum)
1218  );
1219 
1220  FW_ASSERT(
1221  this->m_LogText_OutputPort[portNum].isConnected(),
1222  static_cast<FwAssertArgType>(portNum)
1223  );
1224  this->m_LogText_OutputPort[portNum].invoke(
1225  id,
1226  timeTag,
1227  severity,
1228  text
1229  );
1230  }
1231 
1232 #endif
1233 
1234  void LinuxGpioDriverComponentBase ::
1235  Time_out(
1236  FwIndexType portNum,
1237  Fw::Time& time
1238  ) const
1239  {
1240  FW_ASSERT(
1241  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
1242  static_cast<FwAssertArgType>(portNum)
1243  );
1244 
1245  FW_ASSERT(
1246  this->m_Time_OutputPort[portNum].isConnected(),
1247  static_cast<FwAssertArgType>(portNum)
1248  );
1249  this->m_Time_OutputPort[portNum].invoke(
1250  time
1251  );
1252  }
1253 
1254 #endif
1255 
1256 }
Serialization/Deserialization operation was successful.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
Drv::InputGpioReadPort * get_gpioRead_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_Time_OutputPorts()
Drv::InputGpioWritePort * get_gpioWrite_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_gpioRead_InputPorts()
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
void log_WARNING_HI_OpenChipError(const Fw::StringBase &chip, const Os::FileStatus &status) const
Log event OpenChipError.
FPP shadow-enum representing Os::RawTime::Status.
I32 FwEnumStoreType
void init()
Initialization function.
void log_WARNING_HI_InterruptReadError(U32 expected, U32 got) const
Log event InterruptReadError.
LinuxGpioDriverComponentBase(const char *compName="")
Construct LinuxGpioDriverComponentBase object.
The size of the serial representation.
void gpioInterrupt_out(FwIndexType portNum, Os::RawTime &cycleStart) const
Invoke output port gpioInterrupt.
The size of the serial representation.
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.
static constexpr FwIndexType getNum_gpioInterrupt_OutputPorts()
virtual const CHAR * toChar() const =0
Convert to a C-style char*.
virtual Drv::GpioStatus gpioWrite_handler(FwIndexType portNum, const Fw::Logic &state)=0
Handler for input port gpioWrite.
No time base has been established (Required)
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:24
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
bool isConnected_Log_OutputPort(FwIndexType portNum) const
Drv::GpioStatus gpioRead_handlerBase(FwIndexType portNum, Fw::Logic &state)
Handler base-class function for input port gpioRead.
SerializeStatus
forward declaration for string
void addCallPort(InputCyclePort *callPort)
Register an input port.
static constexpr FwIndexType getNum_gpioWrite_InputPorts()
FwIdType FwEventIdType
The type of an event identifier.
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:40
Auto-generated base for LinuxGpioDriver component.
void init()
Initialization function.
Definition: TimePortAc.cpp:151
static constexpr FwIndexType getNum_Log_OutputPorts()
#define FW_MIN(a, b)
MIN macro (deprecated in C++, use std::min)
Definition: BasicTypes.h:99
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void log_WARNING_HI_OpenPinError(const Fw::StringBase &chip, U32 pin, const Fw::StringBase &pinMessage, const Os::FileStatus &status) const
Log event OpenPinError.
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 addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
A serious but recoverable event.
const char * toChar() const
Convert to a C-style char*.
bool isConnected() const
Definition: PortBase.cpp:38
Enum representing event severity.
#define PRI_FwIndexType
Input GpioRead port.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
void init()
Initialization function.
Definition: LogPortAc.cpp:180
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 connection.
Definition: LogPortAc.cpp:199
PlatformIndexType FwIndexType
void log_WARNING_HI_PollingError(I32 error_number) const
Log event PollingError.
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:186
bool isConnected_Time_OutputPort(FwIndexType portNum) const
Logic states.
Definition: LogicEnumAc.hpp:18
void log_WARNING_HI_InterruptTimeError(const Os::RawTimeStatus &status) const
Log event InterruptTimeError.
void invoke(Os::RawTime &cycleStart) const
Invoke a port connection.
Implementation of malloc based allocator.
virtual ~LinuxGpioDriverComponentBase()
Destroy LinuxGpioDriverComponentBase object.
FPP shadow-enum representing Os::File::Status.
bool isConnected_gpioInterrupt_OutputPort(FwIndexType portNum) const
#define FW_ASSERT(...)
Definition: Assert.hpp:14
SerializeStatus serializeTo(SerialBufferBase &buffer, Endianness mode=Endianness::BIG) const override
Serialize the contents of this object to a buffer.