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
21 #if !FW_DIRECT_PORT_CALLS
23 #endif
24 #if !FW_DIRECT_PORT_CALLS
26 #endif
27 #include "Fw/Time/TimePortAc.hpp"
28 #include "Fw/Tlm/TlmPortAc.hpp"
29 #include "Fw/Tlm/TlmString.hpp"
30 #include "Os/Mutex.hpp"
33 
34 namespace Drv {
35 
40  {
41 
42  // ----------------------------------------------------------------------
43  // Friend classes
44  // ----------------------------------------------------------------------
45 
49  friend class LinuxSpiDriverTester;
50 
51  protected:
52 
53  // ----------------------------------------------------------------------
54  // Constants
55  // ----------------------------------------------------------------------
56 
58  enum {
61  };
62 
64  enum {
69  };
70 
72  enum {
78  };
79 
81  enum {
83  };
84 
86  enum {
88  };
89 
90  public:
91 
92  // ----------------------------------------------------------------------
93  // Component initialization
94  // ----------------------------------------------------------------------
95 
97  void init(
98  FwEnumStoreType instance = 0
99  );
100 
101 #if !FW_DIRECT_PORT_CALLS
102 
103  public:
104 
105  // ----------------------------------------------------------------------
106  // Getters for typed input ports
107  // ----------------------------------------------------------------------
108 
113  FwIndexType portNum
114  );
115 
120  FwIndexType portNum
121  );
122 
123 #endif
124 
125 #if !FW_DIRECT_PORT_CALLS
126 
127  public:
128 
129  // ----------------------------------------------------------------------
130  // Connect input ports to special output ports
131  // ----------------------------------------------------------------------
132 
134  void set_Log_OutputPort(
135  FwIndexType portNum,
136  Fw::InputLogPort* port
137  );
138 
139 #if FW_ENABLE_TEXT_LOGGING == 1
140 
142  void set_LogText_OutputPort(
143  FwIndexType portNum,
144  Fw::InputLogTextPort* port
145  );
146 
147 #endif
148 
150  void set_Time_OutputPort(
151  FwIndexType portNum,
152  Fw::InputTimePort* port
153  );
154 
156  void set_Tlm_OutputPort(
157  FwIndexType portNum,
158  Fw::InputTlmPort* port
159  );
160 
161 #endif
162 
163 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
164 
165  public:
166 
167  // ----------------------------------------------------------------------
168  // Connect serial input ports to special output ports
169  // ----------------------------------------------------------------------
170 
172  void set_Log_OutputPort(
173  FwIndexType portNum,
174  Fw::InputSerializePort* port
175  );
176 
177 #if FW_ENABLE_TEXT_LOGGING == 1
178 
180  void set_LogText_OutputPort(
181  FwIndexType portNum,
182  Fw::InputSerializePort* port
183  );
184 
185 #endif
186 
188  void set_Time_OutputPort(
189  FwIndexType portNum,
190  Fw::InputSerializePort* port
191  );
192 
194  void set_Tlm_OutputPort(
195  FwIndexType portNum,
196  Fw::InputSerializePort* port
197  );
198 
199 #endif
200 
201  protected:
202 
203  // ----------------------------------------------------------------------
204  // Component construction and destruction
205  // ----------------------------------------------------------------------
206 
209  const char* compName = ""
210  );
211 
214 
215  protected:
216 
217  // ----------------------------------------------------------------------
218  // Getters for numbers of typed input ports
219  // ----------------------------------------------------------------------
220 
226  }
227 
233  }
234 
235  protected:
236 
237  // ----------------------------------------------------------------------
238  // Getters for numbers of special output ports
239  // ----------------------------------------------------------------------
240 
244  static constexpr FwIndexType getNum_Log_OutputPorts() {
245  return NUM_LOG_OUTPUT_PORTS;
246  }
247 
248 #if FW_ENABLE_TEXT_LOGGING == 1
249 
253  static constexpr FwIndexType getNum_LogText_OutputPorts() {
255  }
256 
257 #endif
258 
263  return NUM_TIME_OUTPUT_PORTS;
264  }
265 
269  static constexpr FwIndexType getNum_Tlm_OutputPorts() {
270  return NUM_TLM_OUTPUT_PORTS;
271  }
272 
273  protected:
274 
275  // ----------------------------------------------------------------------
276  // Connection status queries for special output ports
277  // ----------------------------------------------------------------------
278 
283  FwIndexType portNum
284  ) const;
285 
286 #if FW_ENABLE_TEXT_LOGGING == 1
287 
291  bool isConnected_LogText_OutputPort(
292  FwIndexType portNum
293  ) const;
294 
295 #endif
296 
301  FwIndexType portNum
302  ) const;
303 
308  FwIndexType portNum
309  ) const;
310 
311  protected:
312 
313  // ----------------------------------------------------------------------
314  // Handlers to implement for typed input ports
315  // ----------------------------------------------------------------------
316 
318  virtual void SpiReadWrite_handler(
319  FwIndexType portNum,
320  Fw::Buffer& writeBuffer,
321  Fw::Buffer& readBuffer
322  ) = 0;
323 
326  FwIndexType portNum,
327  Fw::Buffer& writeBuffer,
328  Fw::Buffer& readBuffer
329  ) = 0;
330 
331 #if FW_DIRECT_PORT_CALLS
332  public:
333 #else
334  protected:
335 #endif
336 
337  // ----------------------------------------------------------------------
338  // Port handler base-class functions for typed input ports
339  //
340  // Call these functions directly to bypass the corresponding ports
341  // ----------------------------------------------------------------------
342 
345  FwIndexType portNum,
346  Fw::Buffer& writeBuffer,
347  Fw::Buffer& readBuffer
348  );
349 
352  FwIndexType portNum,
353  Fw::Buffer& writeBuffer,
354  Fw::Buffer& readBuffer
355  );
356 
357  protected:
358 
359  // ----------------------------------------------------------------------
360  // Event logging functions
361  // ----------------------------------------------------------------------
362 
367  I32 device,
368  I32 select,
369  I32 error
370  ) const;
371 
376  I32 device,
377  I32 select,
378  I32 error
379  ) const;
380 
385  I32 device,
386  I32 select,
387  I32 error
388  );
389 
394  I32 device,
395  I32 select,
396  const Fw::StringBase& parameter,
397  U32 write_value,
398  U32 read_value
399  ) const;
400 
405  I32 device,
406  I32 select
407  ) const;
408 
409  protected:
410 
411  // ----------------------------------------------------------------------
412  // Event throttle reset functions
413  // ----------------------------------------------------------------------
414 
417 
418  protected:
419 
420  // ----------------------------------------------------------------------
421  // Telemetry serialized write
422  // ----------------------------------------------------------------------
423 
428  void tlmWrite(
429  FwChanIdType id,
430  Fw::TlmBuffer& _tlmBuff,
431  Fw::Time _tlmTime = Fw::Time()
432  ) const;
433 
434  protected:
435 
436  // ----------------------------------------------------------------------
437  // Telemetry write functions
438  // ----------------------------------------------------------------------
439 
443  void tlmWrite_SPI_Bytes(
444  FwSizeType arg,
445  Fw::Time _tlmTime = Fw::Time()
446  ) const;
447 
448  protected:
449 
450  // ----------------------------------------------------------------------
451  // Time
452  // ----------------------------------------------------------------------
453 
457  Fw::Time getTime() const;
458 
459  protected:
460 
461  // ----------------------------------------------------------------------
462  // Mutex operations for guarded ports
463  //
464  // You can override these operations to provide more sophisticated
465  // synchronization
466  // ----------------------------------------------------------------------
467 
469  virtual void lock();
470 
472  virtual void unLock();
473 
474  private:
475 
476  // ----------------------------------------------------------------------
477  // Calls for messages received on typed input ports
478  // ----------------------------------------------------------------------
479 
481  static void m_p_SpiReadWrite_in(
482  Fw::PassiveComponentBase* callComp,
483  FwIndexType portNum,
484  Fw::Buffer& writeBuffer,
485  Fw::Buffer& readBuffer
486  );
487 
489  static Drv::SpiStatus m_p_SpiWriteRead_in(
490  Fw::PassiveComponentBase* callComp,
491  FwIndexType portNum,
492  Fw::Buffer& writeBuffer,
493  Fw::Buffer& readBuffer
494  );
495 
496  private:
497 
498  // ----------------------------------------------------------------------
499  // Invocation functions for special output ports
500  // ----------------------------------------------------------------------
501 
503  void Log_out(
504  FwIndexType portNum,
505  FwEventIdType id,
506  Fw::Time& timeTag,
507  const Fw::LogSeverity& severity,
508  Fw::LogBuffer& args
509  ) const;
510 
511 #if FW_ENABLE_TEXT_LOGGING
512 
514  void LogText_out(
515  FwIndexType portNum,
516  FwEventIdType id,
517  Fw::Time& timeTag,
518  const Fw::LogSeverity& severity,
519  Fw::TextLogString& text
520  ) const;
521 
522 #endif
523 
525  void Time_out(
526  FwIndexType portNum,
527  Fw::Time& time
528  ) const;
529 
531  void Tlm_out(
532  FwIndexType portNum,
533  FwChanIdType id,
534  Fw::Time& timeTag,
535  Fw::TlmBuffer& val
536  ) const;
537 
538 #if !FW_DIRECT_PORT_CALLS
539 
540  private:
541 
542  // ----------------------------------------------------------------------
543  // Typed input ports
544  // ----------------------------------------------------------------------
545 
548 
551 
552 #endif
553 
554 #if !FW_DIRECT_PORT_CALLS
555 
556  private:
557 
558  // ----------------------------------------------------------------------
559  // Special output ports
560  // ----------------------------------------------------------------------
561 
563  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
564 
565 #if FW_ENABLE_TEXT_LOGGING == 1
566 
568  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
569 
570 #endif
571 
573  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
574 
576  Fw::OutputTlmPort m_Tlm_OutputPort[NUM_TLM_OUTPUT_PORTS];
577 
578 #endif
579 
580  private:
581 
582  // ----------------------------------------------------------------------
583  // Counter values for event throttling
584  // ----------------------------------------------------------------------
585 
587  std::atomic<FwIndexType> m_SPI_WriteErrorThrottle;
588 
589  private:
590 
591  // ----------------------------------------------------------------------
592  // Mutexes
593  // ----------------------------------------------------------------------
594 
596  Os::Mutex m_guardedPortMutex;
597 
598  };
599 
600 }
601 
602 #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