DCL 3.7.4
Loading...
Searching...
No Matches
SerialPort.h
Go to the documentation of this file.
1#ifndef __DCL_SERIAL_PORT_H__
2#define __DCL_SERIAL_PORT_H__ 20110223
3
4#ifndef __DCL_CONFIG_H__
5#include <dcl/Config.h>
6#endif
7
8#ifdef __WINNT__
9 #define B1200 CBR_1200
10 #define B2400 CBR_2400
11 #define B4800 CBR_4800
12 #define B9600 CBR_9600
13 #define B19200 CBR_19200
14 #define B38400 CBR_38400
15 #define B57600 CBR_57600
16 #define B115200 CBR_115200
17#else
18 #include <termios.h>
19#endif
20
21#ifndef __DCL_POLL_ABLE_H__
22#include <dcl/PollAble.h>
23#endif
24
25__DCL_BEGIN_NAMESPACE
26
27#ifdef __WINNT__
28 class SerialPollThread;
29#endif
30
51class DCLCAPI SerialPort : public PollAble
52{
53 DECLARE_CLASSINFO(SerialPort)
54public:
55 virtual ~SerialPort();
56
61 SerialPort(
62 const String& _path, int _oflags,
63 size_t _inQueue = 4096, size_t _outQueue = 4096
65
74 void open(
75 const String& _path, int _oflags,
76 size_t _inQueue = 4096, size_t _outQueue = 4096
78
79 enum BaudRate
80 {
81 BR_1200 = B1200,
82 BR_2400 = B2400,
83 BR_4800 = B4800,
84 BR_9600 = B9600,
85 BR_19200 = B19200,
86 BR_38400 = B38400
87#if !defined(_AIX)
88 , BR_57600 = B57600,
89 BR_115200 = B115200
90#endif
91 };
92
93 enum ByteSize
94 {
95 BS_8NO, // 8Bit, No parity
96 BS_7EVEN, // 7Bit, Even parity
97 BS_7ODD // 7Bit, Odd parity
98 };
99
100 enum StopBits
101 {
102 SB_1, // 1 Stop bits
103 SB_2 // 2 Stop bits
104 };
105
106 enum FlowControl
107 {
108 FC_NONE,
109 FC_RTSCTS, // Hardware
110 FC_XONXOFF // Software
111 };
112
121 void setAttributes(
122 BaudRate _baudRate = BR_38400, ByteSize _byteSize = BS_8NO,
123 StopBits _stopBits = SB_1, FlowControl _flowControl = FC_NONE
125
126 enum PurgeFlag
127 {
128 PURGE_RX = 0x0001,
129 PURGE_TX = 0x0002
130 };
131
135 void purge(int _flags) __DCL_THROWS1(IOException*);
136
137protected:
142 virtual bool onEvent(short _revents, PollThread* _pPollThread)
144
145#ifdef __WINNT__
146private:
147 // SerialPollThread에 의해 사용된다.
148 DWORD __revents;
149 OVERLAPPED __overlapped;
150
151 bool waitCommEvent();
152
153 friend SerialPollThread;
154#endif
155
156public:
162 static bool access(const String& _path);
163};
164
165#ifdef __WINNT__
166 #undef B1200
167 #undef B2400
168 #undef B4800
169 #undef B9600
170 #undef B19200
171 #undef B38400
172 #undef B57600
173 #undef B115200
174#endif
175
176__DCL_END_NAMESPACE
177
178#endif // __DCL_SERIAL_PORT_H__
#define DCLCAPI
Definition Config.h:95
#define __DCL_THROWS1(e)
Definition Config.h:152
#define DECLARE_CLASSINFO(class_name)
Definition Object.h:227
__DCL_BEGIN_NAMESPACE typedef PollThread SerialPollThread
void open(const String &_path, int _oflags=READONLY, int _mode=0666) __DCL_THROWS1(IOException *)
Definition File.cpp:80
friend class PollThread
Definition PollAble.h:38
virtual bool onEvent(short _revents, PollThread *_pPollThread) __DCL_THROWS1(IOException *)
static bool access(const String &_path)