F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
LinuxUartDriverComponentAc.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title LinuxUartDriverComponentAc.hpp
3 // \author Generated by fpp-to-cpp
4 // \brief hpp file for LinuxUartDriver component base class
5 // ======================================================================
6 
7 #ifndef Drv_LinuxUartDriverComponentAc_HPP
8 #define Drv_LinuxUartDriverComponentAc_HPP
9 
10 #include <atomic>
11 
18 #include "Fw/FPrimeBasicTypes.hpp"
19 #include "Fw/Log/LogPortAc.hpp"
20 #include "Fw/Log/LogString.hpp"
21 #if FW_ENABLE_TEXT_LOGGING == 1
22 #include "Fw/Log/LogTextPortAc.hpp"
23 #endif
26 #include "Fw/Time/TimePortAc.hpp"
27 #include "Fw/Tlm/TlmPortAc.hpp"
28 #include "Fw/Tlm/TlmString.hpp"
29 #include "Os/Mutex.hpp"
33 
34 namespace Drv {
35 
40  {
41 
42  // ----------------------------------------------------------------------
43  // Friend classes
44  // ----------------------------------------------------------------------
45 
49  friend class LinuxUartDriverTester;
50 
51  protected:
52 
53  // ----------------------------------------------------------------------
54  // Constants
55  // ----------------------------------------------------------------------
56 
58  enum {
62  };
63 
65  enum {
70  };
71 
73  enum {
78  };
79 
81  enum {
89  };
90 
92  enum {
96  };
97 
99  enum {
102  };
103 
104  public:
105 
106  // ----------------------------------------------------------------------
107  // Component initialization
108  // ----------------------------------------------------------------------
109 
111  void init(
112  FwEnumStoreType instance = 0
113  );
114 
115  public:
116 
117  // ----------------------------------------------------------------------
118  // Getters for typed input ports
119  // ----------------------------------------------------------------------
120 
125  FwIndexType portNum
126  );
127 
132  FwIndexType portNum
133  );
134 
139  FwIndexType portNum
140  );
141 
142  public:
143 
144  // ----------------------------------------------------------------------
145  // Connect input ports to special output ports
146  // ----------------------------------------------------------------------
147 
149  void set_Log_OutputPort(
150  FwIndexType portNum,
151  Fw::InputLogPort* port
152  );
153 
154 #if FW_ENABLE_TEXT_LOGGING == 1
155 
157  void set_LogText_OutputPort(
158  FwIndexType portNum,
159  Fw::InputLogTextPort* port
160  );
161 
162 #endif
163 
165  void set_Time_OutputPort(
166  FwIndexType portNum,
167  Fw::InputTimePort* port
168  );
169 
171  void set_Tlm_OutputPort(
172  FwIndexType portNum,
173  Fw::InputTlmPort* port
174  );
175 
176  public:
177 
178  // ----------------------------------------------------------------------
179  // Connect typed input ports to typed output ports
180  // ----------------------------------------------------------------------
181 
184  FwIndexType portNum,
186  );
187 
190  FwIndexType portNum,
192  );
193 
196  FwIndexType portNum,
198  );
199 
201  void set_recv_OutputPort(
202  FwIndexType portNum,
204  );
205 
206 #if FW_PORT_SERIALIZATION
207 
208  public:
209 
210  // ----------------------------------------------------------------------
211  // Connect serial input ports to special output ports
212  // ----------------------------------------------------------------------
213 
215  void set_Log_OutputPort(
216  FwIndexType portNum,
217  Fw::InputSerializePort* port
218  );
219 
220 #if FW_ENABLE_TEXT_LOGGING == 1
221 
223  void set_LogText_OutputPort(
224  FwIndexType portNum,
225  Fw::InputSerializePort* port
226  );
227 
228 #endif
229 
231  void set_Time_OutputPort(
232  FwIndexType portNum,
233  Fw::InputSerializePort* port
234  );
235 
237  void set_Tlm_OutputPort(
238  FwIndexType portNum,
239  Fw::InputSerializePort* port
240  );
241 
242 #endif
243 
244 #if FW_PORT_SERIALIZATION
245 
246  public:
247 
248  // ----------------------------------------------------------------------
249  // Connect serial input ports to typed output ports
250  // ----------------------------------------------------------------------
251 
254  FwIndexType portNum,
255  Fw::InputSerializePort* port
256  );
257 
260  FwIndexType portNum,
261  Fw::InputSerializePort* port
262  );
263 
265  void set_recv_OutputPort(
266  FwIndexType portNum,
267  Fw::InputSerializePort* port
268  );
269 
270 #endif
271 
272  protected:
273 
274  // ----------------------------------------------------------------------
275  // Component construction and destruction
276  // ----------------------------------------------------------------------
277 
280  const char* compName = ""
281  );
282 
285 
286  protected:
287 
288  // ----------------------------------------------------------------------
289  // Getters for numbers of typed input ports
290  // ----------------------------------------------------------------------
291 
297  }
298 
302  static constexpr FwIndexType getNum_run_InputPorts() {
303  return NUM_RUN_INPUT_PORTS;
304  }
305 
309  static constexpr FwIndexType getNum_send_InputPorts() {
310  return NUM_SEND_INPUT_PORTS;
311  }
312 
313  protected:
314 
315  // ----------------------------------------------------------------------
316  // Getters for numbers of special output ports
317  // ----------------------------------------------------------------------
318 
322  static constexpr FwIndexType getNum_Log_OutputPorts() {
323  return NUM_LOG_OUTPUT_PORTS;
324  }
325 
326 #if FW_ENABLE_TEXT_LOGGING == 1
327 
331  static constexpr FwIndexType getNum_LogText_OutputPorts() {
333  }
334 
335 #endif
336 
341  return NUM_TIME_OUTPUT_PORTS;
342  }
343 
347  static constexpr FwIndexType getNum_Tlm_OutputPorts() {
348  return NUM_TLM_OUTPUT_PORTS;
349  }
350 
351  protected:
352 
353  // ----------------------------------------------------------------------
354  // Getters for numbers of typed output ports
355  // ----------------------------------------------------------------------
356 
362  }
363 
369  }
370 
375  return NUM_READY_OUTPUT_PORTS;
376  }
377 
382  return NUM_RECV_OUTPUT_PORTS;
383  }
384 
385  protected:
386 
387  // ----------------------------------------------------------------------
388  // Connection status queries for special output ports
389  // ----------------------------------------------------------------------
390 
395  FwIndexType portNum
396  );
397 
398 #if FW_ENABLE_TEXT_LOGGING == 1
399 
403  bool isConnected_LogText_OutputPort(
404  FwIndexType portNum
405  );
406 
407 #endif
408 
413  FwIndexType portNum
414  );
415 
420  FwIndexType portNum
421  );
422 
423  protected:
424 
425  // ----------------------------------------------------------------------
426  // Connection status queries for typed output ports
427  // ----------------------------------------------------------------------
428 
433  FwIndexType portNum
434  );
435 
440  FwIndexType portNum
441  );
442 
447  FwIndexType portNum
448  );
449 
454  FwIndexType portNum
455  );
456 
457  protected:
458 
459  // ----------------------------------------------------------------------
460  // Handlers to implement for typed input ports
461  // ----------------------------------------------------------------------
462 
464  virtual void recvReturnIn_handler(
465  FwIndexType portNum,
466  Fw::Buffer& fwBuffer
467  ) = 0;
468 
470  virtual void run_handler(
471  FwIndexType portNum,
472  U32 context
473  ) = 0;
474 
477  FwIndexType portNum,
478  Fw::Buffer& sendBuffer
479  ) = 0;
480 
481  protected:
482 
483  // ----------------------------------------------------------------------
484  // Port handler base-class functions for typed input ports
485  //
486  // Call these functions directly to bypass the corresponding ports
487  // ----------------------------------------------------------------------
488 
491  FwIndexType portNum,
492  Fw::Buffer& fwBuffer
493  );
494 
496  void run_handlerBase(
497  FwIndexType portNum,
498  U32 context
499  );
500 
503  FwIndexType portNum,
504  Fw::Buffer& sendBuffer
505  );
506 
507  protected:
508 
509  // ----------------------------------------------------------------------
510  // Invocation functions for typed output ports
511  // ----------------------------------------------------------------------
512 
515  FwIndexType portNum,
516  FwSizeType size
517  );
518 
520  void deallocate_out(
521  FwIndexType portNum,
522  Fw::Buffer& fwBuffer
523  );
524 
526  void ready_out(
527  FwIndexType portNum
528  );
529 
531  void recv_out(
532  FwIndexType portNum,
533  Fw::Buffer& buffer,
534  const Drv::ByteStreamStatus& status
535  );
536 
537  protected:
538 
539  // ----------------------------------------------------------------------
540  // Event logging functions
541  // ----------------------------------------------------------------------
542 
547  const Fw::StringBase& device,
548  I32 error,
549  const Fw::StringBase& name
550  ) const;
551 
556  const Fw::StringBase& device,
557  I32 error
558  ) const;
559 
564  const Fw::StringBase& device,
565  I32 error
566  );
567 
572  const Fw::StringBase& device,
573  I32 error
574  );
575 
580  const Fw::StringBase& device
581  ) const;
582 
587  const Fw::StringBase& device
588  );
589 
594  const Fw::StringBase& device,
595  U32 size,
596  U32 needed
597  ) const;
598 
599  protected:
600 
601  // ----------------------------------------------------------------------
602  // Event throttle reset functions
603  // ----------------------------------------------------------------------
604 
607 
610 
613 
614  protected:
615 
616  // ----------------------------------------------------------------------
617  // Telemetry write functions
618  // ----------------------------------------------------------------------
619 
623  void tlmWrite_BytesSent(
624  FwSizeType arg,
625  Fw::Time _tlmTime = Fw::Time()
626  ) const;
627 
631  void tlmWrite_BytesRecv(
632  FwSizeType arg,
633  Fw::Time _tlmTime = Fw::Time()
634  ) const;
635 
636  protected:
637 
638  // ----------------------------------------------------------------------
639  // Time
640  // ----------------------------------------------------------------------
641 
645  Fw::Time getTime() const;
646 
647  protected:
648 
649  // ----------------------------------------------------------------------
650  // Mutex operations for guarded ports
651  //
652  // You can override these operations to provide more sophisticated
653  // synchronization
654  // ----------------------------------------------------------------------
655 
657  virtual void lock();
658 
660  virtual void unLock();
661 
662  private:
663 
664  // ----------------------------------------------------------------------
665  // Calls for messages received on typed input ports
666  // ----------------------------------------------------------------------
667 
669  static void m_p_recvReturnIn_in(
670  Fw::PassiveComponentBase* callComp,
671  FwIndexType portNum,
672  Fw::Buffer& fwBuffer
673  );
674 
676  static void m_p_run_in(
677  Fw::PassiveComponentBase* callComp,
678  FwIndexType portNum,
679  U32 context
680  );
681 
683  static Drv::ByteStreamStatus m_p_send_in(
684  Fw::PassiveComponentBase* callComp,
685  FwIndexType portNum,
686  Fw::Buffer& sendBuffer
687  );
688 
689  private:
690 
691  // ----------------------------------------------------------------------
692  // Typed input ports
693  // ----------------------------------------------------------------------
694 
696  Fw::InputBufferSendPort m_recvReturnIn_InputPort[NUM_RECVRETURNIN_INPUT_PORTS];
697 
699  Svc::InputSchedPort m_run_InputPort[NUM_RUN_INPUT_PORTS];
700 
703 
704  private:
705 
706  // ----------------------------------------------------------------------
707  // Special output ports
708  // ----------------------------------------------------------------------
709 
711  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
712 
713 #if FW_ENABLE_TEXT_LOGGING == 1
714 
716  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
717 
718 #endif
719 
721  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
722 
724  Fw::OutputTlmPort m_Tlm_OutputPort[NUM_TLM_OUTPUT_PORTS];
725 
726  private:
727 
728  // ----------------------------------------------------------------------
729  // Typed output ports
730  // ----------------------------------------------------------------------
731 
733  Fw::OutputBufferGetPort m_allocate_OutputPort[NUM_ALLOCATE_OUTPUT_PORTS];
734 
736  Fw::OutputBufferSendPort m_deallocate_OutputPort[NUM_DEALLOCATE_OUTPUT_PORTS];
737 
740 
743 
744  private:
745 
746  // ----------------------------------------------------------------------
747  // Counter values for event throttling
748  // ----------------------------------------------------------------------
749 
751  std::atomic<FwIndexType> m_WriteErrorThrottle;
752 
754  std::atomic<FwIndexType> m_ReadErrorThrottle;
755 
757  std::atomic<FwIndexType> m_NoBuffersThrottle;
758 
759  private:
760 
761  // ----------------------------------------------------------------------
762  // Mutexes
763  // ----------------------------------------------------------------------
764 
766  Os::Mutex m_guardedPortMutex;
767 
768  };
769 
770 }
771 
772 #endif
virtual void lock()
Lock the guarded mutex.
virtual void unLock()
Unlock the guarded mutex.
bool isConnected_deallocate_OutputPort(FwIndexType portNum)
void log_WARNING_HI_BufferTooSmall(const Fw::StringBase &device, U32 size, U32 needed) const
static constexpr FwIndexType getNum_deallocate_OutputPorts()
bool isConnected_Time_OutputPort(FwIndexType portNum)
void recvReturnIn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port recvReturnIn.
PlatformSizeType FwSizeType
Drv::ByteStreamStatus send_handlerBase(FwIndexType portNum, Fw::Buffer &sendBuffer)
Handler base-class function for input port send.
I32 FwEnumStoreType
bool isConnected_allocate_OutputPort(FwIndexType portNum)
Drv::InputByteStreamSendPort * get_send_InputPort(FwIndexType portNum)
void set_Tlm_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
friend class LinuxUartDriverTesterBase
Friend class tester to support autocoded test harness.
virtual void recvReturnIn_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port recvReturnIn.
static constexpr FwIndexType getNum_recv_OutputPorts()
void tlmWrite_BytesRecv(FwSizeType arg, Fw::Time _tlmTime=Fw::Time()) const
LinuxUartDriverComponentBase(const char *compName="")
Construct LinuxUartDriverComponentBase object.
Auto-generated base for LinuxUartDriver component.
static constexpr FwIndexType getNum_Log_OutputPorts()
void log_WARNING_HI_WriteError(const Fw::StringBase &device, I32 error)
void set_ready_OutputPort(FwIndexType portNum, Drv::InputByteStreamReadyPort *port)
Connect port to ready[portNum].
void init()
Object initializer.
Definition: ObjBase.cpp:24
void log_WARNING_HI_ReadError(const Fw::StringBase &device, I32 error)
void deallocate_out(FwIndexType portNum, Fw::Buffer &fwBuffer)
Invoke output port deallocate.
Fw::InputBufferSendPort * get_recvReturnIn_InputPort(FwIndexType portNum)
Status returned by the send call.
static constexpr FwIndexType getNum_ready_OutputPorts()
static constexpr FwIndexType getNum_recvReturnIn_InputPorts()
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
void recv_out(FwIndexType portNum, Fw::Buffer &buffer, const Drv::ByteStreamStatus &status)
Invoke output port recv.
void log_WARNING_HI_WriteError_ThrottleClear()
Reset throttle value for WriteError.
void log_WARNING_HI_OpenError(const Fw::StringBase &device, I32 error, const Fw::StringBase &name) const
static constexpr FwIndexType getNum_run_InputPorts()
virtual Drv::ByteStreamStatus send_handler(FwIndexType portNum, Fw::Buffer &sendBuffer)=0
Handler for input port send.
bool isConnected_Log_OutputPort(FwIndexType portNum)
void log_ACTIVITY_HI_PortOpened(const Fw::StringBase &device) const
void set_allocate_OutputPort(FwIndexType portNum, Fw::InputBufferGetPort *port)
Connect port to allocate[portNum].
void log_WARNING_HI_NoBuffers(const Fw::StringBase &device)
friend class LinuxUartDriverTester
Friend class tester implementation to support white-box testing.
static constexpr FwIndexType getNum_allocate_OutputPorts()
bool isConnected_Tlm_OutputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_Time_OutputPorts()
static constexpr FwIndexType getNum_Tlm_OutputPorts()
bool isConnected_recv_OutputPort(FwIndexType portNum)
virtual void run_handler(FwIndexType portNum, U32 context)=0
Handler for input port run.
Svc::InputSchedPort * get_run_InputPort(FwIndexType portNum)
void run_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port run.
void set_deallocate_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to deallocate[portNum].
PlatformIndexType FwIndexType
void ready_out(FwIndexType portNum)
Invoke output port ready.
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
virtual ~LinuxUartDriverComponentBase()
Destroy LinuxUartDriverComponentBase object.
bool isConnected_ready_OutputPort(FwIndexType portNum)
void log_WARNING_HI_NoBuffers_ThrottleClear()
Reset throttle value for NoBuffers.
void set_recv_OutputPort(FwIndexType portNum, Drv::InputByteStreamDataPort *port)
Connect port to recv[portNum].
void tlmWrite_BytesSent(FwSizeType arg, Fw::Time _tlmTime=Fw::Time()) const
Fw::Buffer allocate_out(FwIndexType portNum, FwSizeType size)
Invoke output port allocate.
void log_WARNING_HI_ReadError_ThrottleClear()
Reset throttle value for ReadError.
void log_WARNING_HI_ConfigError(const Fw::StringBase &device, I32 error) const
static constexpr FwIndexType getNum_send_InputPorts()