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 #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"
26 #include "Fw/Tlm/TlmPortAc.hpp"
27 #include "Fw/Tlm/TlmString.hpp"
28 #include "Os/Mutex.hpp"
31 
32 namespace Drv {
33 
38  {
39 
40  // ----------------------------------------------------------------------
41  // Friend classes
42  // ----------------------------------------------------------------------
43 
47  friend class LinuxSpiDriverTester;
48 
49  protected:
50 
51  // ----------------------------------------------------------------------
52  // Constants
53  // ----------------------------------------------------------------------
54 
56  enum {
59  };
60 
62  enum {
67  };
68 
70  enum {
76  };
77 
79  enum {
81  };
82 
84  enum {
86  };
87 
88  public:
89 
90  // ----------------------------------------------------------------------
91  // Component initialization
92  // ----------------------------------------------------------------------
93 
95  void init(
96  FwEnumStoreType instance = 0
97  );
98 
99 #if !FW_DIRECT_PORT_CALLS
100 
101  public:
102 
103  // ----------------------------------------------------------------------
104  // Getters for typed input ports
105  // ----------------------------------------------------------------------
106 
111  FwIndexType portNum
112  );
113 
118  FwIndexType portNum
119  );
120 
121 #endif
122 
123 #if !FW_DIRECT_PORT_CALLS
124 
125  public:
126 
127  // ----------------------------------------------------------------------
128  // Connect input ports to special output ports
129  // ----------------------------------------------------------------------
130 
132  void set_Log_OutputPort(
133  FwIndexType portNum,
134  Fw::InputLogPort* port
135  );
136 
137 #if FW_ENABLE_TEXT_LOGGING == 1
138 
140  void set_LogText_OutputPort(
141  FwIndexType portNum,
142  Fw::InputLogTextPort* port
143  );
144 
145 #endif
146 
148  void set_Time_OutputPort(
149  FwIndexType portNum,
150  Fw::InputTimePort* port
151  );
152 
154  void set_Tlm_OutputPort(
155  FwIndexType portNum,
156  Fw::InputTlmPort* port
157  );
158 
159 #endif
160 
161 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
162 
163  public:
164 
165  // ----------------------------------------------------------------------
166  // Connect serial input ports to special output ports
167  // ----------------------------------------------------------------------
168 
170  void set_Log_OutputPort(
171  FwIndexType portNum,
172  Fw::InputSerializePort* port
173  );
174 
175 #if FW_ENABLE_TEXT_LOGGING == 1
176 
178  void set_LogText_OutputPort(
179  FwIndexType portNum,
180  Fw::InputSerializePort* port
181  );
182 
183 #endif
184 
186  void set_Time_OutputPort(
187  FwIndexType portNum,
188  Fw::InputSerializePort* port
189  );
190 
192  void set_Tlm_OutputPort(
193  FwIndexType portNum,
194  Fw::InputSerializePort* port
195  );
196 
197 #endif
198 
199  protected:
200 
201  // ----------------------------------------------------------------------
202  // Component construction and destruction
203  // ----------------------------------------------------------------------
204 
207  const char* compName = ""
208  );
209 
212 
213  protected:
214 
215  // ----------------------------------------------------------------------
216  // Getters for numbers of typed input ports
217  // ----------------------------------------------------------------------
218 
224  }
225 
231  }
232 
233  protected:
234 
235  // ----------------------------------------------------------------------
236  // Getters for numbers of special output ports
237  // ----------------------------------------------------------------------
238 
242  static constexpr FwIndexType getNum_Log_OutputPorts() {
243  return NUM_LOG_OUTPUT_PORTS;
244  }
245 
246 #if FW_ENABLE_TEXT_LOGGING == 1
247 
251  static constexpr FwIndexType getNum_LogText_OutputPorts() {
253  }
254 
255 #endif
256 
261  return NUM_TIME_OUTPUT_PORTS;
262  }
263 
267  static constexpr FwIndexType getNum_Tlm_OutputPorts() {
268  return NUM_TLM_OUTPUT_PORTS;
269  }
270 
271  protected:
272 
273  // ----------------------------------------------------------------------
274  // Connection status queries for special output ports
275  // ----------------------------------------------------------------------
276 
281  FwIndexType portNum
282  ) const;
283 
284 #if FW_ENABLE_TEXT_LOGGING == 1
285 
289  bool isConnected_LogText_OutputPort(
290  FwIndexType portNum
291  ) const;
292 
293 #endif
294 
299  FwIndexType portNum
300  ) const;
301 
306  FwIndexType portNum
307  ) const;
308 
309  protected:
310 
311  // ----------------------------------------------------------------------
312  // Handlers to implement for typed input ports
313  // ----------------------------------------------------------------------
314 
316  virtual void SpiReadWrite_handler(
317  FwIndexType portNum,
318  Fw::Buffer& writeBuffer,
319  Fw::Buffer& readBuffer
320  ) = 0;
321 
324  FwIndexType portNum,
325  Fw::Buffer& writeBuffer,
326  Fw::Buffer& readBuffer
327  ) = 0;
328 
329 #if FW_DIRECT_PORT_CALLS
330  public:
331 #else
332  protected:
333 #endif
334 
335  // ----------------------------------------------------------------------
336  // Port handler base-class functions for typed input ports
337  //
338  // Call these functions directly to bypass the corresponding ports
339  // ----------------------------------------------------------------------
340 
343  FwIndexType portNum,
344  Fw::Buffer& writeBuffer,
345  Fw::Buffer& readBuffer
346  );
347 
350  FwIndexType portNum,
351  Fw::Buffer& writeBuffer,
352  Fw::Buffer& readBuffer
353  );
354 
355  protected:
356 
357  // ----------------------------------------------------------------------
358  // Event logging functions
359  // ----------------------------------------------------------------------
360 
365  I32 device,
366  I32 select,
367  I32 error
368  ) const;
369 
374  I32 device,
375  I32 select,
376  I32 error
377  ) const;
378 
383  I32 device,
384  I32 select,
385  I32 error
386  );
387 
392  I32 device,
393  I32 select,
394  const Fw::StringBase& parameter,
395  U32 write_value,
396  U32 read_value
397  ) const;
398 
403  I32 device,
404  I32 select
405  ) const;
406 
407  protected:
408 
409  // ----------------------------------------------------------------------
410  // Event throttle reset functions
411  // ----------------------------------------------------------------------
412 
415 
416  protected:
417 
418  // ----------------------------------------------------------------------
419  // Telemetry serialized write
420  // ----------------------------------------------------------------------
421 
426  void tlmWrite(
427  FwChanIdType id,
428  Fw::TlmBuffer& _tlmBuff,
429  Fw::Time _tlmTime = Fw::Time()
430  ) const;
431 
432  protected:
433 
434  // ----------------------------------------------------------------------
435  // Telemetry write functions
436  // ----------------------------------------------------------------------
437 
441  void tlmWrite_SPI_Bytes(
442  FwSizeType arg,
443  Fw::Time _tlmTime = Fw::Time()
444  ) const;
445 
446  protected:
447 
448  // ----------------------------------------------------------------------
449  // Time
450  // ----------------------------------------------------------------------
451 
455  Fw::Time getTime() const;
456 
457  protected:
458 
459  // ----------------------------------------------------------------------
460  // Mutex operations for guarded ports
461  //
462  // You can override these operations to provide more sophisticated
463  // synchronization
464  // ----------------------------------------------------------------------
465 
467  virtual void lock();
468 
470  virtual void unLock();
471 
472  private:
473 
474  // ----------------------------------------------------------------------
475  // Calls for messages received on typed input ports
476  // ----------------------------------------------------------------------
477 
479  static void m_p_SpiReadWrite_in(
480  Fw::PassiveComponentBase* callComp,
481  FwIndexType portNum,
482  Fw::Buffer& writeBuffer,
483  Fw::Buffer& readBuffer
484  );
485 
487  static Drv::SpiStatus m_p_SpiWriteRead_in(
488  Fw::PassiveComponentBase* callComp,
489  FwIndexType portNum,
490  Fw::Buffer& writeBuffer,
491  Fw::Buffer& readBuffer
492  );
493 
494  private:
495 
496  // ----------------------------------------------------------------------
497  // Invocation functions for special output ports
498  // ----------------------------------------------------------------------
499 
501  void Log_out(
502  FwIndexType portNum,
503  FwEventIdType id,
504  Fw::Time& timeTag,
505  const Fw::LogSeverity& severity,
506  Fw::LogBuffer& args
507  ) const;
508 
509 #if FW_ENABLE_TEXT_LOGGING
510 
512  void LogText_out(
513  FwIndexType portNum,
514  FwEventIdType id,
515  Fw::Time& timeTag,
516  const Fw::LogSeverity& severity,
517  Fw::TextLogString& text
518  ) const;
519 
520 #endif
521 
523  void Time_out(
524  FwIndexType portNum,
525  Fw::Time& time
526  ) const;
527 
529  void Tlm_out(
530  FwIndexType portNum,
531  FwChanIdType id,
532  Fw::Time& timeTag,
533  Fw::TlmBuffer& val
534  ) const;
535 
536 #if !FW_DIRECT_PORT_CALLS
537 
538  private:
539 
540  // ----------------------------------------------------------------------
541  // Typed input ports
542  // ----------------------------------------------------------------------
543 
546 
549 
550 #endif
551 
552 #if !FW_DIRECT_PORT_CALLS
553 
554  private:
555 
556  // ----------------------------------------------------------------------
557  // Special output ports
558  // ----------------------------------------------------------------------
559 
561  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
562 
563 #if FW_ENABLE_TEXT_LOGGING == 1
564 
566  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
567 
568 #endif
569 
571  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
572 
574  Fw::OutputTlmPort m_Tlm_OutputPort[NUM_TLM_OUTPUT_PORTS];
575 
576 #endif
577 
578  private:
579 
580  // ----------------------------------------------------------------------
581  // Counter values for event throttling
582  // ----------------------------------------------------------------------
583 
585  std::atomic<FwIndexType> m_SPI_WriteErrorThrottle;
586 
587  private:
588 
589  // ----------------------------------------------------------------------
590  // Mutexes
591  // ----------------------------------------------------------------------
592 
594  Os::Mutex m_guardedPortMutex;
595 
596  };
597 
598 }
599 
600 #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()
bool isConnected_Time_OutputPort(FwIndexType portNum) const
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()
void log_WARNING_HI_SPI_WriteError_ThrottleClear()
Reset throttle value for SPI_WriteError.
bool isConnected_Tlm_OutputPort(FwIndexType portNum) const
FwIdType FwEventIdType
The type of an event identifier.
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.
LinuxSpiDriverComponentBase(const char *compName="")
Construct LinuxSpiDriverComponentBase object.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
void log_ACTIVITY_HI_SPI_PortOpened(I32 device, I32 select) const
bool isConnected_Log_OutputPort(FwIndexType portNum) const
static constexpr FwIndexType getNum_SpiReadWrite_InputPorts()
Enum representing event severity.
void tlmWrite(FwChanIdType id, Fw::TlmBuffer &_tlmBuff, Fw::Time _tlmTime=Fw::Time()) const
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].
PlatformIndexType FwIndexType