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
24 #if !FW_DIRECT_PORT_CALLS
26 #endif
27 #if !FW_DIRECT_PORT_CALLS
29 #endif
30 #include "Fw/Time/TimePortAc.hpp"
31 #include "Fw/Tlm/TlmPortAc.hpp"
32 #include "Fw/Tlm/TlmString.hpp"
33 #include "Os/Mutex.hpp"
37 
38 namespace Drv {
39 
44  {
45 
46  // ----------------------------------------------------------------------
47  // Friend classes
48  // ----------------------------------------------------------------------
49 
53  friend class LinuxUartDriverTester;
54 
55  protected:
56 
57  // ----------------------------------------------------------------------
58  // Constants
59  // ----------------------------------------------------------------------
60 
62  enum {
66  };
67 
69  enum {
74  };
75 
77  enum {
82  };
83 
85  enum {
93  };
94 
96  enum {
100  };
101 
103  enum {
106  };
107 
108  public:
109 
110  // ----------------------------------------------------------------------
111  // Component initialization
112  // ----------------------------------------------------------------------
113 
115  void init(
116  FwEnumStoreType instance = 0
117  );
118 
119 #if !FW_DIRECT_PORT_CALLS
120 
121  public:
122 
123  // ----------------------------------------------------------------------
124  // Getters for typed input ports
125  // ----------------------------------------------------------------------
126 
131  FwIndexType portNum
132  );
133 
138  FwIndexType portNum
139  );
140 
145  FwIndexType portNum
146  );
147 
148 #endif
149 
150 #if !FW_DIRECT_PORT_CALLS
151 
152  public:
153 
154  // ----------------------------------------------------------------------
155  // Connect input ports to special output ports
156  // ----------------------------------------------------------------------
157 
159  void set_Log_OutputPort(
160  FwIndexType portNum,
161  Fw::InputLogPort* port
162  );
163 
164 #if FW_ENABLE_TEXT_LOGGING == 1
165 
167  void set_LogText_OutputPort(
168  FwIndexType portNum,
169  Fw::InputLogTextPort* port
170  );
171 
172 #endif
173 
175  void set_Time_OutputPort(
176  FwIndexType portNum,
177  Fw::InputTimePort* port
178  );
179 
181  void set_Tlm_OutputPort(
182  FwIndexType portNum,
183  Fw::InputTlmPort* port
184  );
185 
186 #endif
187 
188 #if !FW_DIRECT_PORT_CALLS
189 
190  public:
191 
192  // ----------------------------------------------------------------------
193  // Connect typed input ports to typed output ports
194  // ----------------------------------------------------------------------
195 
198  FwIndexType portNum,
200  );
201 
204  FwIndexType portNum,
206  );
207 
210  FwIndexType portNum,
212  );
213 
215  void set_recv_OutputPort(
216  FwIndexType portNum,
218  );
219 
220 #endif
221 
222 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
223 
224  public:
225 
226  // ----------------------------------------------------------------------
227  // Connect serial input ports to special output ports
228  // ----------------------------------------------------------------------
229 
231  void set_Log_OutputPort(
232  FwIndexType portNum,
233  Fw::InputSerializePort* port
234  );
235 
236 #if FW_ENABLE_TEXT_LOGGING == 1
237 
239  void set_LogText_OutputPort(
240  FwIndexType portNum,
241  Fw::InputSerializePort* port
242  );
243 
244 #endif
245 
247  void set_Time_OutputPort(
248  FwIndexType portNum,
249  Fw::InputSerializePort* port
250  );
251 
253  void set_Tlm_OutputPort(
254  FwIndexType portNum,
255  Fw::InputSerializePort* port
256  );
257 
258 #endif
259 
260 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
261 
262  public:
263 
264  // ----------------------------------------------------------------------
265  // Connect serial input ports to typed output ports
266  // ----------------------------------------------------------------------
267 
270  FwIndexType portNum,
271  Fw::InputSerializePort* port
272  );
273 
276  FwIndexType portNum,
277  Fw::InputSerializePort* port
278  );
279 
281  void set_recv_OutputPort(
282  FwIndexType portNum,
283  Fw::InputSerializePort* port
284  );
285 
286 #endif
287 
288  protected:
289 
290  // ----------------------------------------------------------------------
291  // Component construction and destruction
292  // ----------------------------------------------------------------------
293 
296  const char* compName = ""
297  );
298 
301 
302  protected:
303 
304  // ----------------------------------------------------------------------
305  // Getters for numbers of typed input ports
306  // ----------------------------------------------------------------------
307 
313  }
314 
318  static constexpr FwIndexType getNum_run_InputPorts() {
319  return NUM_RUN_INPUT_PORTS;
320  }
321 
325  static constexpr FwIndexType getNum_send_InputPorts() {
326  return NUM_SEND_INPUT_PORTS;
327  }
328 
329  protected:
330 
331  // ----------------------------------------------------------------------
332  // Getters for numbers of special output ports
333  // ----------------------------------------------------------------------
334 
338  static constexpr FwIndexType getNum_Log_OutputPorts() {
339  return NUM_LOG_OUTPUT_PORTS;
340  }
341 
342 #if FW_ENABLE_TEXT_LOGGING == 1
343 
347  static constexpr FwIndexType getNum_LogText_OutputPorts() {
349  }
350 
351 #endif
352 
357  return NUM_TIME_OUTPUT_PORTS;
358  }
359 
363  static constexpr FwIndexType getNum_Tlm_OutputPorts() {
364  return NUM_TLM_OUTPUT_PORTS;
365  }
366 
367  protected:
368 
369  // ----------------------------------------------------------------------
370  // Getters for numbers of typed output ports
371  // ----------------------------------------------------------------------
372 
378  }
379 
385  }
386 
391  return NUM_READY_OUTPUT_PORTS;
392  }
393 
398  return NUM_RECV_OUTPUT_PORTS;
399  }
400 
401  protected:
402 
403  // ----------------------------------------------------------------------
404  // Connection status queries for special output ports
405  // ----------------------------------------------------------------------
406 
411  FwIndexType portNum
412  ) const;
413 
414 #if FW_ENABLE_TEXT_LOGGING == 1
415 
419  bool isConnected_LogText_OutputPort(
420  FwIndexType portNum
421  ) const;
422 
423 #endif
424 
429  FwIndexType portNum
430  ) const;
431 
436  FwIndexType portNum
437  ) const;
438 
439  protected:
440 
441  // ----------------------------------------------------------------------
442  // Connection status queries for typed output ports
443  // ----------------------------------------------------------------------
444 
449  FwIndexType portNum
450  ) const;
451 
456  FwIndexType portNum
457  ) const;
458 
463  FwIndexType portNum
464  ) const;
465 
470  FwIndexType portNum
471  ) const;
472 
473  protected:
474 
475  // ----------------------------------------------------------------------
476  // Handlers to implement for typed input ports
477  // ----------------------------------------------------------------------
478 
480  virtual void recvReturnIn_handler(
481  FwIndexType portNum,
482  Fw::Buffer& fwBuffer
483  ) = 0;
484 
486  virtual void run_handler(
487  FwIndexType portNum,
488  U32 context
489  ) = 0;
490 
493  FwIndexType portNum,
494  Fw::Buffer& sendBuffer
495  ) = 0;
496 
497 #if FW_DIRECT_PORT_CALLS
498  public:
499 #else
500  protected:
501 #endif
502 
503  // ----------------------------------------------------------------------
504  // Port handler base-class functions for typed input ports
505  //
506  // Call these functions directly to bypass the corresponding ports
507  // ----------------------------------------------------------------------
508 
511  FwIndexType portNum,
512  Fw::Buffer& fwBuffer
513  );
514 
516  void run_handlerBase(
517  FwIndexType portNum,
518  U32 context
519  );
520 
523  FwIndexType portNum,
524  Fw::Buffer& sendBuffer
525  );
526 
527  protected:
528 
529  // ----------------------------------------------------------------------
530  // Invocation functions for typed output ports
531  // ----------------------------------------------------------------------
532 
535  FwIndexType portNum,
536  FwSizeType size
537  ) const;
538 
540  void deallocate_out(
541  FwIndexType portNum,
542  Fw::Buffer& fwBuffer
543  ) const;
544 
546  void ready_out(
547  FwIndexType portNum
548  ) const;
549 
551  void recv_out(
552  FwIndexType portNum,
553  Fw::Buffer& buffer,
554  const Drv::ByteStreamStatus& status
555  ) const;
556 
557  protected:
558 
559  // ----------------------------------------------------------------------
560  // Event logging functions
561  // ----------------------------------------------------------------------
562 
567  const Fw::StringBase& device,
568  I32 error,
569  const Fw::StringBase& name
570  ) const;
571 
576  const Fw::StringBase& device,
577  I32 error
578  ) const;
579 
584  const Fw::StringBase& device,
585  I32 error
586  );
587 
592  const Fw::StringBase& device,
593  I32 error
594  );
595 
600  const Fw::StringBase& device
601  ) const;
602 
607  const Fw::StringBase& device
608  );
609 
614  const Fw::StringBase& device,
615  U32 size,
616  U32 needed
617  ) const;
618 
619  protected:
620 
621  // ----------------------------------------------------------------------
622  // Event throttle reset functions
623  // ----------------------------------------------------------------------
624 
627 
630 
633 
634  protected:
635 
636  // ----------------------------------------------------------------------
637  // Telemetry serialized write
638  // ----------------------------------------------------------------------
639 
644  void tlmWrite(
645  FwChanIdType id,
646  Fw::TlmBuffer& _tlmBuff,
647  Fw::Time _tlmTime = Fw::Time()
648  ) const;
649 
650  protected:
651 
652  // ----------------------------------------------------------------------
653  // Telemetry write functions
654  // ----------------------------------------------------------------------
655 
659  void tlmWrite_BytesSent(
660  FwSizeType arg,
661  Fw::Time _tlmTime = Fw::Time()
662  ) const;
663 
667  void tlmWrite_BytesRecv(
668  FwSizeType arg,
669  Fw::Time _tlmTime = Fw::Time()
670  ) const;
671 
672  protected:
673 
674  // ----------------------------------------------------------------------
675  // Time
676  // ----------------------------------------------------------------------
677 
681  Fw::Time getTime() const;
682 
683  protected:
684 
685  // ----------------------------------------------------------------------
686  // Mutex operations for guarded ports
687  //
688  // You can override these operations to provide more sophisticated
689  // synchronization
690  // ----------------------------------------------------------------------
691 
693  virtual void lock();
694 
696  virtual void unLock();
697 
698  private:
699 
700  // ----------------------------------------------------------------------
701  // Calls for messages received on typed input ports
702  // ----------------------------------------------------------------------
703 
705  static void m_p_recvReturnIn_in(
706  Fw::PassiveComponentBase* callComp,
707  FwIndexType portNum,
708  Fw::Buffer& fwBuffer
709  );
710 
712  static void m_p_run_in(
713  Fw::PassiveComponentBase* callComp,
714  FwIndexType portNum,
715  U32 context
716  );
717 
719  static Drv::ByteStreamStatus m_p_send_in(
720  Fw::PassiveComponentBase* callComp,
721  FwIndexType portNum,
722  Fw::Buffer& sendBuffer
723  );
724 
725  private:
726 
727  // ----------------------------------------------------------------------
728  // Invocation functions for special output ports
729  // ----------------------------------------------------------------------
730 
732  void Log_out(
733  FwIndexType portNum,
734  FwEventIdType id,
735  Fw::Time& timeTag,
736  const Fw::LogSeverity& severity,
737  Fw::LogBuffer& args
738  ) const;
739 
740 #if FW_ENABLE_TEXT_LOGGING
741 
743  void LogText_out(
744  FwIndexType portNum,
745  FwEventIdType id,
746  Fw::Time& timeTag,
747  const Fw::LogSeverity& severity,
748  Fw::TextLogString& text
749  ) const;
750 
751 #endif
752 
754  void Time_out(
755  FwIndexType portNum,
756  Fw::Time& time
757  ) const;
758 
760  void Tlm_out(
761  FwIndexType portNum,
762  FwChanIdType id,
763  Fw::Time& timeTag,
764  Fw::TlmBuffer& val
765  ) const;
766 
767 #if !FW_DIRECT_PORT_CALLS
768 
769  private:
770 
771  // ----------------------------------------------------------------------
772  // Typed input ports
773  // ----------------------------------------------------------------------
774 
776  Fw::InputBufferSendPort m_recvReturnIn_InputPort[NUM_RECVRETURNIN_INPUT_PORTS];
777 
779  Svc::InputSchedPort m_run_InputPort[NUM_RUN_INPUT_PORTS];
780 
783 
784 #endif
785 
786 #if !FW_DIRECT_PORT_CALLS
787 
788  private:
789 
790  // ----------------------------------------------------------------------
791  // Special output ports
792  // ----------------------------------------------------------------------
793 
795  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
796 
797 #if FW_ENABLE_TEXT_LOGGING == 1
798 
800  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
801 
802 #endif
803 
805  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
806 
808  Fw::OutputTlmPort m_Tlm_OutputPort[NUM_TLM_OUTPUT_PORTS];
809 
810 #endif
811 
812 #if !FW_DIRECT_PORT_CALLS
813 
814  private:
815 
816  // ----------------------------------------------------------------------
817  // Typed output ports
818  // ----------------------------------------------------------------------
819 
821  Fw::OutputBufferGetPort m_allocate_OutputPort[NUM_ALLOCATE_OUTPUT_PORTS];
822 
824  Fw::OutputBufferSendPort m_deallocate_OutputPort[NUM_DEALLOCATE_OUTPUT_PORTS];
825 
828 
831 
832 #endif
833 
834  private:
835 
836  // ----------------------------------------------------------------------
837  // Counter values for event throttling
838  // ----------------------------------------------------------------------
839 
841  std::atomic<FwIndexType> m_WriteErrorThrottle;
842 
844  std::atomic<FwIndexType> m_ReadErrorThrottle;
845 
847  std::atomic<FwIndexType> m_NoBuffersThrottle;
848 
849  private:
850 
851  // ----------------------------------------------------------------------
852  // Mutexes
853  // ----------------------------------------------------------------------
854 
856  Os::Mutex m_guardedPortMutex;
857 
858  };
859 
860 }
861 
862 #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()