serchan.h

Go to the documentation of this file.
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  * $Revision: 20385 $
00030  * $Author: rjongbloed $
00031  * $Date: 2008-06-04 10:40:38 +0000 (Wed, 04 Jun 2008) $
00032  */
00033 
00034 #ifndef _PSERIALCHANNEL
00035 #define _PSERIALCHANNEL
00036 
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040 
00041 
00042 class PConfig;
00043 
00044 
00046 // Serial Channel
00047 
00051 class PSerialChannel : public PChannel
00052 {
00053   PCLASSINFO(PSerialChannel, PChannel);
00054 
00055   public:
00058 
00059     PSerialChannel();
00060 
00062     enum Parity {
00064       DefaultParity,    
00066       NoParity,         
00068       EvenParity,       
00070       OddParity,        
00072       MarkParity,       
00074       SpaceParity       
00075     };
00076 
00078     enum FlowControl {
00080       DefaultFlowControl,
00082       NoFlowControl,    
00084       XonXoff,         
00086       RtsCts           
00087     };
00088 
00093     PSerialChannel(
00098       const PString & port,
00103       DWORD speed = 0,
00107       BYTE data = 0,
00112       Parity parity = DefaultParity,
00116       BYTE stop = 0,
00118       FlowControl inputFlow = DefaultFlowControl,
00120       FlowControl outputFlow = DefaultFlowControl      
00121     );
00122 
00123 #if P_CONFIG_FILE
00124 
00129     PSerialChannel(
00130       PConfig & cfg  
00131     );
00132 #endif // P_CONFIG_FILE
00133 
00135     ~PSerialChannel();
00137 
00138 
00145     virtual PBoolean Open(
00150       const PString & port,
00155       DWORD speed = 0,
00159       BYTE data = 0,
00164       Parity parity = DefaultParity,
00168       BYTE stop = 0,
00170       FlowControl inputFlow = DefaultFlowControl,
00172       FlowControl outputFlow = DefaultFlowControl      
00173     );
00174 
00175 #if P_CONFIG_FILE
00176 
00181     virtual PBoolean Open(
00182       PConfig & cfg  
00183     );
00184 #endif // P_CONFIG_FILE
00185 
00194     static PStringList GetPortNames();
00196 
00197 
00205     PBoolean SetSpeed(
00206       DWORD speed   
00207     );
00208 
00214     DWORD GetSpeed() const;
00215 
00221     PBoolean SetDataBits(
00222       BYTE data   
00223     );
00224 
00230     BYTE GetDataBits() const;
00231 
00237     PBoolean SetParity(
00238       Parity parity   
00239     );
00240 
00246     Parity GetParity() const;
00247 
00253     PBoolean SetStopBits(
00254       BYTE stop   
00255     );
00256 
00262     BYTE GetStopBits() const;
00263 
00270     PBoolean SetInputFlowControl(
00271       FlowControl flowControl   
00272     );
00273 
00280     FlowControl GetInputFlowControl() const;
00281 
00288     PBoolean SetOutputFlowControl(
00289       FlowControl flowControl   
00290     );
00291 
00298     FlowControl GetOutputFlowControl() const;
00299 
00300 #if P_CONFIG_FILE
00301 
00304     virtual void SaveSettings(
00305       PConfig & cfg   
00306     );
00307 #endif // P_CONFIG_FILE
00308 
00309 
00310 
00314     void SetDTR(
00315       PBoolean state = PTrue   
00316     );
00317 
00321     void ClearDTR();
00322 
00324     void SetRTS(
00325       PBoolean state = PTrue   
00326     );
00327 
00331     void ClearRTS();
00332 
00334     void SetBreak(
00335       PBoolean state = PTrue   
00336     );
00337 
00341     void ClearBreak();
00342 
00348     PBoolean GetCTS();
00349 
00355     PBoolean GetDSR();
00356 
00362     PBoolean GetDCD();
00363 
00369     PBoolean GetRing();
00371 
00372 
00373   private:
00374     void Construct();
00375     // Platform dependent construct of the serial channel.
00376 
00377 
00378 // Include platform dependent part of class
00379 #ifdef _WIN32
00380 #include "msos/ptlib/serchan.h"
00381 #else
00382 #include "unix/ptlib/serchan.h"
00383 #endif
00384 };
00385 
00386 #endif
00387 
00388 // End Of File ///////////////////////////////////////////////////////////////

Generated on Mon Feb 23 01:57:54 2009 for PTLib by  doxygen 1.5.1