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"
29 
30 namespace Drv {
31 
36  {
37 
38  // ----------------------------------------------------------------------
39  // Friend classes
40  // ----------------------------------------------------------------------
41 
45  friend class LinuxSpiDriverTester;
46 
47  protected:
48 
49  // ----------------------------------------------------------------------
50  // Constants
51  // ----------------------------------------------------------------------
52 
54  enum {
57  };
58 
60  enum {
65  };
66 
68  enum {
74  };
75 
77  enum {
79  };
80 
82  enum {
84  };
85 
86  public:
87 
88  // ----------------------------------------------------------------------
89  // Component initialization
90  // ----------------------------------------------------------------------
91 
93  void init(
94  FwEnumStoreType instance = 0
95  );
96 
97  public:
98 
99  // ----------------------------------------------------------------------
100  // Getters for typed input ports
101  // ----------------------------------------------------------------------
102 
107  FwIndexType portNum
108  );
109 
114  FwIndexType portNum
115  );
116 
117  public:
118 
119  // ----------------------------------------------------------------------
120  // Connect input ports to special output ports
121  // ----------------------------------------------------------------------
122 
124  void set_Log_OutputPort(
125  FwIndexType portNum,
126  Fw::InputLogPort* port
127  );
128 
129 #if FW_ENABLE_TEXT_LOGGING == 1
130 
132  void set_LogText_OutputPort(
133  FwIndexType portNum,
134  Fw::InputLogTextPort* port
135  );
136 
137 #endif
138 
140  void set_Time_OutputPort(
141  FwIndexType portNum,
142  Fw::InputTimePort* port
143  );
144 
146  void set_Tlm_OutputPort(
147  FwIndexType portNum,
148  Fw::InputTlmPort* port
149  );
150 
151 #if FW_PORT_SERIALIZATION
152 
153  public:
154 
155  // ----------------------------------------------------------------------
156  // Connect serial input ports to special output ports
157  // ----------------------------------------------------------------------
158 
160  void set_Log_OutputPort(
161  FwIndexType portNum,
162  Fw::InputSerializePort* port
163  );
164 
165 #if FW_ENABLE_TEXT_LOGGING == 1
166 
168  void set_LogText_OutputPort(
169  FwIndexType portNum,
170  Fw::InputSerializePort* port
171  );
172 
173 #endif
174 
176  void set_Time_OutputPort(
177  FwIndexType portNum,
178  Fw::InputSerializePort* port
179  );
180 
182  void set_Tlm_OutputPort(
183  FwIndexType portNum,
184  Fw::InputSerializePort* port
185  );
186 
187 #endif
188 
189  protected:
190 
191  // ----------------------------------------------------------------------
192  // Component construction and destruction
193  // ----------------------------------------------------------------------
194 
197  const char* compName = ""
198  );
199 
202 
203  protected:
204 
205  // ----------------------------------------------------------------------
206  // Getters for numbers of typed input ports
207  // ----------------------------------------------------------------------
208 
214  }
215 
221  }
222 
223  protected:
224 
225  // ----------------------------------------------------------------------
226  // Getters for numbers of special output ports
227  // ----------------------------------------------------------------------
228 
232  static constexpr FwIndexType getNum_Log_OutputPorts() {
233  return NUM_LOG_OUTPUT_PORTS;
234  }
235 
236 #if FW_ENABLE_TEXT_LOGGING == 1
237 
241  static constexpr FwIndexType getNum_LogText_OutputPorts() {
243  }
244 
245 #endif
246 
251  return NUM_TIME_OUTPUT_PORTS;
252  }
253 
257  static constexpr FwIndexType getNum_Tlm_OutputPorts() {
258  return NUM_TLM_OUTPUT_PORTS;
259  }
260 
261  protected:
262 
263  // ----------------------------------------------------------------------
264  // Connection status queries for special output ports
265  // ----------------------------------------------------------------------
266 
271  FwIndexType portNum
272  );
273 
274 #if FW_ENABLE_TEXT_LOGGING == 1
275 
279  bool isConnected_LogText_OutputPort(
280  FwIndexType portNum
281  );
282 
283 #endif
284 
289  FwIndexType portNum
290  );
291 
296  FwIndexType portNum
297  );
298 
299  protected:
300 
301  // ----------------------------------------------------------------------
302  // Handlers to implement for typed input ports
303  // ----------------------------------------------------------------------
304 
306  virtual void SpiReadWrite_handler(
307  FwIndexType portNum,
308  Fw::Buffer& writeBuffer,
309  Fw::Buffer& readBuffer
310  ) = 0;
311 
314  FwIndexType portNum,
315  Fw::Buffer& writeBuffer,
316  Fw::Buffer& readBuffer
317  ) = 0;
318 
319  protected:
320 
321  // ----------------------------------------------------------------------
322  // Port handler base-class functions for typed input ports
323  //
324  // Call these functions directly to bypass the corresponding ports
325  // ----------------------------------------------------------------------
326 
329  FwIndexType portNum,
330  Fw::Buffer& writeBuffer,
331  Fw::Buffer& readBuffer
332  );
333 
336  FwIndexType portNum,
337  Fw::Buffer& writeBuffer,
338  Fw::Buffer& readBuffer
339  );
340 
341  protected:
342 
343  // ----------------------------------------------------------------------
344  // Event logging functions
345  // ----------------------------------------------------------------------
346 
351  I32 device,
352  I32 select,
353  I32 error
354  ) const;
355 
360  I32 device,
361  I32 select,
362  I32 error
363  ) const;
364 
369  I32 device,
370  I32 select,
371  I32 error
372  );
373 
378  I32 device,
379  I32 select,
380  const Fw::StringBase& parameter,
381  U32 write_value,
382  U32 read_value
383  ) const;
384 
389  I32 device,
390  I32 select
391  ) const;
392 
393  protected:
394 
395  // ----------------------------------------------------------------------
396  // Event throttle reset functions
397  // ----------------------------------------------------------------------
398 
401 
402  protected:
403 
404  // ----------------------------------------------------------------------
405  // Telemetry write functions
406  // ----------------------------------------------------------------------
407 
411  void tlmWrite_SPI_Bytes(
412  FwSizeType arg,
413  Fw::Time _tlmTime = Fw::Time()
414  ) const;
415 
416  protected:
417 
418  // ----------------------------------------------------------------------
419  // Time
420  // ----------------------------------------------------------------------
421 
425  Fw::Time getTime() const;
426 
427  protected:
428 
429  // ----------------------------------------------------------------------
430  // Mutex operations for guarded ports
431  //
432  // You can override these operations to provide more sophisticated
433  // synchronization
434  // ----------------------------------------------------------------------
435 
437  virtual void lock();
438 
440  virtual void unLock();
441 
442  private:
443 
444  // ----------------------------------------------------------------------
445  // Calls for messages received on typed input ports
446  // ----------------------------------------------------------------------
447 
449  static void m_p_SpiReadWrite_in(
450  Fw::PassiveComponentBase* callComp,
451  FwIndexType portNum,
452  Fw::Buffer& writeBuffer,
453  Fw::Buffer& readBuffer
454  );
455 
457  static Drv::SpiStatus m_p_SpiWriteRead_in(
458  Fw::PassiveComponentBase* callComp,
459  FwIndexType portNum,
460  Fw::Buffer& writeBuffer,
461  Fw::Buffer& readBuffer
462  );
463 
464  private:
465 
466  // ----------------------------------------------------------------------
467  // Typed input ports
468  // ----------------------------------------------------------------------
469 
472 
475 
476  private:
477 
478  // ----------------------------------------------------------------------
479  // Special output ports
480  // ----------------------------------------------------------------------
481 
483  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
484 
485 #if FW_ENABLE_TEXT_LOGGING == 1
486 
488  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
489 
490 #endif
491 
493  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
494 
496  Fw::OutputTlmPort m_Tlm_OutputPort[NUM_TLM_OUTPUT_PORTS];
497 
498  private:
499 
500  // ----------------------------------------------------------------------
501  // Counter values for event throttling
502  // ----------------------------------------------------------------------
503 
505  std::atomic<FwIndexType> m_SPI_WriteErrorThrottle;
506 
507  private:
508 
509  // ----------------------------------------------------------------------
510  // Mutexes
511  // ----------------------------------------------------------------------
512 
514  Os::Mutex m_guardedPortMutex;
515 
516  };
517 
518 }
519 
520 #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