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 #include "Fw/Log/LogTextPortAc.hpp"
19 #if !FW_DIRECT_PORT_CALLS
21 #endif
22 #if !FW_DIRECT_PORT_CALLS
24 #endif
25 #include "Fw/Time/TimePortAc.hpp"
30 
31 namespace Drv {
32 
37  {
38 
39  // ----------------------------------------------------------------------
40  // Friend classes
41  // ----------------------------------------------------------------------
42 
46  friend class LinuxGpioDriverTester;
47 
48  protected:
49 
50  // ----------------------------------------------------------------------
51  // Constants
52  // ----------------------------------------------------------------------
53 
55  enum {
58  };
59 
61  enum {
65  };
66 
68  enum {
70  };
71 
73  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  const Os::FileStatus& status
407  ) const;
408 
411  const Fw::StringBase& chip,
412  U32 pin,
413  const Fw::StringBase& pinMessage,
414  const 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 
427  void log_WARNING_HI_InterruptTimeError(const Os::RawTimeStatus& status) const;
428 
429  protected:
430 
431  // ----------------------------------------------------------------------
432  // Time
433  // ----------------------------------------------------------------------
434 
438  Fw::Time getTime() const;
439 
440  private:
441 
442  // ----------------------------------------------------------------------
443  // Calls for messages received on typed input ports
444  // ----------------------------------------------------------------------
445 
447  static Drv::GpioStatus m_p_gpioRead_in(
448  Fw::PassiveComponentBase* callComp,
449  FwIndexType portNum,
450  Fw::Logic& state
451  );
452 
454  static Drv::GpioStatus m_p_gpioWrite_in(
455  Fw::PassiveComponentBase* callComp,
456  FwIndexType portNum,
457  const Fw::Logic& state
458  );
459 
460  private:
461 
462  // ----------------------------------------------------------------------
463  // Invocation functions for special output ports
464  // ----------------------------------------------------------------------
465 
467  void Log_out(
468  FwIndexType portNum,
469  FwEventIdType id,
470  Fw::Time& timeTag,
471  const Fw::LogSeverity& severity,
472  Fw::LogBuffer& args
473  ) const;
474 
475 #if FW_ENABLE_TEXT_LOGGING
476 
478  void LogText_out(
479  FwIndexType portNum,
480  FwEventIdType id,
481  Fw::Time& timeTag,
482  const Fw::LogSeverity& severity,
483  Fw::TextLogString& text
484  ) const;
485 
486 #endif
487 
489  void Time_out(
490  FwIndexType portNum,
491  Fw::Time& time
492  ) const;
493 
494 #if !FW_DIRECT_PORT_CALLS
495 
496  private:
497 
498  // ----------------------------------------------------------------------
499  // Typed input ports
500  // ----------------------------------------------------------------------
501 
503  Drv::InputGpioReadPort m_gpioRead_InputPort[NUM_GPIOREAD_INPUT_PORTS];
504 
506  Drv::InputGpioWritePort m_gpioWrite_InputPort[NUM_GPIOWRITE_INPUT_PORTS];
507 
508 #endif
509 
510 #if !FW_DIRECT_PORT_CALLS
511 
512  private:
513 
514  // ----------------------------------------------------------------------
515  // Special output ports
516  // ----------------------------------------------------------------------
517 
519  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
520 
521 #if FW_ENABLE_TEXT_LOGGING == 1
522 
524  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
525 
526 #endif
527 
529  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
530 
531 #endif
532 
533 #if !FW_DIRECT_PORT_CALLS
534 
535  private:
536 
537  // ----------------------------------------------------------------------
538  // Typed output ports
539  // ----------------------------------------------------------------------
540 
542  Svc::OutputCyclePort m_gpioInterrupt_OutputPort[NUM_GPIOINTERRUPT_OUTPUT_PORTS];
543 
544 #endif
545 
546  };
547 
548 }
549 
550 #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()
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 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.
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_OpenPinError(const Fw::StringBase &chip, U32 pin, const Fw::StringBase &pinMessage, const Os::FileStatus &status) const
Log event OpenPinError.
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:18
void log_WARNING_HI_InterruptTimeError(const Os::RawTimeStatus &status) const
Log event InterruptTimeError.
virtual ~LinuxGpioDriverComponentBase()
Destroy LinuxGpioDriverComponentBase object.
FPP shadow-enum representing Os::File::Status.
bool isConnected_gpioInterrupt_OutputPort(FwIndexType portNum) const