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 #include "Fw/Log/LogTextPortAc.hpp"
22 #if !FW_DIRECT_PORT_CALLS
24 #endif
25 #if !FW_DIRECT_PORT_CALLS
27 #endif
28 #include "Fw/Time/TimePortAc.hpp"
29 #include "Fw/Tlm/TlmPortAc.hpp"
30 #include "Fw/Tlm/TlmString.hpp"
31 #include "Os/Mutex.hpp"
35 
36 namespace Drv {
37 
42  {
43 
44  // ----------------------------------------------------------------------
45  // Friend classes
46  // ----------------------------------------------------------------------
47 
51  friend class LinuxUartDriverTester;
52 
53  protected:
54 
55  // ----------------------------------------------------------------------
56  // Constants
57  // ----------------------------------------------------------------------
58 
60  enum {
64  };
65 
67  enum {
72  };
73 
75  enum {
80  };
81 
83  enum {
91  };
92 
94  enum {
98  };
99 
101  enum {
104  };
105 
106  public:
107 
108  // ----------------------------------------------------------------------
109  // Component initialization
110  // ----------------------------------------------------------------------
111 
113  void init(
114  FwEnumStoreType instance = 0
115  );
116 
117 #if !FW_DIRECT_PORT_CALLS
118 
119  public:
120 
121  // ----------------------------------------------------------------------
122  // Getters for typed input ports
123  // ----------------------------------------------------------------------
124 
129  FwIndexType portNum
130  );
131 
136  FwIndexType portNum
137  );
138 
143  FwIndexType portNum
144  );
145 
146 #endif
147 
148 #if !FW_DIRECT_PORT_CALLS
149 
150  public:
151 
152  // ----------------------------------------------------------------------
153  // Connect input ports to special output ports
154  // ----------------------------------------------------------------------
155 
157  void set_Log_OutputPort(
158  FwIndexType portNum,
159  Fw::InputLogPort* port
160  );
161 
162 #if FW_ENABLE_TEXT_LOGGING == 1
163 
165  void set_LogText_OutputPort(
166  FwIndexType portNum,
167  Fw::InputLogTextPort* port
168  );
169 
170 #endif
171 
173  void set_Time_OutputPort(
174  FwIndexType portNum,
175  Fw::InputTimePort* port
176  );
177 
179  void set_Tlm_OutputPort(
180  FwIndexType portNum,
181  Fw::InputTlmPort* port
182  );
183 
184 #endif
185 
186 #if !FW_DIRECT_PORT_CALLS
187 
188  public:
189 
190  // ----------------------------------------------------------------------
191  // Connect typed input ports to typed output ports
192  // ----------------------------------------------------------------------
193 
196  FwIndexType portNum,
198  );
199 
202  FwIndexType portNum,
204  );
205 
208  FwIndexType portNum,
210  );
211 
213  void set_recv_OutputPort(
214  FwIndexType portNum,
216  );
217 
218 #endif
219 
220 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
221 
222  public:
223 
224  // ----------------------------------------------------------------------
225  // Connect serial input ports to special output ports
226  // ----------------------------------------------------------------------
227 
229  void set_Log_OutputPort(
230  FwIndexType portNum,
231  Fw::InputSerializePort* port
232  );
233 
234 #if FW_ENABLE_TEXT_LOGGING == 1
235 
237  void set_LogText_OutputPort(
238  FwIndexType portNum,
239  Fw::InputSerializePort* port
240  );
241 
242 #endif
243 
245  void set_Time_OutputPort(
246  FwIndexType portNum,
247  Fw::InputSerializePort* port
248  );
249 
251  void set_Tlm_OutputPort(
252  FwIndexType portNum,
253  Fw::InputSerializePort* port
254  );
255 
256 #endif
257 
258 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
259 
260  public:
261 
262  // ----------------------------------------------------------------------
263  // Connect serial input ports to typed output ports
264  // ----------------------------------------------------------------------
265 
268  FwIndexType portNum,
269  Fw::InputSerializePort* port
270  );
271 
274  FwIndexType portNum,
275  Fw::InputSerializePort* port
276  );
277 
279  void set_recv_OutputPort(
280  FwIndexType portNum,
281  Fw::InputSerializePort* port
282  );
283 
284 #endif
285 
286  protected:
287 
288  // ----------------------------------------------------------------------
289  // Component construction and destruction
290  // ----------------------------------------------------------------------
291 
294  const char* compName = ""
295  );
296 
299 
300  protected:
301 
302  // ----------------------------------------------------------------------
303  // Getters for numbers of typed input ports
304  // ----------------------------------------------------------------------
305 
311  }
312 
316  static constexpr FwIndexType getNum_run_InputPorts() {
317  return NUM_RUN_INPUT_PORTS;
318  }
319 
323  static constexpr FwIndexType getNum_send_InputPorts() {
324  return NUM_SEND_INPUT_PORTS;
325  }
326 
327  protected:
328 
329  // ----------------------------------------------------------------------
330  // Getters for numbers of special output ports
331  // ----------------------------------------------------------------------
332 
336  static constexpr FwIndexType getNum_Log_OutputPorts() {
337  return NUM_LOG_OUTPUT_PORTS;
338  }
339 
340 #if FW_ENABLE_TEXT_LOGGING == 1
341 
345  static constexpr FwIndexType getNum_LogText_OutputPorts() {
347  }
348 
349 #endif
350 
355  return NUM_TIME_OUTPUT_PORTS;
356  }
357 
361  static constexpr FwIndexType getNum_Tlm_OutputPorts() {
362  return NUM_TLM_OUTPUT_PORTS;
363  }
364 
365  protected:
366 
367  // ----------------------------------------------------------------------
368  // Getters for numbers of typed output ports
369  // ----------------------------------------------------------------------
370 
376  }
377 
383  }
384 
389  return NUM_READY_OUTPUT_PORTS;
390  }
391 
396  return NUM_RECV_OUTPUT_PORTS;
397  }
398 
399  protected:
400 
401  // ----------------------------------------------------------------------
402  // Connection status queries for special output ports
403  // ----------------------------------------------------------------------
404 
409  FwIndexType portNum
410  ) const;
411 
412 #if FW_ENABLE_TEXT_LOGGING == 1
413 
417  bool isConnected_LogText_OutputPort(
418  FwIndexType portNum
419  ) const;
420 
421 #endif
422 
427  FwIndexType portNum
428  ) const;
429 
434  FwIndexType portNum
435  ) const;
436 
437  protected:
438 
439  // ----------------------------------------------------------------------
440  // Connection status queries for typed output ports
441  // ----------------------------------------------------------------------
442 
447  FwIndexType portNum
448  ) const;
449 
454  FwIndexType portNum
455  ) const;
456 
461  FwIndexType portNum
462  ) const;
463 
468  FwIndexType portNum
469  ) const;
470 
471  protected:
472 
473  // ----------------------------------------------------------------------
474  // Handlers to implement for typed input ports
475  // ----------------------------------------------------------------------
476 
478  virtual void recvReturnIn_handler(
479  FwIndexType portNum,
480  Fw::Buffer& fwBuffer
481  ) = 0;
482 
484  virtual void run_handler(
485  FwIndexType portNum,
486  U32 context
487  ) = 0;
488 
491  FwIndexType portNum,
492  Fw::Buffer& sendBuffer
493  ) = 0;
494 
495 #if FW_DIRECT_PORT_CALLS
496  public:
497 #else
498  protected:
499 #endif
500 
501  // ----------------------------------------------------------------------
502  // Port handler base-class functions for typed input ports
503  //
504  // Call these functions directly to bypass the corresponding ports
505  // ----------------------------------------------------------------------
506 
509  FwIndexType portNum,
510  Fw::Buffer& fwBuffer
511  );
512 
514  void run_handlerBase(
515  FwIndexType portNum,
516  U32 context
517  );
518 
521  FwIndexType portNum,
522  Fw::Buffer& sendBuffer
523  );
524 
525  protected:
526 
527  // ----------------------------------------------------------------------
528  // Invocation functions for typed output ports
529  // ----------------------------------------------------------------------
530 
533  FwIndexType portNum,
534  FwSizeType size
535  ) const;
536 
538  void deallocate_out(
539  FwIndexType portNum,
540  Fw::Buffer& fwBuffer
541  ) const;
542 
544  void ready_out(
545  FwIndexType portNum
546  ) const;
547 
549  void recv_out(
550  FwIndexType portNum,
551  Fw::Buffer& buffer,
552  const Drv::ByteStreamStatus& status
553  ) const;
554 
555  protected:
556 
557  // ----------------------------------------------------------------------
558  // Event logging functions
559  // ----------------------------------------------------------------------
560 
565  const Fw::StringBase& device,
566  I32 error,
567  const Fw::StringBase& name
568  ) const;
569 
574  const Fw::StringBase& device,
575  I32 error
576  ) const;
577 
582  const Fw::StringBase& device,
583  I32 error
584  );
585 
590  const Fw::StringBase& device,
591  I32 error
592  );
593 
598  const Fw::StringBase& device
599  ) const;
600 
605  const Fw::StringBase& device
606  );
607 
612  const Fw::StringBase& device,
613  U32 size,
614  U32 needed
615  ) const;
616 
617  protected:
618 
619  // ----------------------------------------------------------------------
620  // Event throttle reset functions
621  // ----------------------------------------------------------------------
622 
625 
628 
631 
632  protected:
633 
634  // ----------------------------------------------------------------------
635  // Telemetry serialized write
636  // ----------------------------------------------------------------------
637 
642  void tlmWrite(
643  FwChanIdType id,
644  Fw::TlmBuffer& _tlmBuff,
645  Fw::Time _tlmTime = Fw::Time()
646  ) const;
647 
648  protected:
649 
650  // ----------------------------------------------------------------------
651  // Telemetry write functions
652  // ----------------------------------------------------------------------
653 
657  void tlmWrite_BytesSent(
658  FwSizeType arg,
659  Fw::Time _tlmTime = Fw::Time()
660  ) const;
661 
665  void tlmWrite_BytesRecv(
666  FwSizeType arg,
667  Fw::Time _tlmTime = Fw::Time()
668  ) const;
669 
670  protected:
671 
672  // ----------------------------------------------------------------------
673  // Time
674  // ----------------------------------------------------------------------
675 
679  Fw::Time getTime() const;
680 
681  protected:
682 
683  // ----------------------------------------------------------------------
684  // Mutex operations for guarded ports
685  //
686  // You can override these operations to provide more sophisticated
687  // synchronization
688  // ----------------------------------------------------------------------
689 
691  virtual void lock();
692 
694  virtual void unLock();
695 
696  private:
697 
698  // ----------------------------------------------------------------------
699  // Calls for messages received on typed input ports
700  // ----------------------------------------------------------------------
701 
703  static void m_p_recvReturnIn_in(
704  Fw::PassiveComponentBase* callComp,
705  FwIndexType portNum,
706  Fw::Buffer& fwBuffer
707  );
708 
710  static void m_p_run_in(
711  Fw::PassiveComponentBase* callComp,
712  FwIndexType portNum,
713  U32 context
714  );
715 
717  static Drv::ByteStreamStatus m_p_send_in(
718  Fw::PassiveComponentBase* callComp,
719  FwIndexType portNum,
720  Fw::Buffer& sendBuffer
721  );
722 
723  private:
724 
725  // ----------------------------------------------------------------------
726  // Invocation functions for special output ports
727  // ----------------------------------------------------------------------
728 
730  void Log_out(
731  FwIndexType portNum,
732  FwEventIdType id,
733  Fw::Time& timeTag,
734  const Fw::LogSeverity& severity,
735  Fw::LogBuffer& args
736  ) const;
737 
738 #if FW_ENABLE_TEXT_LOGGING
739 
741  void LogText_out(
742  FwIndexType portNum,
743  FwEventIdType id,
744  Fw::Time& timeTag,
745  const Fw::LogSeverity& severity,
746  Fw::TextLogString& text
747  ) const;
748 
749 #endif
750 
752  void Time_out(
753  FwIndexType portNum,
754  Fw::Time& time
755  ) const;
756 
758  void Tlm_out(
759  FwIndexType portNum,
760  FwChanIdType id,
761  Fw::Time& timeTag,
762  Fw::TlmBuffer& val
763  ) const;
764 
765 #if !FW_DIRECT_PORT_CALLS
766 
767  private:
768 
769  // ----------------------------------------------------------------------
770  // Typed input ports
771  // ----------------------------------------------------------------------
772 
774  Fw::InputBufferSendPort m_recvReturnIn_InputPort[NUM_RECVRETURNIN_INPUT_PORTS];
775 
777  Svc::InputSchedPort m_run_InputPort[NUM_RUN_INPUT_PORTS];
778 
781 
782 #endif
783 
784 #if !FW_DIRECT_PORT_CALLS
785 
786  private:
787 
788  // ----------------------------------------------------------------------
789  // Special output ports
790  // ----------------------------------------------------------------------
791 
793  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
794 
795 #if FW_ENABLE_TEXT_LOGGING == 1
796 
798  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
799 
800 #endif
801 
803  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
804 
806  Fw::OutputTlmPort m_Tlm_OutputPort[NUM_TLM_OUTPUT_PORTS];
807 
808 #endif
809 
810 #if !FW_DIRECT_PORT_CALLS
811 
812  private:
813 
814  // ----------------------------------------------------------------------
815  // Typed output ports
816  // ----------------------------------------------------------------------
817 
819  Fw::OutputBufferGetPort m_allocate_OutputPort[NUM_ALLOCATE_OUTPUT_PORTS];
820 
822  Fw::OutputBufferSendPort m_deallocate_OutputPort[NUM_DEALLOCATE_OUTPUT_PORTS];
823 
826 
829 
830 #endif
831 
832  private:
833 
834  // ----------------------------------------------------------------------
835  // Counter values for event throttling
836  // ----------------------------------------------------------------------
837 
839  std::atomic<FwIndexType> m_WriteErrorThrottle;
840 
842  std::atomic<FwIndexType> m_ReadErrorThrottle;
843 
845  std::atomic<FwIndexType> m_NoBuffersThrottle;
846 
847  private:
848 
849  // ----------------------------------------------------------------------
850  // Mutexes
851  // ----------------------------------------------------------------------
852 
854  Os::Mutex m_guardedPortMutex;
855 
856  };
857 
858 }
859 
860 #endif
virtual void lock()
Lock the guarded mutex.
virtual void unLock()
Unlock the guarded mutex.
void ready_out(FwIndexType portNum) const
Invoke output port ready.
void log_WARNING_HI_BufferTooSmall(const Fw::StringBase &device, U32 size, U32 needed) const
static constexpr FwIndexType getNum_deallocate_OutputPorts()
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
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
bool isConnected_ready_OutputPort(FwIndexType portNum) const
void recv_out(FwIndexType portNum, Fw::Buffer &buffer, const Drv::ByteStreamStatus &status) const
Invoke output port recv.
bool isConnected_Log_OutputPort(FwIndexType portNum) const
LinuxUartDriverComponentBase(const char *compName="")
Construct LinuxUartDriverComponentBase object.
bool isConnected_allocate_OutputPort(FwIndexType portNum) const
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)
Fw::InputBufferSendPort * get_recvReturnIn_InputPort(FwIndexType portNum)
FwIdType FwEventIdType
The type of an event identifier.
void deallocate_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port deallocate.
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 log_WARNING_HI_WriteError_ThrottleClear()
Reset throttle value for WriteError.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
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.
void log_ACTIVITY_HI_PortOpened(const Fw::StringBase &device) const
Enum representing event severity.
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.
bool isConnected_deallocate_OutputPort(FwIndexType portNum) const
void tlmWrite(FwChanIdType id, Fw::TlmBuffer &_tlmBuff, Fw::Time _tlmTime=Fw::Time()) const
static constexpr FwIndexType getNum_allocate_OutputPorts()
static constexpr FwIndexType getNum_Time_OutputPorts()
static constexpr FwIndexType getNum_Tlm_OutputPorts()
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.
bool isConnected_Time_OutputPort(FwIndexType portNum) const
void set_deallocate_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to deallocate[portNum].
bool isConnected_Tlm_OutputPort(FwIndexType portNum) const
PlatformIndexType FwIndexType
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
virtual ~LinuxUartDriverComponentBase()
Destroy LinuxUartDriverComponentBase object.
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
bool isConnected_recv_OutputPort(FwIndexType portNum) const
Fw::Buffer allocate_out(FwIndexType portNum, FwSizeType size) const
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()