PTLib  Version 2.14.3
 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: 29669 $
30  * $Author: rjongbloed $
31  * $Date: 2013-05-09 12:03:44 +1000 (Thu, 09 May 2013) $
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 #if HAVE_TERMIOS_H
45  #include <termios.h>
46 #elif HAVE_SYS_TERMIOS_H
47  #include <sys/termios.h>
48 #endif
49 
50 
52 // Serial Channel
53 
57 class PSerialChannel : public PChannel
58 {
59  PCLASSINFO(PSerialChannel, PChannel);
60 
61  public:
64 
66 
68  enum Parity {
81  };
82 
84  enum FlowControl {
93  };
94 
104  const PString & port,
109  DWORD speed = 0,
113  BYTE data = 0,
118  Parity parity = DefaultParity,
122  BYTE stop = 0,
124  FlowControl inputFlow = DefaultFlowControl,
126  FlowControl outputFlow = DefaultFlowControl
127  );
128 
129 #if P_CONFIG_FILE
130 
136  PConfig & cfg
137  );
138 #endif // P_CONFIG_FILE
139 
141  ~PSerialChannel();
143 
144 
151  virtual PBoolean Open(
156  const PString & port,
161  DWORD speed = 0,
165  BYTE data = 0,
170  Parity parity = DefaultParity,
174  BYTE stop = 0,
176  FlowControl inputFlow = DefaultFlowControl,
178  FlowControl outputFlow = DefaultFlowControl
179  );
180 
181 #if P_CONFIG_FILE
182 
187  virtual PBoolean Open(
188  PConfig & cfg
189  );
190 #endif // P_CONFIG_FILE
191 
200  static PStringList GetPortNames();
202 
203 
212  DWORD speed
213  );
214 
220  DWORD GetSpeed() const;
221 
228  BYTE data
229  );
230 
236  BYTE GetDataBits() const;
237 
244  Parity parity
245  );
246 
252  Parity GetParity() const;
253 
260  BYTE stop
261  );
262 
268  BYTE GetStopBits() const;
269 
277  FlowControl flowControl
278  );
279 
287 
295  FlowControl flowControl
296  );
297 
305 
306 #if P_CONFIG_FILE
307 
310  virtual void SaveSettings(
311  PConfig & cfg
312  );
313 #endif // P_CONFIG_FILE
314 
315 
316 
320  void SetDTR(
321  PBoolean state = true
322  );
323 
327  void ClearDTR();
328 
330  void SetRTS(
331  PBoolean state = true
332  );
333 
337  void ClearRTS();
338 
340  void SetBreak(
341  PBoolean state = true
342  );
343 
347  void ClearBreak();
348 
354  PBoolean GetCTS();
355 
361  PBoolean GetDSR();
362 
368  PBoolean GetDCD();
369 
375  PBoolean GetRing();
377 
378 
379  private:
380  void Construct();
381  // Platform dependent construct of the serial channel.
382 
383 
384 // Include platform dependent part of class
385 #ifdef _WIN32
386 #include "msos/ptlib/serchan.h"
387 #else
388 #include "unix/ptlib/serchan.h"
389 #endif
390 };
391 
392 
393 #endif // PTLIB_SERIALCHANNEL_H
394 
395 
396 // End Of File ///////////////////////////////////////////////////////////////