PWLib
1.10.10
|
00001 /* 00002 * serchan.h 00003 * 00004 * Asynchronous Serial I/O channel class. 00005 * 00006 * Portable Windows Library 00007 * 00008 * Copyright (c) 1993-1998 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Portable Windows Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Portions are Copyright (C) 1993 Free Software Foundation, Inc. 00025 * All Rights Reserved. 00026 * 00027 * Contributor(s): ______________________________________. 00028 * 00029 * $Log: serchan.h,v $ 00030 * Revision 1.18 2005/11/25 03:43:47 csoutheren 00031 * Fixed function argument comments to be compatible with Doxygen 00032 * 00033 * Revision 1.17 2005/02/20 21:18:30 dereksmithies 00034 * Fix documentation typos. 00035 * 00036 * Revision 1.16 2003/09/17 05:41:59 csoutheren 00037 * Removed recursive includes 00038 * 00039 * Revision 1.15 2003/09/17 01:18:02 csoutheren 00040 * Removed recursive include file system and removed all references 00041 * to deprecated coooperative threading support 00042 * 00043 * Revision 1.14 2002/09/16 01:08:59 robertj 00044 * Added #define so can select if #pragma interface/implementation is used on 00045 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00046 * 00047 * Revision 1.13 2001/05/22 12:49:32 robertj 00048 * Did some seriously wierd rewrite of platform headers to eliminate the 00049 * stupid GNU compiler warning about braces not matching. 00050 * 00051 * Revision 1.12 1999/03/09 02:59:50 robertj 00052 * Changed comments to doc++ compatible documentation. 00053 * 00054 * Revision 1.11 1999/02/16 08:11:10 robertj 00055 * MSVC 6.0 compatibility changes. 00056 * 00057 * Revision 1.10 1998/09/23 06:21:21 robertj 00058 * Added open source copyright license. 00059 * 00060 * Revision 1.9 1995/07/31 12:15:46 robertj 00061 * Removed PContainer from PChannel ancestor. 00062 * 00063 * Revision 1.8 1995/06/17 11:13:18 robertj 00064 * Documentation update. 00065 * 00066 * Revision 1.7 1995/03/14 12:42:33 robertj 00067 * Updated documentation to use HTML codes. 00068 * 00069 * Revision 1.6 1995/01/14 06:19:37 robertj 00070 * Documentation 00071 * 00072 * Revision 1.5 1994/08/23 11:32:52 robertj 00073 * Oops 00074 * 00075 * Revision 1.4 1994/08/22 00:46:48 robertj 00076 * Added pragma fro GNU C++ compiler. 00077 * 00078 * Revision 1.3 1994/07/17 10:46:06 robertj 00079 * Moved data to PChannel class. 00080 * 00081 * Revision 1.2 1994/06/25 11:55:15 robertj 00082 * Unix version synchronisation. 00083 * 00084 * Revision 1.1 1994/04/20 12:17:44 robertj 00085 * Initial revision 00086 * 00087 */ 00088 00089 #ifndef _PSERIALCHANNEL 00090 #define _PSERIALCHANNEL 00091 00092 #ifdef P_USE_PRAGMA 00093 #pragma interface 00094 #endif 00095 00096 00097 class PConfig; 00098 00099 00101 // Serial Channel 00102 00106 class PSerialChannel : public PChannel 00107 { 00108 PCLASSINFO(PSerialChannel, PChannel); 00109 00110 public: 00113 00114 PSerialChannel(); 00115 00117 enum Parity { 00119 DefaultParity, 00121 NoParity, 00123 EvenParity, 00125 OddParity, 00127 MarkParity, 00129 SpaceParity 00130 }; 00131 00133 enum FlowControl { 00135 DefaultFlowControl, 00137 NoFlowControl, 00139 XonXoff, 00141 RtsCts 00142 }; 00143 00148 PSerialChannel( 00153 const PString & port, 00158 DWORD speed = 0, 00162 BYTE data = 0, 00167 Parity parity = DefaultParity, 00171 BYTE stop = 0, 00173 FlowControl inputFlow = DefaultFlowControl, 00175 FlowControl outputFlow = DefaultFlowControl 00176 ); 00177 00183 PSerialChannel( 00184 PConfig & cfg 00185 ); 00186 00188 ~PSerialChannel(); 00190 00191 00198 virtual BOOL Open( 00203 const PString & port, 00208 DWORD speed = 0, 00212 BYTE data = 0, 00217 Parity parity = DefaultParity, 00221 BYTE stop = 0, 00223 FlowControl inputFlow = DefaultFlowControl, 00225 FlowControl outputFlow = DefaultFlowControl 00226 ); 00227 00233 virtual BOOL Open( 00234 PConfig & cfg 00235 ); 00236 00245 static PStringList GetPortNames(); 00247 00248 00256 BOOL SetSpeed( 00257 DWORD speed 00258 ); 00259 00265 DWORD GetSpeed() const; 00266 00272 BOOL SetDataBits( 00273 BYTE data 00274 ); 00275 00281 BYTE GetDataBits() const; 00282 00288 BOOL SetParity( 00289 Parity parity 00290 ); 00291 00297 Parity GetParity() const; 00298 00304 BOOL SetStopBits( 00305 BYTE stop 00306 ); 00307 00313 BYTE GetStopBits() const; 00314 00321 BOOL SetInputFlowControl( 00322 FlowControl flowControl 00323 ); 00324 00331 FlowControl GetInputFlowControl() const; 00332 00339 BOOL SetOutputFlowControl( 00340 FlowControl flowControl 00341 ); 00342 00349 FlowControl GetOutputFlowControl() const; 00350 00354 virtual void SaveSettings( 00355 PConfig & cfg 00356 ); 00358 00359 00363 void SetDTR( 00364 BOOL state = TRUE 00365 ); 00366 00370 void ClearDTR(); 00371 00373 void SetRTS( 00374 BOOL state = TRUE 00375 ); 00376 00380 void ClearRTS(); 00381 00383 void SetBreak( 00384 BOOL state = TRUE 00385 ); 00386 00390 void ClearBreak(); 00391 00397 BOOL GetCTS(); 00398 00404 BOOL GetDSR(); 00405 00411 BOOL GetDCD(); 00412 00418 BOOL GetRing(); 00420 00421 00422 private: 00423 void Construct(); 00424 // Platform dependent construct of the serial channel. 00425 00426 00427 // Include platform dependent part of class 00428 #ifdef _WIN32 00429 #include "msos/ptlib/serchan.h" 00430 #else 00431 #include "unix/ptlib/serchan.h" 00432 #endif 00433 }; 00434 00435 #endif 00436 00437 // End Of File ///////////////////////////////////////////////////////////////