PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
serchan.h
Go to the documentation of this file.
1 /*
2 * serchan.h
3 *
4 * Asynchronous Serial I/O channel class.
5 *
6 * Portable Windows Library
7 *
8 * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9 *
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
14 *
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * The Original Code is Portable Windows Library.
21 *
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23 *
24 * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25 * All Rights Reserved.
26 *
27 * Contributor(s): ______________________________________.
28 *
29 * $Revision: 24177 $
30 * $Author: rjongbloed $
31 * $Date: 2010-04-05 21:52:04 +1000 (Mon, 05 Apr 2010) $
32 */
33
34 #ifndef PTLIB_SERIALCHANNEL_H
35 #define PTLIB_SERIALCHANNEL_H
36
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40
41
42 class PConfig;
43
44
46 // Serial Channel
47
51 class PSerialChannel : public PChannel
52 {
53 PCLASSINFO(PSerialChannel, PChannel);
54
55 public:
58
59 PSerialChannel();
60
62 enum Parity {
64 DefaultParity,
66 NoParity,
68 EvenParity,
70 OddParity,
72 MarkParity,
74 SpaceParity
75 };
76
78 enum FlowControl {
80 DefaultFlowControl,
82 NoFlowControl,
84 XonXoff,
86 RtsCts
87 };
88
93 PSerialChannel(
98 const PString & port,
103 DWORD speed = 0,
107 BYTE data = 0,
112 Parity parity = DefaultParity,
116 BYTE stop = 0,
118 FlowControl inputFlow = DefaultFlowControl,
120 FlowControl outputFlow = DefaultFlowControl
121 );
122
123 #if P_CONFIG_FILE
124
129 PSerialChannel(
130 PConfig & cfg
131 );
132 #endif // P_CONFIG_FILE
133
135 ~PSerialChannel();
137
138
145 virtual PBoolean Open(
150 const PString & port,
155 DWORD speed = 0,
159 BYTE data = 0,
164 Parity parity = DefaultParity,
168 BYTE stop = 0,
170 FlowControl inputFlow = DefaultFlowControl,
172 FlowControl outputFlow = DefaultFlowControl
173 );
174
175 #if P_CONFIG_FILE
176
181 virtual PBoolean Open(
182 PConfig & cfg
183 );
184 #endif // P_CONFIG_FILE
185
194 static PStringList GetPortNames();
196
197
205 PBoolean SetSpeed(
206 DWORD speed
207 );
208
214 DWORD GetSpeed() const;
215
221 PBoolean SetDataBits(
222 BYTE data
223 );
224
230 BYTE GetDataBits() const;
231
237 PBoolean SetParity(
238 Parity parity
239 );
240
246 Parity GetParity() const;
247
253 PBoolean SetStopBits(
254 BYTE stop
255 );
256
262 BYTE GetStopBits() const;
263
270 PBoolean SetInputFlowControl(
271 FlowControl flowControl
272 );
273
280 FlowControl GetInputFlowControl() const;
281
288 PBoolean SetOutputFlowControl(
289 FlowControl flowControl
290 );
291
298 FlowControl GetOutputFlowControl() const;
299
300 #if P_CONFIG_FILE
301
304 virtual void SaveSettings(
305 PConfig & cfg
306 );
307 #endif // P_CONFIG_FILE
308
309
310
314 void SetDTR(
315 PBoolean state = true
316 );
317
321 void ClearDTR();
322
324 void SetRTS(
325 PBoolean state = true
326 );
327
331 void ClearRTS();
332
334 void SetBreak(
335 PBoolean state = true
336 );
337
341 void ClearBreak();
342
348 PBoolean GetCTS();
349
355 PBoolean GetDSR();
356
362 PBoolean GetDCD();
363
369 PBoolean GetRing();
371
372
373 private:
374 void Construct();
375 // Platform dependent construct of the serial channel.
376
377
378 // Include platform dependent part of class
379 #ifdef _WIN32
380 #include "msos/ptlib/serchan.h"
381 #else
382 #include "unix/ptlib/serchan.h"
383 #endif
384 };
385
386
387 #endif // PTLIB_SERIALCHANNEL_H
388
389
390 // End Of File ///////////////////////////////////////////////////////////////