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  // Connection status queries for special output ports
342  // ----------------------------------------------------------------------
343 
346  {
347  FW_ASSERT(
348  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
349  static_cast<FwAssertArgType>(portNum)
350  );
351 
352  return this->m_Log_OutputPort[portNum].isConnected();
353  }
354 
355 #if FW_ENABLE_TEXT_LOGGING == 1
356 
357  bool LinuxGpioDriverComponentBase ::
358  isConnected_LogText_OutputPort(FwIndexType portNum)
359  {
360  FW_ASSERT(
361  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
362  static_cast<FwAssertArgType>(portNum)
363  );
364 
365  return this->m_LogText_OutputPort[portNum].isConnected();
366  }
367 
368 #endif
369 
372  {
373  FW_ASSERT(
374  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
375  static_cast<FwAssertArgType>(portNum)
376  );
377 
378  return this->m_Time_OutputPort[portNum].isConnected();
379  }
380 
381  // ----------------------------------------------------------------------
382  // Connection status queries for typed output ports
383  // ----------------------------------------------------------------------
384 
387  {
388  FW_ASSERT(
389  (0 <= portNum) && (portNum < this->getNum_gpioInterrupt_OutputPorts()),
390  static_cast<FwAssertArgType>(portNum)
391  );
392 
393  return this->m_gpioInterrupt_OutputPort[portNum].isConnected();
394  }
395 
396  // ----------------------------------------------------------------------
397  // Port handler base-class functions for typed input ports
398  //
399  // Call these functions directly to bypass the corresponding ports
400  // ----------------------------------------------------------------------
401 
404  FwIndexType portNum,
405  Fw::Logic& state
406  )
407  {
408  // Make sure port number is valid
409  FW_ASSERT(
410  (0 <= portNum) && (portNum < this->getNum_gpioRead_InputPorts()),
411  static_cast<FwAssertArgType>(portNum)
412  );
413 
414  Drv::GpioStatus retVal;
415 
416  // Call handler function
417  retVal = this->gpioRead_handler(
418  portNum,
419  state
420  );
421 
422  return retVal;
423  }
424 
427  FwIndexType portNum,
428  const Fw::Logic& state
429  )
430  {
431  // Make sure port number is valid
432  FW_ASSERT(
433  (0 <= portNum) && (portNum < this->getNum_gpioWrite_InputPorts()),
434  static_cast<FwAssertArgType>(portNum)
435  );
436 
437  Drv::GpioStatus retVal;
438 
439  // Call handler function
440  retVal = this->gpioWrite_handler(
441  portNum,
442  state
443  );
444 
445  return retVal;
446  }
447 
448  // ----------------------------------------------------------------------
449  // Invocation functions for typed output ports
450  // ----------------------------------------------------------------------
451 
454  FwIndexType portNum,
455  Os::RawTime& cycleStart
456  )
457  {
458  FW_ASSERT(
459  (0 <= portNum) && (portNum < this->getNum_gpioInterrupt_OutputPorts()),
460  static_cast<FwAssertArgType>(portNum)
461  );
462 
463  FW_ASSERT(
464  this->m_gpioInterrupt_OutputPort[portNum].isConnected(),
465  static_cast<FwAssertArgType>(portNum)
466  );
467  this->m_gpioInterrupt_OutputPort[portNum].invoke(
468  cycleStart
469  );
470  }
471 
472  // ----------------------------------------------------------------------
473  // Event logging functions
474  // ----------------------------------------------------------------------
475 
478  const Fw::StringBase& chip,
479  const Fw::StringBase& chipLabel,
480  U32 pin,
481  const Fw::StringBase& pinMessage
482  ) const
483  {
484  // Get the time
485  Fw::Time _logTime;
486  if (this->m_Time_OutputPort[0].isConnected()) {
487  this->m_Time_OutputPort[0].invoke(_logTime);
488  }
489 
490  FwEventIdType _id = static_cast<FwEventIdType>(0);
491 
492  _id = this->getIdBase() + EVENTID_OPENCHIP;
493 
494  // Emit the event on the log port
495  if (this->m_Log_OutputPort[0].isConnected()) {
496  Fw::LogBuffer _logBuff;
498 
499 #if FW_AMPCS_COMPATIBLE
500  // Serialize the number of arguments
501  _status = _logBuff.serializeFrom(static_cast<U8>(4));
502  FW_ASSERT(
503  _status == Fw::FW_SERIALIZE_OK,
504  static_cast<FwAssertArgType>(_status)
505  );
506 #endif
507 
508  _status = chip.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
509  FW_ASSERT(
510  _status == Fw::FW_SERIALIZE_OK,
511  static_cast<FwAssertArgType>(_status)
512  );
513 
514  _status = chipLabel.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
515  FW_ASSERT(
516  _status == Fw::FW_SERIALIZE_OK,
517  static_cast<FwAssertArgType>(_status)
518  );
519 
520 #if FW_AMPCS_COMPATIBLE
521  // Serialize the argument size
522  _status = _logBuff.serializeFrom(
523  static_cast<U8>(sizeof(U32))
524  );
525  FW_ASSERT(
526  _status == Fw::FW_SERIALIZE_OK,
527  static_cast<FwAssertArgType>(_status)
528  );
529 #endif
530  _status = _logBuff.serializeFrom(pin);
531  FW_ASSERT(
532  _status == Fw::FW_SERIALIZE_OK,
533  static_cast<FwAssertArgType>(_status)
534  );
535 
536  _status = pinMessage.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
537  FW_ASSERT(
538  _status == Fw::FW_SERIALIZE_OK,
539  static_cast<FwAssertArgType>(_status)
540  );
541 
542  this->m_Log_OutputPort[0].invoke(
543  _id,
544  _logTime,
546  _logBuff
547  );
548  }
549 
550  // Emit the event on the text log port
551 #if FW_ENABLE_TEXT_LOGGING
552  if (this->m_LogText_OutputPort[0].isConnected()) {
553 #if FW_OBJECT_NAMES == 1
554  const char* _formatString =
555  "(%s) %s: Opened GPIO chip %s[%s] pin %" PRIu32 "[%s]";
556 #else
557  const char* _formatString =
558  "%s: Opened GPIO chip %s[%s] pin %" PRIu32 "[%s]";
559 #endif
560 
561  Fw::TextLogString _logString;
562  _logString.format(
563  _formatString,
564 #if FW_OBJECT_NAMES == 1
565  this->m_objName.toChar(),
566 #endif
567  "OpenChip ",
568  chip.toChar(),
569  chipLabel.toChar(),
570  pin,
571  pinMessage.toChar()
572  );
573 
574  this->m_LogText_OutputPort[0].invoke(
575  _id,
576  _logTime,
578  _logString
579  );
580  }
581 #endif
582  }
583 
586  const Fw::StringBase& chip,
587  Os::FileStatus status
588  ) const
589  {
590  // Get the time
591  Fw::Time _logTime;
592  if (this->m_Time_OutputPort[0].isConnected()) {
593  this->m_Time_OutputPort[0].invoke(_logTime);
594  }
595 
596  FwEventIdType _id = static_cast<FwEventIdType>(0);
597 
598  _id = this->getIdBase() + EVENTID_OPENCHIPERROR;
599 
600  // Emit the event on the log port
601  if (this->m_Log_OutputPort[0].isConnected()) {
602  Fw::LogBuffer _logBuff;
604 
605 #if FW_AMPCS_COMPATIBLE
606  // Serialize the number of arguments
607  _status = _logBuff.serializeFrom(static_cast<U8>(2));
608  FW_ASSERT(
609  _status == Fw::FW_SERIALIZE_OK,
610  static_cast<FwAssertArgType>(_status)
611  );
612 #endif
613 
614  _status = chip.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
615  FW_ASSERT(
616  _status == Fw::FW_SERIALIZE_OK,
617  static_cast<FwAssertArgType>(_status)
618  );
619 
620 #if FW_AMPCS_COMPATIBLE
621  // Serialize the argument size
622  _status = _logBuff.serializeFrom(
623  static_cast<U8>(Os::FileStatus::SERIALIZED_SIZE)
624  );
625  FW_ASSERT(
626  _status == Fw::FW_SERIALIZE_OK,
627  static_cast<FwAssertArgType>(_status)
628  );
629 #endif
630  _status = _logBuff.serializeFrom(status);
631  FW_ASSERT(
632  _status == Fw::FW_SERIALIZE_OK,
633  static_cast<FwAssertArgType>(_status)
634  );
635 
636  this->m_Log_OutputPort[0].invoke(
637  _id,
638  _logTime,
640  _logBuff
641  );
642  }
643 
644  // Emit the event on the text log port
645 #if FW_ENABLE_TEXT_LOGGING
646  if (this->m_LogText_OutputPort[0].isConnected()) {
647 #if FW_OBJECT_NAMES == 1
648  const char* _formatString =
649  "(%s) %s: Failed to open GPIO chip %s: %s";
650 #else
651  const char* _formatString =
652  "%s: Failed to open GPIO chip %s: %s";
653 #endif
654 
655  Fw::String statusStr;
656  status.toString(statusStr);
657 
658  Fw::TextLogString _logString;
659  _logString.format(
660  _formatString,
661 #if FW_OBJECT_NAMES == 1
662  this->m_objName.toChar(),
663 #endif
664  "OpenChipError ",
665  chip.toChar(),
666  statusStr.toChar()
667  );
668 
669  this->m_LogText_OutputPort[0].invoke(
670  _id,
671  _logTime,
673  _logString
674  );
675  }
676 #endif
677  }
678 
681  const Fw::StringBase& chip,
682  U32 pin,
683  const Fw::StringBase& pinMessage,
684  Os::FileStatus status
685  ) const
686  {
687  // Get the time
688  Fw::Time _logTime;
689  if (this->m_Time_OutputPort[0].isConnected()) {
690  this->m_Time_OutputPort[0].invoke(_logTime);
691  }
692 
693  FwEventIdType _id = static_cast<FwEventIdType>(0);
694 
695  _id = this->getIdBase() + EVENTID_OPENPINERROR;
696 
697  // Emit the event on the log port
698  if (this->m_Log_OutputPort[0].isConnected()) {
699  Fw::LogBuffer _logBuff;
701 
702 #if FW_AMPCS_COMPATIBLE
703  // Serialize the number of arguments
704  _status = _logBuff.serializeFrom(static_cast<U8>(4));
705  FW_ASSERT(
706  _status == Fw::FW_SERIALIZE_OK,
707  static_cast<FwAssertArgType>(_status)
708  );
709 #endif
710 
711  _status = chip.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
712  FW_ASSERT(
713  _status == Fw::FW_SERIALIZE_OK,
714  static_cast<FwAssertArgType>(_status)
715  );
716 
717 #if FW_AMPCS_COMPATIBLE
718  // Serialize the argument size
719  _status = _logBuff.serializeFrom(
720  static_cast<U8>(sizeof(U32))
721  );
722  FW_ASSERT(
723  _status == Fw::FW_SERIALIZE_OK,
724  static_cast<FwAssertArgType>(_status)
725  );
726 #endif
727  _status = _logBuff.serializeFrom(pin);
728  FW_ASSERT(
729  _status == Fw::FW_SERIALIZE_OK,
730  static_cast<FwAssertArgType>(_status)
731  );
732 
733  _status = pinMessage.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
734  FW_ASSERT(
735  _status == Fw::FW_SERIALIZE_OK,
736  static_cast<FwAssertArgType>(_status)
737  );
738 
739 #if FW_AMPCS_COMPATIBLE
740  // Serialize the argument size
741  _status = _logBuff.serializeFrom(
742  static_cast<U8>(Os::FileStatus::SERIALIZED_SIZE)
743  );
744  FW_ASSERT(
745  _status == Fw::FW_SERIALIZE_OK,
746  static_cast<FwAssertArgType>(_status)
747  );
748 #endif
749  _status = _logBuff.serializeFrom(status);
750  FW_ASSERT(
751  _status == Fw::FW_SERIALIZE_OK,
752  static_cast<FwAssertArgType>(_status)
753  );
754 
755  this->m_Log_OutputPort[0].invoke(
756  _id,
757  _logTime,
759  _logBuff
760  );
761  }
762 
763  // Emit the event on the text log port
764 #if FW_ENABLE_TEXT_LOGGING
765  if (this->m_LogText_OutputPort[0].isConnected()) {
766 #if FW_OBJECT_NAMES == 1
767  const char* _formatString =
768  "(%s) %s: Failed to open GPIO chip %s pin %" PRIu32 " [%s]: %s";
769 #else
770  const char* _formatString =
771  "%s: Failed to open GPIO chip %s pin %" PRIu32 " [%s]: %s";
772 #endif
773 
774  Fw::String statusStr;
775  status.toString(statusStr);
776 
777  Fw::TextLogString _logString;
778  _logString.format(
779  _formatString,
780 #if FW_OBJECT_NAMES == 1
781  this->m_objName.toChar(),
782 #endif
783  "OpenPinError ",
784  chip.toChar(),
785  pin,
786  pinMessage.toChar(),
787  statusStr.toChar()
788  );
789 
790  this->m_LogText_OutputPort[0].invoke(
791  _id,
792  _logTime,
794  _logString
795  );
796  }
797 #endif
798  }
799 
802  U32 expected,
803  U32 got
804  ) const
805  {
806  // Get the time
807  Fw::Time _logTime;
808  if (this->m_Time_OutputPort[0].isConnected()) {
809  this->m_Time_OutputPort[0].invoke(_logTime);
810  }
811 
812  FwEventIdType _id = static_cast<FwEventIdType>(0);
813 
814  _id = this->getIdBase() + EVENTID_INTERRUPTREADERROR;
815 
816  // Emit the event on the log port
817  if (this->m_Log_OutputPort[0].isConnected()) {
818  Fw::LogBuffer _logBuff;
820 
821 #if FW_AMPCS_COMPATIBLE
822  // Serialize the number of arguments
823  _status = _logBuff.serializeFrom(static_cast<U8>(2));
824  FW_ASSERT(
825  _status == Fw::FW_SERIALIZE_OK,
826  static_cast<FwAssertArgType>(_status)
827  );
828 #endif
829 
830 #if FW_AMPCS_COMPATIBLE
831  // Serialize the argument size
832  _status = _logBuff.serializeFrom(
833  static_cast<U8>(sizeof(U32))
834  );
835  FW_ASSERT(
836  _status == Fw::FW_SERIALIZE_OK,
837  static_cast<FwAssertArgType>(_status)
838  );
839 #endif
840  _status = _logBuff.serializeFrom(expected);
841  FW_ASSERT(
842  _status == Fw::FW_SERIALIZE_OK,
843  static_cast<FwAssertArgType>(_status)
844  );
845 
846 #if FW_AMPCS_COMPATIBLE
847  // Serialize the argument size
848  _status = _logBuff.serializeFrom(
849  static_cast<U8>(sizeof(U32))
850  );
851  FW_ASSERT(
852  _status == Fw::FW_SERIALIZE_OK,
853  static_cast<FwAssertArgType>(_status)
854  );
855 #endif
856  _status = _logBuff.serializeFrom(got);
857  FW_ASSERT(
858  _status == Fw::FW_SERIALIZE_OK,
859  static_cast<FwAssertArgType>(_status)
860  );
861 
862  this->m_Log_OutputPort[0].invoke(
863  _id,
864  _logTime,
866  _logBuff
867  );
868  }
869 
870  // Emit the event on the text log port
871 #if FW_ENABLE_TEXT_LOGGING
872  if (this->m_LogText_OutputPort[0].isConnected()) {
873 #if FW_OBJECT_NAMES == 1
874  const char* _formatString =
875  "(%s) %s: Interrupt data read expected %" PRIu32 " byes and got %" PRIu32 "";
876 #else
877  const char* _formatString =
878  "%s: Interrupt data read expected %" PRIu32 " byes and got %" PRIu32 "";
879 #endif
880 
881  Fw::TextLogString _logString;
882  _logString.format(
883  _formatString,
884 #if FW_OBJECT_NAMES == 1
885  this->m_objName.toChar(),
886 #endif
887  "InterruptReadError ",
888  expected,
889  got
890  );
891 
892  this->m_LogText_OutputPort[0].invoke(
893  _id,
894  _logTime,
896  _logString
897  );
898  }
899 #endif
900  }
901 
903  log_WARNING_HI_PollingError(I32 error_number) const
904  {
905  // Get the time
906  Fw::Time _logTime;
907  if (this->m_Time_OutputPort[0].isConnected()) {
908  this->m_Time_OutputPort[0].invoke(_logTime);
909  }
910 
911  FwEventIdType _id = static_cast<FwEventIdType>(0);
912 
913  _id = this->getIdBase() + EVENTID_POLLINGERROR;
914 
915  // Emit the event on the log port
916  if (this->m_Log_OutputPort[0].isConnected()) {
917  Fw::LogBuffer _logBuff;
919 
920 #if FW_AMPCS_COMPATIBLE
921  // Serialize the number of arguments
922  _status = _logBuff.serializeFrom(static_cast<U8>(1));
923  FW_ASSERT(
924  _status == Fw::FW_SERIALIZE_OK,
925  static_cast<FwAssertArgType>(_status)
926  );
927 #endif
928 
929 #if FW_AMPCS_COMPATIBLE
930  // Serialize the argument size
931  _status = _logBuff.serializeFrom(
932  static_cast<U8>(sizeof(I32))
933  );
934  FW_ASSERT(
935  _status == Fw::FW_SERIALIZE_OK,
936  static_cast<FwAssertArgType>(_status)
937  );
938 #endif
939  _status = _logBuff.serializeFrom(error_number);
940  FW_ASSERT(
941  _status == Fw::FW_SERIALIZE_OK,
942  static_cast<FwAssertArgType>(_status)
943  );
944 
945  this->m_Log_OutputPort[0].invoke(
946  _id,
947  _logTime,
949  _logBuff
950  );
951  }
952 
953  // Emit the event on the text log port
954 #if FW_ENABLE_TEXT_LOGGING
955  if (this->m_LogText_OutputPort[0].isConnected()) {
956 #if FW_OBJECT_NAMES == 1
957  const char* _formatString =
958  "(%s) %s: Interrupt polling returned errno: %" PRIi32 "";
959 #else
960  const char* _formatString =
961  "%s: Interrupt polling returned errno: %" PRIi32 "";
962 #endif
963 
964  Fw::TextLogString _logString;
965  _logString.format(
966  _formatString,
967 #if FW_OBJECT_NAMES == 1
968  this->m_objName.toChar(),
969 #endif
970  "PollingError ",
971  error_number
972  );
973 
974  this->m_LogText_OutputPort[0].invoke(
975  _id,
976  _logTime,
978  _logString
979  );
980  }
981 #endif
982  }
983 
984  // ----------------------------------------------------------------------
985  // Time
986  // ----------------------------------------------------------------------
987 
989  getTime() const
990  {
991  if (this->m_Time_OutputPort[0].isConnected()) {
992  Fw::Time _time;
993  this->m_Time_OutputPort[0].invoke(_time);
994  return _time;
995  }
996  else {
997  return Fw::Time(TimeBase::TB_NONE, 0, 0);
998  }
999  }
1000 
1001  // ----------------------------------------------------------------------
1002  // Calls for messages received on typed input ports
1003  // ----------------------------------------------------------------------
1004 
1005  Drv::GpioStatus LinuxGpioDriverComponentBase ::
1006  m_p_gpioRead_in(
1007  Fw::PassiveComponentBase* callComp,
1008  FwIndexType portNum,
1009  Fw::Logic& state
1010  )
1011  {
1012  FW_ASSERT(callComp);
1013  LinuxGpioDriverComponentBase* compPtr = static_cast<LinuxGpioDriverComponentBase*>(callComp);
1014  return compPtr->gpioRead_handlerBase(
1015  portNum,
1016  state
1017  );
1018  }
1019 
1020  Drv::GpioStatus LinuxGpioDriverComponentBase ::
1021  m_p_gpioWrite_in(
1022  Fw::PassiveComponentBase* callComp,
1023  FwIndexType portNum,
1024  const Fw::Logic& state
1025  )
1026  {
1027  FW_ASSERT(callComp);
1028  LinuxGpioDriverComponentBase* compPtr = static_cast<LinuxGpioDriverComponentBase*>(callComp);
1029  return compPtr->gpioWrite_handlerBase(
1030  portNum,
1031  state
1032  );
1033  }
1034 
1035 }
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)
static constexpr FwIndexType getNum_Time_OutputPorts()
Drv::InputGpioWritePort * get_gpioWrite_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_gpioRead_InputPorts()
I32 FwEnumStoreType
void init()
Initialization function.
#define FW_LOG_STRING_MAX_SIZE
Max size of log string parameter type.
Definition: FpConfig.h:206
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.
static constexpr FwIndexType getNum_gpioInterrupt_OutputPorts()
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.
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].
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.
bool isConnected_Log_OutputPort(FwIndexType portNum)
#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:128
static constexpr FwIndexType getNum_Log_OutputPorts()
#define FW_MIN(a, b)
MIN macro.
Definition: BasicTypes.h:92
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
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:38
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)
serialize 8-bit unsigned int
#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.
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
SerializeStatus serializeTo(SerializeBufferBase &buffer, Endianness mode=Endianness::BIG) const override
serialize contents to buffer
Definition: StringBase.cpp:142
Logic states.
Definition: LogicEnumAc.hpp:17
void invoke(Os::RawTime &cycleStart) const
Invoke a port interface.
Implementation of malloc based allocator.
virtual ~LinuxGpioDriverComponentBase()
Destroy LinuxGpioDriverComponentBase object.
FPP shadow-enum representing Os::File::Status.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
virtual const CHAR * toChar() const =0