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"
32 
33 namespace Drv {
34 
39  {
40 
41  // ----------------------------------------------------------------------
42  // Friend classes
43  // ----------------------------------------------------------------------
44 
48  friend class LinuxUartDriverTester;
49 
50  protected:
51 
52  // ----------------------------------------------------------------------
53  // Constants
54  // ----------------------------------------------------------------------
55 
57  enum {
61  };
62 
64  enum {
69  };
70 
72  enum {
77  };
78 
80  enum {
88  };
89 
91  enum {
95  };
96 
98  enum {
101  };
102 
103  public:
104 
105  // ----------------------------------------------------------------------
106  // Component initialization
107  // ----------------------------------------------------------------------
108 
110  void init(
111  FwEnumStoreType instance = 0
112  );
113 
114  public:
115 
116  // ----------------------------------------------------------------------
117  // Getters for typed input ports
118  // ----------------------------------------------------------------------
119 
124  FwIndexType portNum
125  );
126 
131  FwIndexType portNum
132  );
133 
138  FwIndexType portNum
139  );
140 
141  public:
142 
143  // ----------------------------------------------------------------------
144  // Connect input ports to special output ports
145  // ----------------------------------------------------------------------
146 
148  void set_Log_OutputPort(
149  FwIndexType portNum,
150  Fw::InputLogPort* port
151  );
152 
153 #if FW_ENABLE_TEXT_LOGGING == 1
154 
156  void set_LogText_OutputPort(
157  FwIndexType portNum,
158  Fw::InputLogTextPort* port
159  );
160 
161 #endif
162 
164  void set_Time_OutputPort(
165  FwIndexType portNum,
166  Fw::InputTimePort* port
167  );
168 
170  void set_Tlm_OutputPort(
171  FwIndexType portNum,
172  Fw::InputTlmPort* port
173  );
174 
175  public:
176 
177  // ----------------------------------------------------------------------
178  // Connect typed input ports to typed output ports
179  // ----------------------------------------------------------------------
180 
183  FwIndexType portNum,
185  );
186 
189  FwIndexType portNum,
191  );
192 
195  FwIndexType portNum,
197  );
198 
200  void set_recv_OutputPort(
201  FwIndexType portNum,
203  );
204 
205 #if FW_PORT_SERIALIZATION
206 
207  public:
208 
209  // ----------------------------------------------------------------------
210  // Connect serial input ports to special output ports
211  // ----------------------------------------------------------------------
212 
214  void set_Log_OutputPort(
215  FwIndexType portNum,
216  Fw::InputSerializePort* port
217  );
218 
219 #if FW_ENABLE_TEXT_LOGGING == 1
220 
222  void set_LogText_OutputPort(
223  FwIndexType portNum,
224  Fw::InputSerializePort* port
225  );
226 
227 #endif
228 
230  void set_Time_OutputPort(
231  FwIndexType portNum,
232  Fw::InputSerializePort* port
233  );
234 
236  void set_Tlm_OutputPort(
237  FwIndexType portNum,
238  Fw::InputSerializePort* port
239  );
240 
241 #endif
242 
243 #if FW_PORT_SERIALIZATION
244 
245  public:
246 
247  // ----------------------------------------------------------------------
248  // Connect serial input ports to typed output ports
249  // ----------------------------------------------------------------------
250 
253  FwIndexType portNum,
254  Fw::InputSerializePort* port
255  );
256 
259  FwIndexType portNum,
260  Fw::InputSerializePort* port
261  );
262 
264  void set_recv_OutputPort(
265  FwIndexType portNum,
266  Fw::InputSerializePort* port
267  );
268 
269 #endif
270 
271  protected:
272 
273  // ----------------------------------------------------------------------
274  // Component construction and destruction
275  // ----------------------------------------------------------------------
276 
279  const char* compName = ""
280  );
281 
284 
285  protected:
286 
287  // ----------------------------------------------------------------------
288  // Getters for numbers of typed input ports
289  // ----------------------------------------------------------------------
290 
296  }
297 
301  static constexpr FwIndexType getNum_run_InputPorts() {
302  return NUM_RUN_INPUT_PORTS;
303  }
304 
308  static constexpr FwIndexType getNum_send_InputPorts() {
309  return NUM_SEND_INPUT_PORTS;
310  }
311 
312  protected:
313 
314  // ----------------------------------------------------------------------
315  // Getters for numbers of special output ports
316  // ----------------------------------------------------------------------
317 
321  static constexpr FwIndexType getNum_Log_OutputPorts() {
322  return NUM_LOG_OUTPUT_PORTS;
323  }
324 
325 #if FW_ENABLE_TEXT_LOGGING == 1
326 
330  static constexpr FwIndexType getNum_LogText_OutputPorts() {
332  }
333 
334 #endif
335 
340  return NUM_TIME_OUTPUT_PORTS;
341  }
342 
346  static constexpr FwIndexType getNum_Tlm_OutputPorts() {
347  return NUM_TLM_OUTPUT_PORTS;
348  }
349 
350  protected:
351 
352  // ----------------------------------------------------------------------
353  // Getters for numbers of typed output ports
354  // ----------------------------------------------------------------------
355 
361  }
362 
368  }
369 
374  return NUM_READY_OUTPUT_PORTS;
375  }
376 
381  return NUM_RECV_OUTPUT_PORTS;
382  }
383 
384  protected:
385 
386  // ----------------------------------------------------------------------
387  // Connection status queries for special output ports
388  // ----------------------------------------------------------------------
389 
394  FwIndexType portNum
395  );
396 
397 #if FW_ENABLE_TEXT_LOGGING == 1
398 
402  bool isConnected_LogText_OutputPort(
403  FwIndexType portNum
404  );
405 
406 #endif
407 
412  FwIndexType portNum
413  );
414 
419  FwIndexType portNum
420  );
421 
422  protected:
423 
424  // ----------------------------------------------------------------------
425  // Connection status queries for typed output ports
426  // ----------------------------------------------------------------------
427 
432  FwIndexType portNum
433  );
434 
439  FwIndexType portNum
440  );
441 
446  FwIndexType portNum
447  );
448 
453  FwIndexType portNum
454  );
455 
456  protected:
457 
458  // ----------------------------------------------------------------------
459  // Handlers to implement for typed input ports
460  // ----------------------------------------------------------------------
461 
463  virtual void recvReturnIn_handler(
464  FwIndexType portNum,
465  Fw::Buffer& fwBuffer
466  ) = 0;
467 
469  virtual void run_handler(
470  FwIndexType portNum,
471  U32 context
472  ) = 0;
473 
476  FwIndexType portNum,
477  Fw::Buffer& sendBuffer
478  ) = 0;
479 
480  protected:
481 
482  // ----------------------------------------------------------------------
483  // Port handler base-class functions for typed input ports
484  //
485  // Call these functions directly to bypass the corresponding ports
486  // ----------------------------------------------------------------------
487 
490  FwIndexType portNum,
491  Fw::Buffer& fwBuffer
492  );
493 
495  void run_handlerBase(
496  FwIndexType portNum,
497  U32 context
498  );
499 
502  FwIndexType portNum,
503  Fw::Buffer& sendBuffer
504  );
505 
506  protected:
507 
508  // ----------------------------------------------------------------------
509  // Invocation functions for typed output ports
510  // ----------------------------------------------------------------------
511 
514  FwIndexType portNum,
515  FwSizeType size
516  );
517 
519  void deallocate_out(
520  FwIndexType portNum,
521  Fw::Buffer& fwBuffer
522  );
523 
525  void ready_out(
526  FwIndexType portNum
527  );
528 
530  void recv_out(
531  FwIndexType portNum,
532  Fw::Buffer& buffer,
533  const Drv::ByteStreamStatus& status
534  );
535 
536  protected:
537 
538  // ----------------------------------------------------------------------
539  // Event logging functions
540  // ----------------------------------------------------------------------
541 
546  const Fw::StringBase& device,
547  I32 error,
548  const Fw::StringBase& name
549  ) const;
550 
555  const Fw::StringBase& device,
556  I32 error
557  ) const;
558 
563  const Fw::StringBase& device,
564  I32 error
565  );
566 
571  const Fw::StringBase& device,
572  I32 error
573  );
574 
579  const Fw::StringBase& device
580  ) const;
581 
586  const Fw::StringBase& device
587  );
588 
593  const Fw::StringBase& device,
594  U32 size,
595  U32 needed
596  ) const;
597 
598  protected:
599 
600  // ----------------------------------------------------------------------
601  // Event throttle reset functions
602  // ----------------------------------------------------------------------
603 
606 
609 
612 
613  protected:
614 
615  // ----------------------------------------------------------------------
616  // Telemetry write functions
617  // ----------------------------------------------------------------------
618 
622  void tlmWrite_BytesSent(
623  FwSizeType arg,
624  Fw::Time _tlmTime = Fw::Time()
625  ) const;
626 
630  void tlmWrite_BytesRecv(
631  FwSizeType arg,
632  Fw::Time _tlmTime = Fw::Time()
633  ) const;
634 
635  protected:
636 
637  // ----------------------------------------------------------------------
638  // Time
639  // ----------------------------------------------------------------------
640 
644  Fw::Time getTime() const;
645 
646  protected:
647 
648  // ----------------------------------------------------------------------
649  // Mutex operations for guarded ports
650  //
651  // You can override these operations to provide more sophisticated
652  // synchronization
653  // ----------------------------------------------------------------------
654 
656  virtual void lock();
657 
659  virtual void unLock();
660 
661  private:
662 
663  // ----------------------------------------------------------------------
664  // Calls for messages received on typed input ports
665  // ----------------------------------------------------------------------
666 
668  static void m_p_recvReturnIn_in(
669  Fw::PassiveComponentBase* callComp,
670  FwIndexType portNum,
671  Fw::Buffer& fwBuffer
672  );
673 
675  static void m_p_run_in(
676  Fw::PassiveComponentBase* callComp,
677  FwIndexType portNum,
678  U32 context
679  );
680 
682  static Drv::ByteStreamStatus m_p_send_in(
683  Fw::PassiveComponentBase* callComp,
684  FwIndexType portNum,
685  Fw::Buffer& sendBuffer
686  );
687 
688  private:
689 
690  // ----------------------------------------------------------------------
691  // Typed input ports
692  // ----------------------------------------------------------------------
693 
695  Fw::InputBufferSendPort m_recvReturnIn_InputPort[NUM_RECVRETURNIN_INPUT_PORTS];
696 
698  Svc::InputSchedPort m_run_InputPort[NUM_RUN_INPUT_PORTS];
699 
702 
703  private:
704 
705  // ----------------------------------------------------------------------
706  // Special output ports
707  // ----------------------------------------------------------------------
708 
710  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
711 
712 #if FW_ENABLE_TEXT_LOGGING == 1
713 
715  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
716 
717 #endif
718 
720  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
721 
723  Fw::OutputTlmPort m_Tlm_OutputPort[NUM_TLM_OUTPUT_PORTS];
724 
725  private:
726 
727  // ----------------------------------------------------------------------
728  // Typed output ports
729  // ----------------------------------------------------------------------
730 
732  Fw::OutputBufferGetPort m_allocate_OutputPort[NUM_ALLOCATE_OUTPUT_PORTS];
733 
735  Fw::OutputBufferSendPort m_deallocate_OutputPort[NUM_DEALLOCATE_OUTPUT_PORTS];
736 
739 
742 
743  private:
744 
745  // ----------------------------------------------------------------------
746  // Counter values for event throttling
747  // ----------------------------------------------------------------------
748 
750  std::atomic<FwIndexType> m_WriteErrorThrottle;
751 
753  std::atomic<FwIndexType> m_ReadErrorThrottle;
754 
756  std::atomic<FwIndexType> m_NoBuffersThrottle;
757 
758  private:
759 
760  // ----------------------------------------------------------------------
761  // Mutexes
762  // ----------------------------------------------------------------------
763 
765  Os::Mutex m_guardedPortMutex;
766 
767  };
768 
769 }
770 
771 #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()