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 
17 #include "Fw/FPrimeBasicTypes.hpp"
18 #include "Fw/Log/LogPortAc.hpp"
19 #include "Fw/Log/LogString.hpp"
20 #if FW_ENABLE_TEXT_LOGGING == 1
21 #include "Fw/Log/LogTextPortAc.hpp"
22 #endif
25 #include "Fw/Time/TimePortAc.hpp"
26 #include "Fw/Tlm/TlmPortAc.hpp"
27 #include "Fw/Tlm/TlmString.hpp"
28 #include "Os/Mutex.hpp"
29 
30 namespace Drv {
31 
36  {
37 
38  // ----------------------------------------------------------------------
39  // Friend classes
40  // ----------------------------------------------------------------------
41 
45  friend class LinuxUartDriverTester;
46 
47  PROTECTED:
48 
49  // ----------------------------------------------------------------------
50  // Constants
51  // ----------------------------------------------------------------------
52 
54  enum {
57  };
58 
60  enum {
65  };
66 
68  enum {
74  };
75 
77  enum {
85  };
86 
88  enum {
92  };
93 
95  enum {
98  };
99 
100  public:
101 
102  // ----------------------------------------------------------------------
103  // Component initialization
104  // ----------------------------------------------------------------------
105 
107  void init(
108  FwEnumStoreType instance = 0
109  );
110 
111  public:
112 
113  // ----------------------------------------------------------------------
114  // Getters for typed input ports
115  // ----------------------------------------------------------------------
116 
121  FwIndexType portNum
122  );
123 
128  FwIndexType portNum
129  );
130 
131  public:
132 
133  // ----------------------------------------------------------------------
134  // Connect input ports to special output ports
135  // ----------------------------------------------------------------------
136 
138  void set_Log_OutputPort(
139  FwIndexType portNum,
140  Fw::InputLogPort* port
141  );
142 
143 #if FW_ENABLE_TEXT_LOGGING == 1
144 
146  void set_LogText_OutputPort(
147  FwIndexType portNum,
148  Fw::InputLogTextPort* port
149  );
150 
151 #endif
152 
154  void set_Time_OutputPort(
155  FwIndexType portNum,
156  Fw::InputTimePort* port
157  );
158 
160  void set_Tlm_OutputPort(
161  FwIndexType portNum,
162  Fw::InputTlmPort* port
163  );
164 
165  public:
166 
167  // ----------------------------------------------------------------------
168  // Connect typed input ports to typed output ports
169  // ----------------------------------------------------------------------
170 
173  FwIndexType portNum,
175  );
176 
179  FwIndexType portNum,
181  );
182 
185  FwIndexType portNum,
187  );
188 
190  void set_recv_OutputPort(
191  FwIndexType portNum,
193  );
194 
197  FwIndexType portNum,
199  );
200 
201 #if FW_PORT_SERIALIZATION
202 
203  public:
204 
205  // ----------------------------------------------------------------------
206  // Connect serial input ports to special output ports
207  // ----------------------------------------------------------------------
208 
210  void set_Log_OutputPort(
211  FwIndexType portNum,
212  Fw::InputSerializePort* port
213  );
214 
215 #if FW_ENABLE_TEXT_LOGGING == 1
216 
218  void set_LogText_OutputPort(
219  FwIndexType portNum,
220  Fw::InputSerializePort* port
221  );
222 
223 #endif
224 
226  void set_Time_OutputPort(
227  FwIndexType portNum,
228  Fw::InputSerializePort* port
229  );
230 
232  void set_Tlm_OutputPort(
233  FwIndexType portNum,
234  Fw::InputSerializePort* port
235  );
236 
237 #endif
238 
239 #if FW_PORT_SERIALIZATION
240 
241  public:
242 
243  // ----------------------------------------------------------------------
244  // Connect serial input ports to typed output ports
245  // ----------------------------------------------------------------------
246 
249  FwIndexType portNum,
250  Fw::InputSerializePort* port
251  );
252 
255  FwIndexType portNum,
256  Fw::InputSerializePort* port
257  );
258 
260  void set_recv_OutputPort(
261  FwIndexType portNum,
262  Fw::InputSerializePort* port
263  );
264 
267  FwIndexType portNum,
268  Fw::InputSerializePort* port
269  );
270 
271 #endif
272 
273  PROTECTED:
274 
275  // ----------------------------------------------------------------------
276  // Component construction and destruction
277  // ----------------------------------------------------------------------
278 
281  const char* compName = ""
282  );
283 
286 
287  PROTECTED:
288 
289  // ----------------------------------------------------------------------
290  // Getters for numbers of typed input ports
291  // ----------------------------------------------------------------------
292 
297 
302 
303  PROTECTED:
304 
305  // ----------------------------------------------------------------------
306  // Getters for numbers of special output ports
307  // ----------------------------------------------------------------------
308 
313 
314 #if FW_ENABLE_TEXT_LOGGING == 1
315 
319  FwIndexType getNum_LogText_OutputPorts() const;
320 
321 #endif
322 
327 
332 
333  PROTECTED:
334 
335  // ----------------------------------------------------------------------
336  // Getters for numbers of typed output ports
337  // ----------------------------------------------------------------------
338 
343 
348 
353 
358 
363 
364  PROTECTED:
365 
366  // ----------------------------------------------------------------------
367  // Connection status queries for special output ports
368  // ----------------------------------------------------------------------
369 
374  FwIndexType portNum
375  );
376 
377 #if FW_ENABLE_TEXT_LOGGING == 1
378 
382  bool isConnected_LogText_OutputPort(
383  FwIndexType portNum
384  );
385 
386 #endif
387 
392  FwIndexType portNum
393  );
394 
399  FwIndexType portNum
400  );
401 
402  PROTECTED:
403 
404  // ----------------------------------------------------------------------
405  // Connection status queries for typed output ports
406  // ----------------------------------------------------------------------
407 
412  FwIndexType portNum
413  );
414 
419  FwIndexType portNum
420  );
421 
426  FwIndexType portNum
427  );
428 
433  FwIndexType portNum
434  );
435 
440  FwIndexType portNum
441  );
442 
443  PROTECTED:
444 
445  // ----------------------------------------------------------------------
446  // Handlers to implement for typed input ports
447  // ----------------------------------------------------------------------
448 
450  virtual void recvReturnIn_handler(
451  FwIndexType portNum,
452  Fw::Buffer& fwBuffer
453  ) = 0;
454 
456  virtual void send_handler(
457  FwIndexType portNum,
458  Fw::Buffer& fwBuffer
459  ) = 0;
460 
461  PROTECTED:
462 
463  // ----------------------------------------------------------------------
464  // Port handler base-class functions for typed input ports
465  //
466  // Call these functions directly to bypass the corresponding ports
467  // ----------------------------------------------------------------------
468 
471  FwIndexType portNum,
472  Fw::Buffer& fwBuffer
473  );
474 
476  void send_handlerBase(
477  FwIndexType portNum,
478  Fw::Buffer& fwBuffer
479  );
480 
481  PROTECTED:
482 
483  // ----------------------------------------------------------------------
484  // Invocation functions for typed output ports
485  // ----------------------------------------------------------------------
486 
489  FwIndexType portNum,
490  U32 size
491  );
492 
494  void deallocate_out(
495  FwIndexType portNum,
496  Fw::Buffer& fwBuffer
497  );
498 
500  void ready_out(
501  FwIndexType portNum
502  );
503 
505  void recv_out(
506  FwIndexType portNum,
507  Fw::Buffer& buffer,
508  const Drv::ByteStreamStatus& status
509  );
510 
512  void sendReturnOut_out(
513  FwIndexType portNum,
514  Fw::Buffer& buffer,
515  const Drv::ByteStreamStatus& status
516  );
517 
518  PROTECTED:
519 
520  // ----------------------------------------------------------------------
521  // Event logging functions
522  // ----------------------------------------------------------------------
523 
528  const Fw::StringBase& device,
529  I32 error,
530  const Fw::StringBase& name
531  ) const;
532 
537  const Fw::StringBase& device,
538  I32 error
539  ) const;
540 
545  const Fw::StringBase& device,
546  I32 error
547  );
548 
553  const Fw::StringBase& device,
554  I32 error
555  );
556 
561  const Fw::StringBase& device
562  ) const;
563 
568  const Fw::StringBase& device
569  );
570 
575  const Fw::StringBase& device,
576  U32 size,
577  U32 needed
578  ) const;
579 
580  PROTECTED:
581 
582  // ----------------------------------------------------------------------
583  // Event throttle reset functions
584  // ----------------------------------------------------------------------
585 
588 
591 
594 
595  PROTECTED:
596 
597  // ----------------------------------------------------------------------
598  // Telemetry write functions
599  // ----------------------------------------------------------------------
600 
604  void tlmWrite_BytesSent(
605  U32 arg,
606  Fw::Time _tlmTime = Fw::Time()
607  ) const;
608 
612  void tlmWrite_BytesRecv(
613  U32 arg,
614  Fw::Time _tlmTime = Fw::Time()
615  ) const;
616 
617  PROTECTED:
618 
619  // ----------------------------------------------------------------------
620  // Time
621  // ----------------------------------------------------------------------
622 
626  Fw::Time getTime() const;
627 
628  PROTECTED:
629 
630  // ----------------------------------------------------------------------
631  // Mutex operations for guarded ports
632  //
633  // You can override these operations to provide more sophisticated
634  // synchronization
635  // ----------------------------------------------------------------------
636 
638  virtual void lock();
639 
641  virtual void unLock();
642 
643  PRIVATE:
644 
645  // ----------------------------------------------------------------------
646  // Calls for messages received on typed input ports
647  // ----------------------------------------------------------------------
648 
650  static void m_p_recvReturnIn_in(
651  Fw::PassiveComponentBase* callComp,
652  FwIndexType portNum,
653  Fw::Buffer& fwBuffer
654  );
655 
657  static void m_p_send_in(
658  Fw::PassiveComponentBase* callComp,
659  FwIndexType portNum,
660  Fw::Buffer& fwBuffer
661  );
662 
663  PRIVATE:
664 
665  // ----------------------------------------------------------------------
666  // Typed input ports
667  // ----------------------------------------------------------------------
668 
670  Fw::InputBufferSendPort m_recvReturnIn_InputPort[NUM_RECVRETURNIN_INPUT_PORTS];
671 
674 
675  PRIVATE:
676 
677  // ----------------------------------------------------------------------
678  // Special output ports
679  // ----------------------------------------------------------------------
680 
682  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
683 
684 #if FW_ENABLE_TEXT_LOGGING == 1
685 
687  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
688 
689 #endif
690 
692  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
693 
695  Fw::OutputTlmPort m_Tlm_OutputPort[NUM_TLM_OUTPUT_PORTS];
696 
697  PRIVATE:
698 
699  // ----------------------------------------------------------------------
700  // Typed output ports
701  // ----------------------------------------------------------------------
702 
704  Fw::OutputBufferGetPort m_allocate_OutputPort[NUM_ALLOCATE_OUTPUT_PORTS];
705 
707  Fw::OutputBufferSendPort m_deallocate_OutputPort[NUM_DEALLOCATE_OUTPUT_PORTS];
708 
711 
714 
717 
718  PRIVATE:
719 
720  // ----------------------------------------------------------------------
721  // Counter values for event throttling
722  // ----------------------------------------------------------------------
723 
725  std::atomic<FwIndexType> m_WriteErrorThrottle;
726 
728  std::atomic<FwIndexType> m_ReadErrorThrottle;
729 
731  std::atomic<FwIndexType> m_NoBuffersThrottle;
732 
733  PRIVATE:
734 
735  // ----------------------------------------------------------------------
736  // Mutexes
737  // ----------------------------------------------------------------------
738 
740  Os::Mutex m_guardedPortMutex;
741 
742  };
743 
744 }
745 
746 #endif
virtual void lock()
Lock the guarded mutex.
virtual void unLock()
Unlock the guarded mutex.
bool isConnected_deallocate_OutputPort(FwIndexType portNum)
Definition: Time.hpp:9
void log_WARNING_HI_BufferTooSmall(const Fw::StringBase &device, U32 size, U32 needed) const
bool isConnected_Time_OutputPort(FwIndexType portNum)
void sendReturnOut_out(FwIndexType portNum, Fw::Buffer &buffer, const Drv::ByteStreamStatus &status)
Invoke output port sendReturnOut.
void recvReturnIn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port recvReturnIn.
I32 FwEnumStoreType
bool isConnected_allocate_OutputPort(FwIndexType portNum)
void set_Tlm_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
bool isConnected_sendReturnOut_OutputPort(FwIndexType 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.
Fw::Buffer allocate_out(FwIndexType portNum, U32 size)
Invoke output port allocate.
LinuxUartDriverComponentBase(const char *compName="")
Construct LinuxUartDriverComponentBase object.
Auto-generated base for LinuxUartDriver component.
void log_WARNING_HI_WriteError(const Fw::StringBase &device, I32 error)
void set_sendReturnOut_OutputPort(FwIndexType portNum, Drv::InputByteStreamDataPort *port)
Connect port to sendReturnOut[portNum].
virtual void send_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port send.
void set_ready_OutputPort(FwIndexType portNum, Drv::InputByteStreamReadyPort *port)
Connect port to ready[portNum].
void init()
Object initializer.
Definition: ObjBase.cpp:26
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.
void tlmWrite_BytesRecv(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
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
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.
bool isConnected_Tlm_OutputPort(FwIndexType portNum)
void tlmWrite_BytesSent(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
bool isConnected_recv_OutputPort(FwIndexType portNum)
void set_deallocate_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to deallocate[portNum].
PlatformIndexType FwIndexType
Fw::InputBufferSendPort * get_send_InputPort(FwIndexType portNum)
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 log_WARNING_HI_ReadError_ThrottleClear()
Reset throttle value for ReadError.
void send_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port send.
void log_WARNING_HI_ConfigError(const Fw::StringBase &device, I32 error) const