F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
LinuxGpioDriverComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title LinuxGpioDriverComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for LinuxGpioDriver component base class
5 // ======================================================================
6 
7 #ifndef Drv_LinuxGpioDriverComponentAc_HPP
8 #define Drv_LinuxGpioDriverComponentAc_HPP
9 
10 #include <atomic>
11 
15 #include "Fw/FPrimeBasicTypes.hpp"
16 #include "Fw/Log/LogPortAc.hpp"
17 #include "Fw/Log/LogString.hpp"
18 #if FW_ENABLE_TEXT_LOGGING == 1
19 #include "Fw/Log/LogTextPortAc.hpp"
20 #endif
21 #if !FW_DIRECT_PORT_CALLS
23 #endif
24 #if !FW_DIRECT_PORT_CALLS
26 #endif
27 #include "Fw/Time/TimePortAc.hpp"
31 
32 namespace Drv {
33 
38  {
39 
40  // ----------------------------------------------------------------------
41  // Friend classes
42  // ----------------------------------------------------------------------
43 
47  friend class LinuxGpioDriverTester;
48 
49  protected:
50 
51  // ----------------------------------------------------------------------
52  // Constants
53  // ----------------------------------------------------------------------
54 
56  enum {
59  };
60 
62  enum {
66  };
67 
69  enum {
71  };
72 
74  enum {
80  };
81 
82  public:
83 
84  // ----------------------------------------------------------------------
85  // Component initialization
86  // ----------------------------------------------------------------------
87 
89  void init(
90  FwEnumStoreType instance = 0
91  );
92 
93 #if !FW_DIRECT_PORT_CALLS
94 
95  public:
96 
97  // ----------------------------------------------------------------------
98  // Getters for typed input ports
99  // ----------------------------------------------------------------------
100 
105  FwIndexType portNum
106  );
107 
112  FwIndexType portNum
113  );
114 
115 #endif
116 
117 #if !FW_DIRECT_PORT_CALLS
118 
119  public:
120 
121  // ----------------------------------------------------------------------
122  // Connect input ports to special output ports
123  // ----------------------------------------------------------------------
124 
126  void set_Log_OutputPort(
127  FwIndexType portNum,
128  Fw::InputLogPort* port
129  );
130 
131 #if FW_ENABLE_TEXT_LOGGING == 1
132 
134  void set_LogText_OutputPort(
135  FwIndexType portNum,
136  Fw::InputLogTextPort* port
137  );
138 
139 #endif
140 
142  void set_Time_OutputPort(
143  FwIndexType portNum,
144  Fw::InputTimePort* port
145  );
146 
147 #endif
148 
149 #if !FW_DIRECT_PORT_CALLS
150 
151  public:
152 
153  // ----------------------------------------------------------------------
154  // Connect typed input ports to typed output ports
155  // ----------------------------------------------------------------------
156 
159  FwIndexType portNum,
160  Svc::InputCyclePort* port
161  );
162 
163 #endif
164 
165 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
166 
167  public:
168 
169  // ----------------------------------------------------------------------
170  // Connect serial input ports to special output ports
171  // ----------------------------------------------------------------------
172 
174  void set_Log_OutputPort(
175  FwIndexType portNum,
176  Fw::InputSerializePort* port
177  );
178 
179 #if FW_ENABLE_TEXT_LOGGING == 1
180 
182  void set_LogText_OutputPort(
183  FwIndexType portNum,
184  Fw::InputSerializePort* port
185  );
186 
187 #endif
188 
190  void set_Time_OutputPort(
191  FwIndexType portNum,
192  Fw::InputSerializePort* port
193  );
194 
195 #endif
196 
197 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
198 
199  public:
200 
201  // ----------------------------------------------------------------------
202  // Connect serial input ports to typed output ports
203  // ----------------------------------------------------------------------
204 
207  FwIndexType portNum,
208  Fw::InputSerializePort* port
209  );
210 
211 #endif
212 
213  protected:
214 
215  // ----------------------------------------------------------------------
216  // Component construction and destruction
217  // ----------------------------------------------------------------------
218 
221  const char* compName = ""
222  );
223 
226 
227  protected:
228 
229  // ----------------------------------------------------------------------
230  // Getters for numbers of typed input ports
231  // ----------------------------------------------------------------------
232 
238  }
239 
245  }
246 
247  protected:
248 
249  // ----------------------------------------------------------------------
250  // Getters for numbers of special output ports
251  // ----------------------------------------------------------------------
252 
256  static constexpr FwIndexType getNum_Log_OutputPorts() {
257  return NUM_LOG_OUTPUT_PORTS;
258  }
259 
260 #if FW_ENABLE_TEXT_LOGGING == 1
261 
265  static constexpr FwIndexType getNum_LogText_OutputPorts() {
267  }
268 
269 #endif
270 
275  return NUM_TIME_OUTPUT_PORTS;
276  }
277 
278  protected:
279 
280  // ----------------------------------------------------------------------
281  // Getters for numbers of typed output ports
282  // ----------------------------------------------------------------------
283 
289  }
290 
291  protected:
292 
293  // ----------------------------------------------------------------------
294  // Connection status queries for special output ports
295  // ----------------------------------------------------------------------
296 
301  FwIndexType portNum
302  ) const;
303 
304 #if FW_ENABLE_TEXT_LOGGING == 1
305 
309  bool isConnected_LogText_OutputPort(
310  FwIndexType portNum
311  ) const;
312 
313 #endif
314 
319  FwIndexType portNum
320  ) const;
321 
322  protected:
323 
324  // ----------------------------------------------------------------------
325  // Connection status queries for typed output ports
326  // ----------------------------------------------------------------------
327 
332  FwIndexType portNum
333  ) const;
334 
335  protected:
336 
337  // ----------------------------------------------------------------------
338  // Handlers to implement for typed input ports
339  // ----------------------------------------------------------------------
340 
343  FwIndexType portNum,
344  Fw::Logic& state
345  ) = 0;
346 
349  FwIndexType portNum,
350  const Fw::Logic& state
351  ) = 0;
352 
353 #if FW_DIRECT_PORT_CALLS
354  public:
355 #else
356  protected:
357 #endif
358 
359  // ----------------------------------------------------------------------
360  // Port handler base-class functions for typed input ports
361  //
362  // Call these functions directly to bypass the corresponding ports
363  // ----------------------------------------------------------------------
364 
367  FwIndexType portNum,
368  Fw::Logic& state
369  );
370 
373  FwIndexType portNum,
374  const Fw::Logic& state
375  );
376 
377  protected:
378 
379  // ----------------------------------------------------------------------
380  // Invocation functions for typed output ports
381  // ----------------------------------------------------------------------
382 
384  void gpioInterrupt_out(
385  FwIndexType portNum,
386  Os::RawTime& cycleStart
387  ) const;
388 
389  protected:
390 
391  // ----------------------------------------------------------------------
392  // Event logging functions
393  // ----------------------------------------------------------------------
394 
397  const Fw::StringBase& chip,
398  const Fw::StringBase& chipLabel,
399  U32 pin,
400  const Fw::StringBase& pinMessage
401  ) const;
402 
405  const Fw::StringBase& chip,
406  Os::FileStatus status
407  ) const;
408 
411  const Fw::StringBase& chip,
412  U32 pin,
413  const Fw::StringBase& pinMessage,
414  Os::FileStatus status
415  ) const;
416 
419  U32 expected,
420  U32 got
421  ) const;
422 
424  void log_WARNING_HI_PollingError(I32 error_number) const;
425 
426  protected:
427 
428  // ----------------------------------------------------------------------
429  // Time
430  // ----------------------------------------------------------------------
431 
435  Fw::Time getTime() const;
436 
437  private:
438 
439  // ----------------------------------------------------------------------
440  // Calls for messages received on typed input ports
441  // ----------------------------------------------------------------------
442 
444  static Drv::GpioStatus m_p_gpioRead_in(
445  Fw::PassiveComponentBase* callComp,
446  FwIndexType portNum,
447  Fw::Logic& state
448  );
449 
451  static Drv::GpioStatus m_p_gpioWrite_in(
452  Fw::PassiveComponentBase* callComp,
453  FwIndexType portNum,
454  const Fw::Logic& state
455  );
456 
457  private:
458 
459  // ----------------------------------------------------------------------
460  // Invocation functions for special output ports
461  // ----------------------------------------------------------------------
462 
464  void Log_out(
465  FwIndexType portNum,
466  FwEventIdType id,
467  Fw::Time& timeTag,
468  const Fw::LogSeverity& severity,
469  Fw::LogBuffer& args
470  ) const;
471 
472 #if FW_ENABLE_TEXT_LOGGING
473 
475  void LogText_out(
476  FwIndexType portNum,
477  FwEventIdType id,
478  Fw::Time& timeTag,
479  const Fw::LogSeverity& severity,
480  Fw::TextLogString& text
481  ) const;
482 
483 #endif
484 
486  void Time_out(
487  FwIndexType portNum,
488  Fw::Time& time
489  ) const;
490 
491 #if !FW_DIRECT_PORT_CALLS
492 
493  private:
494 
495  // ----------------------------------------------------------------------
496  // Typed input ports
497  // ----------------------------------------------------------------------
498 
500  Drv::InputGpioReadPort m_gpioRead_InputPort[NUM_GPIOREAD_INPUT_PORTS];
501 
503  Drv::InputGpioWritePort m_gpioWrite_InputPort[NUM_GPIOWRITE_INPUT_PORTS];
504 
505 #endif
506 
507 #if !FW_DIRECT_PORT_CALLS
508 
509  private:
510 
511  // ----------------------------------------------------------------------
512  // Special output ports
513  // ----------------------------------------------------------------------
514 
516  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
517 
518 #if FW_ENABLE_TEXT_LOGGING == 1
519 
521  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
522 
523 #endif
524 
526  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
527 
528 #endif
529 
530 #if !FW_DIRECT_PORT_CALLS
531 
532  private:
533 
534  // ----------------------------------------------------------------------
535  // Typed output ports
536  // ----------------------------------------------------------------------
537 
539  Svc::OutputCyclePort m_gpioInterrupt_OutputPort[NUM_GPIOINTERRUPT_OUTPUT_PORTS];
540 
541 #endif
542 
543  };
544 
545 }
546 
547 #endif
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()
I32 FwEnumStoreType
void log_WARNING_HI_InterruptReadError(U32 expected, U32 got) const
Log event InterruptReadError.
LinuxGpioDriverComponentBase(const char *compName="")
Construct LinuxGpioDriverComponentBase object.
void gpioInterrupt_out(FwIndexType portNum, Os::RawTime &cycleStart) const
Invoke output port gpioInterrupt.
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.
virtual Drv::GpioStatus gpioRead_handler(FwIndexType portNum, Fw::Logic &state)=0
Handler for input port gpioRead.
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.
friend class LinuxGpioDriverTester
Friend class tester implementation to support white-box testing.
static constexpr FwIndexType getNum_gpioWrite_InputPorts()
FwIdType FwEventIdType
The type of an event identifier.
Auto-generated base for LinuxGpioDriver component.
static constexpr FwIndexType getNum_Log_OutputPorts()
void log_WARNING_HI_OpenChipError(const Fw::StringBase &chip, Os::FileStatus status) const
Log event OpenChipError.
void log_DIAGNOSTIC_OpenChip(const Fw::StringBase &chip, const Fw::StringBase &chipLabel, U32 pin, const Fw::StringBase &pinMessage) const
Log event OpenChip.
Enum representing event severity.
Input GpioRead port.
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
PlatformIndexType FwIndexType
void log_WARNING_HI_PollingError(I32 error_number) const
Log event PollingError.
bool isConnected_Time_OutputPort(FwIndexType portNum) const
friend class LinuxGpioDriverTesterBase
Friend class tester to support autocoded test harness.
Logic states.
Definition: LogicEnumAc.hpp:17
virtual ~LinuxGpioDriverComponentBase()
Destroy LinuxGpioDriverComponentBase object.
FPP shadow-enum representing Os::File::Status.
bool isConnected_gpioInterrupt_OutputPort(FwIndexType portNum) const