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 
295 
300 
305 
306  protected:
307 
308  // ----------------------------------------------------------------------
309  // Getters for numbers of special output ports
310  // ----------------------------------------------------------------------
311 
316 
317 #if FW_ENABLE_TEXT_LOGGING == 1
318 
322  FwIndexType getNum_LogText_OutputPorts() const;
323 
324 #endif
325 
330 
335 
336  protected:
337 
338  // ----------------------------------------------------------------------
339  // Getters for numbers of typed output ports
340  // ----------------------------------------------------------------------
341 
346 
351 
356 
361 
362  protected:
363 
364  // ----------------------------------------------------------------------
365  // Connection status queries for special output ports
366  // ----------------------------------------------------------------------
367 
372  FwIndexType portNum
373  );
374 
375 #if FW_ENABLE_TEXT_LOGGING == 1
376 
380  bool isConnected_LogText_OutputPort(
381  FwIndexType portNum
382  );
383 
384 #endif
385 
390  FwIndexType portNum
391  );
392 
397  FwIndexType portNum
398  );
399 
400  protected:
401 
402  // ----------------------------------------------------------------------
403  // Connection status queries for typed output ports
404  // ----------------------------------------------------------------------
405 
410  FwIndexType portNum
411  );
412 
417  FwIndexType portNum
418  );
419 
424  FwIndexType portNum
425  );
426 
431  FwIndexType portNum
432  );
433 
434  protected:
435 
436  // ----------------------------------------------------------------------
437  // Handlers to implement for typed input ports
438  // ----------------------------------------------------------------------
439 
441  virtual void recvReturnIn_handler(
442  FwIndexType portNum,
443  Fw::Buffer& fwBuffer
444  ) = 0;
445 
447  virtual void run_handler(
448  FwIndexType portNum,
449  U32 context
450  ) = 0;
451 
454  FwIndexType portNum,
455  Fw::Buffer& sendBuffer
456  ) = 0;
457 
458  protected:
459 
460  // ----------------------------------------------------------------------
461  // Port handler base-class functions for typed input ports
462  //
463  // Call these functions directly to bypass the corresponding ports
464  // ----------------------------------------------------------------------
465 
468  FwIndexType portNum,
469  Fw::Buffer& fwBuffer
470  );
471 
473  void run_handlerBase(
474  FwIndexType portNum,
475  U32 context
476  );
477 
480  FwIndexType portNum,
481  Fw::Buffer& sendBuffer
482  );
483 
484  protected:
485 
486  // ----------------------------------------------------------------------
487  // Invocation functions for typed output ports
488  // ----------------------------------------------------------------------
489 
492  FwIndexType portNum,
493  FwSizeType size
494  );
495 
497  void deallocate_out(
498  FwIndexType portNum,
499  Fw::Buffer& fwBuffer
500  );
501 
503  void ready_out(
504  FwIndexType portNum
505  );
506 
508  void recv_out(
509  FwIndexType portNum,
510  Fw::Buffer& buffer,
511  const Drv::ByteStreamStatus& status
512  );
513 
514  protected:
515 
516  // ----------------------------------------------------------------------
517  // Event logging functions
518  // ----------------------------------------------------------------------
519 
524  const Fw::StringBase& device,
525  I32 error,
526  const Fw::StringBase& name
527  ) const;
528 
533  const Fw::StringBase& device,
534  I32 error
535  ) const;
536 
541  const Fw::StringBase& device,
542  I32 error
543  );
544 
549  const Fw::StringBase& device,
550  I32 error
551  );
552 
557  const Fw::StringBase& device
558  ) const;
559 
564  const Fw::StringBase& device
565  );
566 
571  const Fw::StringBase& device,
572  U32 size,
573  U32 needed
574  ) const;
575 
576  protected:
577 
578  // ----------------------------------------------------------------------
579  // Event throttle reset functions
580  // ----------------------------------------------------------------------
581 
584 
587 
590 
591  protected:
592 
593  // ----------------------------------------------------------------------
594  // Telemetry write functions
595  // ----------------------------------------------------------------------
596 
600  void tlmWrite_BytesSent(
601  FwSizeType arg,
602  Fw::Time _tlmTime = Fw::Time()
603  ) const;
604 
608  void tlmWrite_BytesRecv(
609  FwSizeType arg,
610  Fw::Time _tlmTime = Fw::Time()
611  ) const;
612 
613  protected:
614 
615  // ----------------------------------------------------------------------
616  // Time
617  // ----------------------------------------------------------------------
618 
622  Fw::Time getTime() const;
623 
624  protected:
625 
626  // ----------------------------------------------------------------------
627  // Mutex operations for guarded ports
628  //
629  // You can override these operations to provide more sophisticated
630  // synchronization
631  // ----------------------------------------------------------------------
632 
634  virtual void lock();
635 
637  virtual void unLock();
638 
639  private:
640 
641  // ----------------------------------------------------------------------
642  // Calls for messages received on typed input ports
643  // ----------------------------------------------------------------------
644 
646  static void m_p_recvReturnIn_in(
647  Fw::PassiveComponentBase* callComp,
648  FwIndexType portNum,
649  Fw::Buffer& fwBuffer
650  );
651 
653  static void m_p_run_in(
654  Fw::PassiveComponentBase* callComp,
655  FwIndexType portNum,
656  U32 context
657  );
658 
660  static Drv::ByteStreamStatus m_p_send_in(
661  Fw::PassiveComponentBase* callComp,
662  FwIndexType portNum,
663  Fw::Buffer& sendBuffer
664  );
665 
666  private:
667 
668  // ----------------------------------------------------------------------
669  // Typed input ports
670  // ----------------------------------------------------------------------
671 
673  Fw::InputBufferSendPort m_recvReturnIn_InputPort[NUM_RECVRETURNIN_INPUT_PORTS];
674 
676  Svc::InputSchedPort m_run_InputPort[NUM_RUN_INPUT_PORTS];
677 
680 
681  private:
682 
683  // ----------------------------------------------------------------------
684  // Special output ports
685  // ----------------------------------------------------------------------
686 
688  Fw::OutputLogPort m_Log_OutputPort[NUM_LOG_OUTPUT_PORTS];
689 
690 #if FW_ENABLE_TEXT_LOGGING == 1
691 
693  Fw::OutputLogTextPort m_LogText_OutputPort[NUM_LOGTEXT_OUTPUT_PORTS];
694 
695 #endif
696 
698  Fw::OutputTimePort m_Time_OutputPort[NUM_TIME_OUTPUT_PORTS];
699 
701  Fw::OutputTlmPort m_Tlm_OutputPort[NUM_TLM_OUTPUT_PORTS];
702 
703  private:
704 
705  // ----------------------------------------------------------------------
706  // Typed output ports
707  // ----------------------------------------------------------------------
708 
710  Fw::OutputBufferGetPort m_allocate_OutputPort[NUM_ALLOCATE_OUTPUT_PORTS];
711 
713  Fw::OutputBufferSendPort m_deallocate_OutputPort[NUM_DEALLOCATE_OUTPUT_PORTS];
714 
717 
720 
721  private:
722 
723  // ----------------------------------------------------------------------
724  // Counter values for event throttling
725  // ----------------------------------------------------------------------
726 
728  std::atomic<FwIndexType> m_WriteErrorThrottle;
729 
731  std::atomic<FwIndexType> m_ReadErrorThrottle;
732 
734  std::atomic<FwIndexType> m_NoBuffersThrottle;
735 
736  private:
737 
738  // ----------------------------------------------------------------------
739  // Mutexes
740  // ----------------------------------------------------------------------
741 
743  Os::Mutex m_guardedPortMutex;
744 
745  };
746 
747 }
748 
749 #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
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.
void tlmWrite_BytesRecv(FwSizeType arg, Fw::Time _tlmTime=Fw::Time()) const
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_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.
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
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.
bool isConnected_Tlm_OutputPort(FwIndexType portNum)
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