F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
LinuxSpiDriverComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title LinuxSpiDriverComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for LinuxSpiDriver component base class
5 // ======================================================================
6 
7 #ifndef Drv_LinuxSpiDriverComponentAc_HPP
8 #define Drv_LinuxSpiDriverComponentAc_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
23 #include "Fw/Time/TimePortAc.hpp"
24 #include "Fw/Tlm/TlmPortAc.hpp"
25 #include "Fw/Tlm/TlmString.hpp"
26 #include "Os/Mutex.hpp"
28 
29 namespace Drv {
30 
35  {
36 
37  // ----------------------------------------------------------------------
38  // Friend classes
39  // ----------------------------------------------------------------------
40 
44  friend class LinuxSpiDriverTester;
45 
46  protected:
47 
48  // ----------------------------------------------------------------------
49  // Constants
50  // ----------------------------------------------------------------------
51 
53  enum {
56  };
57 
59  enum {
64  };
65 
67  enum {
73  };
74 
76  enum {
78  };
79 
81  enum {
83  };
84 
85  public:
86 
87  // ----------------------------------------------------------------------
88  // Component initialization
89  // ----------------------------------------------------------------------
90 
92  void init(
93  FwEnumStoreType instance = 0
94  );
95 
96  public:
97 
98  // ----------------------------------------------------------------------
99  // Getters for typed input ports
100  // ----------------------------------------------------------------------
101 
106  FwIndexType portNum
107  );
108 
113  FwIndexType portNum
114  );
115 
116  public:
117 
118  // ----------------------------------------------------------------------
119  // Connect input ports to special output ports
120  // ----------------------------------------------------------------------
121 
123  void set_Log_OutputPort(
124  FwIndexType portNum,
125  Fw::InputLogPort* port
126  );
127 
128 #if FW_ENABLE_TEXT_LOGGING == 1
129 
131  void set_LogText_OutputPort(
132  FwIndexType portNum,
133  Fw::InputLogTextPort* port
134  );
135 
136 #endif
137 
139  void set_Time_OutputPort(
140  FwIndexType portNum,
141  Fw::InputTimePort* port
142  );
143 
145  void set_Tlm_OutputPort(
146  FwIndexType portNum,
147  Fw::InputTlmPort* port
148  );
149 
150 #if FW_PORT_SERIALIZATION
151 
152  public:
153 
154  // ----------------------------------------------------------------------
155  // Connect serial input ports to special output ports
156  // ----------------------------------------------------------------------
157 
159  void set_Log_OutputPort(
160  FwIndexType portNum,
161  Fw::InputSerializePort* port
162  );
163 
164 #if FW_ENABLE_TEXT_LOGGING == 1
165 
167  void set_LogText_OutputPort(
168  FwIndexType portNum,
169  Fw::InputSerializePort* port
170  );
171 
172 #endif
173 
175  void set_Time_OutputPort(
176  FwIndexType portNum,
177  Fw::InputSerializePort* port
178  );
179 
181  void set_Tlm_OutputPort(
182  FwIndexType portNum,
183  Fw::InputSerializePort* port
184  );
185 
186 #endif
187 
188  protected:
189 
190  // ----------------------------------------------------------------------
191  // Component construction and destruction
192  // ----------------------------------------------------------------------
193 
196  const char* compName = ""
197  );
198 
201 
202  protected:
203 
204  // ----------------------------------------------------------------------
205  // Getters for numbers of typed input ports
206  // ----------------------------------------------------------------------
207 
213  }
214 
220  }
221 
222  protected:
223 
224  // ----------------------------------------------------------------------
225  // Getters for numbers of special output ports
226  // ----------------------------------------------------------------------
227 
231  static constexpr FwIndexType getNum_Log_OutputPorts() {
232  return NUM_LOG_OUTPUT_PORTS;
233  }
234 
235 #if FW_ENABLE_TEXT_LOGGING == 1
236 
240  static constexpr FwIndexType getNum_LogText_OutputPorts() {
242  }
243 
244 #endif
245 
250  return NUM_TIME_OUTPUT_PORTS;
251  }
252 
256  static constexpr FwIndexType getNum_Tlm_OutputPorts() {
257  return NUM_TLM_OUTPUT_PORTS;
258  }
259 
260  protected:
261 
262  // ----------------------------------------------------------------------
263  // Connection status queries for special output ports
264  // ----------------------------------------------------------------------
265 
270  FwIndexType portNum
271  );
272 
273 #if FW_ENABLE_TEXT_LOGGING == 1
274 
278  bool isConnected_LogText_OutputPort(
279  FwIndexType portNum
280  );
281 
282 #endif
283 
288  FwIndexType portNum
289  );
290 
295  FwIndexType portNum
296  );
297 
298  protected:
299 
300  // ----------------------------------------------------------------------
301  // Handlers to implement for typed input ports
302  // ----------------------------------------------------------------------
303 
305  virtual void SpiReadWrite_handler(
306  FwIndexType portNum,
307  Fw::Buffer& writeBuffer,
308  Fw::Buffer& readBuffer
309  ) = 0;
310 
313  FwIndexType portNum,
314  Fw::Buffer& writeBuffer,
315  Fw::Buffer& readBuffer
316  ) = 0;
317 
318  protected:
319 
320  // ----------------------------------------------------------------------
321  // Port handler base-class functions for typed input ports
322  //
323  // Call these functions directly to bypass the corresponding ports
324  // ----------------------------------------------------------------------
325 
328  FwIndexType portNum,
329  Fw::Buffer& writeBuffer,
330  Fw::Buffer& readBuffer
331  );
332 
335  FwIndexType portNum,
336  Fw::Buffer& writeBuffer,
337  Fw::Buffer& readBuffer
338  );
339 
340  protected:
341 
342  // ----------------------------------------------------------------------
343  // Event logging functions
344  // ----------------------------------------------------------------------
345 
350  I32 device,
351  I32 select,
352  I32 error
353  ) const;
354 
359  I32 device,
360  I32 select,
361  I32 error
362  ) const;
363 
368  I32 device,
369  I32 select,
370  I32 error
371  );
372 
377  I32 device,
378  I32 select,
379  const Fw::StringBase& parameter,
380  U32 write_value,
381  U32 read_value
382  ) const;
383 
388  I32 device,
389  I32 select
390  ) const;
391 
392  protected:
393 
394  // ----------------------------------------------------------------------
395  // Event throttle reset functions
396  // ----------------------------------------------------------------------
397 
400 
401  protected:
402 
403  // ----------------------------------------------------------------------
404  // Telemetry write functions
405  // ----------------------------------------------------------------------
406 
410  void tlmWrite_SPI_Bytes(
411  FwSizeType arg,
412  Fw::Time _tlmTime = Fw::Time()
413  ) const;
414 
415  protected:
416 
417  // ----------------------------------------------------------------------
418  // Time
419  // ----------------------------------------------------------------------
420 
424  Fw::Time getTime() const;
425 
426  protected:
427 
428  // ----------------------------------------------------------------------
429  // Mutex operations for guarded ports
430  //
431  // You can override these operations to provide more sophisticated
432  // synchronization
433  // ----------------------------------------------------------------------
434 
436  virtual void lock();
437 
439  virtual void unLock();
440 
441  private:
442 
443  // ----------------------------------------------------------------------
444  // Calls for messages received on typed input ports
445  // ----------------------------------------------------------------------
446 
448  static void m_p_SpiReadWrite_in(
449  Fw::PassiveComponentBase* callComp,
450  FwIndexType portNum,
451  Fw::Buffer& writeBuffer,
452  Fw::Buffer& readBuffer
453  );
454 
456  static Drv::SpiStatus m_p_SpiWriteRead_in(
457  Fw::PassiveComponentBase* callComp,
458  FwIndexType portNum,
459  Fw::Buffer& writeBuffer,
460  Fw::Buffer& readBuffer
461  );
462 
463  private:
464 
465  // ----------------------------------------------------------------------
466  // Typed input ports
467  // ----------------------------------------------------------------------
468 
471 
474 
475  private:
476 
477  // ----------------------------------------------------------------------
478  // Special output ports
479  // ----------------------------------------------------------------------
480 
482  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
483 
484 #if FW_ENABLE_TEXT_LOGGING == 1
485 
487  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
488 
489 #endif
490 
492  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
493 
495  Fw::OutputTlmPort m_Tlm_OutputPort[NUM_TLM_OUTPUT_PORTS];
496 
497  private:
498 
499  // ----------------------------------------------------------------------
500  // Counter values for event throttling
501  // ----------------------------------------------------------------------
502 
504  std::atomic<FwIndexType> m_SPI_WriteErrorThrottle;
505 
506  private:
507 
508  // ----------------------------------------------------------------------
509  // Mutexes
510  // ----------------------------------------------------------------------
511 
513  Os::Mutex m_guardedPortMutex;
514 
515  };
516 
517 }
518 
519 #endif
void SpiReadWrite_handlerBase(FwIndexType portNum, Fw::Buffer &writeBuffer, Fw::Buffer &readBuffer)
Handler base-class function for input port SpiReadWrite.
void log_WARNING_HI_SPI_ConfigError(I32 device, I32 select, I32 error) const
PlatformSizeType FwSizeType
static constexpr FwIndexType getNum_SpiWriteRead_InputPorts()
I32 FwEnumStoreType
virtual void SpiReadWrite_handler(FwIndexType portNum, Fw::Buffer &writeBuffer, Fw::Buffer &readBuffer)=0
Handler for input port SpiReadWrite.
static constexpr FwIndexType getNum_Time_OutputPorts()
virtual void lock()
Lock the guarded mutex.
friend class LinuxSpiDriverTester
Friend class tester implementation to support white-box testing.
void log_WARNING_HI_SPI_WriteError(I32 device, I32 select, I32 error)
friend class LinuxSpiDriverTesterBase
Friend class tester to support autocoded test harness.
void log_WARNING_LO_SPI_ConfigMismatch(I32 device, I32 select, const Fw::StringBase &parameter, U32 write_value, U32 read_value) const
virtual ~LinuxSpiDriverComponentBase()
Destroy LinuxSpiDriverComponentBase object.
virtual Drv::SpiStatus SpiWriteRead_handler(FwIndexType portNum, Fw::Buffer &writeBuffer, Fw::Buffer &readBuffer)=0
Handler for input port SpiWriteRead.
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
void init()
Object initializer.
Definition: ObjBase.cpp:24
static constexpr FwIndexType getNum_Tlm_OutputPorts()
bool isConnected_Tlm_OutputPort(FwIndexType portNum)
void log_WARNING_HI_SPI_WriteError_ThrottleClear()
Reset throttle value for SPI_WriteError.
Input SpiWriteRead port.
void tlmWrite_SPI_Bytes(FwSizeType arg, Fw::Time _tlmTime=Fw::Time()) const
Drv::InputSpiReadWritePort * get_SpiReadWrite_InputPort(FwIndexType portNum)
Auto-generated base for LinuxSpiDriver component.
bool isConnected_Time_OutputPort(FwIndexType portNum)
LinuxSpiDriverComponentBase(const char *compName="")
Construct LinuxSpiDriverComponentBase object.
void log_ACTIVITY_HI_SPI_PortOpened(I32 device, I32 select) const
static constexpr FwIndexType getNum_SpiReadWrite_InputPorts()
virtual void unLock()
Unlock the guarded mutex.
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
void log_WARNING_HI_SPI_OpenError(I32 device, I32 select, I32 error) const
static constexpr FwIndexType getNum_Log_OutputPorts()
Drv::SpiStatus SpiWriteRead_handlerBase(FwIndexType portNum, Fw::Buffer &writeBuffer, Fw::Buffer &readBuffer)
Handler base-class function for input port SpiWriteRead.
Drv::InputSpiWriteReadPort * get_SpiWriteRead_InputPort(FwIndexType portNum)
void set_Tlm_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
bool isConnected_Log_OutputPort(FwIndexType portNum)
PlatformIndexType FwIndexType