F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
LinuxUartDriver.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title LinuxUartDriverImpl.hpp
3 // \author tcanham
4 // \brief hpp file for LinuxUartDriver component implementation class
5 //
6 // \copyright
7 // Copyright 2009-2015, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
13 #ifndef LinuxUartDriver_HPP
14 #define LinuxUartDriver_HPP
15 
17 #include <Os/Mutex.hpp>
18 #include <Os/Task.hpp>
19 
20 #include <termios.h>
21 
22 namespace Drv {
23 
25  public:
26  // ----------------------------------------------------------------------
27  // Construction, initialization, and destruction
28  // ----------------------------------------------------------------------
29 
32  LinuxUartDriver(const char* const compName
33  );
34 
37  void init(const NATIVE_INT_TYPE instance = 0
38  );
39 
41  enum UartBaudRate {
42  BAUD_9600=9600,
43  BAUD_19200=19200,
44  BAUD_38400=38400,
45  BAUD_57600=57600,
46  BAUD_115K=115200,
47  BAUD_230K=230400,
48 #ifdef TGT_OS_TYPE_LINUX
49  BAUD_460K=460800,
50  BAUD_921K=921600,
51  BAUD_1000K=1000000000,
52  BAUD_1152K=1152000000,
53  BAUD_1500K=1500000000,
54  BAUD_2000K=2000000000,
55 #ifdef B2500000
56  BAUD_2500K=2500000000,
57 #endif
58 #ifdef B3000000
59  BAUD_3000K=3000000000,
60 #endif
61 #ifdef B3500000
62  BAUD_3500K=3500000000,
63 #endif
64 #ifdef B4000000
65  BAUD_4000K=4000000000
66 #endif
67 #endif
68  };
69 
71 
73 
74  // Open device with specified baud and flow control.
75  bool open(const char* const device, UartBaudRate baud, UartFlowControl fc, UartParity parity, U32 allocationSize);
76 
83 
85  void quitReadThread();
86 
89 
93 
94  PRIVATE:
95  // ----------------------------------------------------------------------
96  // Handler implementations for user-defined typed input ports
97  // ----------------------------------------------------------------------
98 
101  Drv::SendStatus send_handler(NATIVE_INT_TYPE portNum,
102  Fw::Buffer& serBuffer);
103 
104 
105  NATIVE_INT_TYPE m_fd;
106  U32 m_allocationSize;
107  const char* m_device;
108 
110  static void serialReadTaskEntry(void* ptr);
111 
112  Os::Task m_readTask;
113 
114 
115  bool m_quitReadThread;
116 };
117 
118 } // end namespace Drv
119 
120 #endif
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
Auto-generated base for LinuxUartDriver component.
void quitReadThread()
Quit thread.
Os::Task::Status join()
Join thread.
LinuxUartDriver(const char *const compName)
UartBaudRate
Configure UART parameters.
void start(Os::Task::ParamType priority=Os::Task::TASK_DEFAULT, Os::Task::ParamType stackSize=Os::Task::TASK_DEFAULT, Os::Task::ParamType cpuAffinity=Os::Task::TASK_DEFAULT)
bool open(const char *const device, UartBaudRate baud, UartFlowControl fc, UartParity parity, U32 allocationSize)
Status returned by the send call.
void init()
Object initializer.
Definition: ObjBase.cpp:27
FwSizeType ParamType
backwards-compatible parameter type
Definition: Task.hpp:218
static constexpr FwSizeType TASK_DEFAULT
Definition: Task.hpp:28