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: 19008 $
00030  * $Author: rjongbloed $
00031  * $Date: 2007-11-29 09:17:41 +0000 (Thu, 29 Nov 2007) $
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 
00128     PSerialChannel(
00129       PConfig & cfg  
00130     );
00131 
00133     ~PSerialChannel();
00135 
00136 
00143     virtual PBoolean Open(
00148       const PString & port,
00153       DWORD speed = 0,
00157       BYTE data = 0,
00162       Parity parity = DefaultParity,
00166       BYTE stop = 0,
00168       FlowControl inputFlow = DefaultFlowControl,
00170       FlowControl outputFlow = DefaultFlowControl      
00171     );
00172 
00178     virtual PBoolean Open(
00179       PConfig & cfg  
00180     );
00181 
00190     static PStringList GetPortNames();
00192 
00193 
00201     PBoolean SetSpeed(
00202       DWORD speed   
00203     );
00204 
00210     DWORD GetSpeed() const;
00211 
00217     PBoolean SetDataBits(
00218       BYTE data   
00219     );
00220 
00226     BYTE GetDataBits() const;
00227 
00233     PBoolean SetParity(
00234       Parity parity   
00235     );
00236 
00242     Parity GetParity() const;
00243 
00249     PBoolean SetStopBits(
00250       BYTE stop   
00251     );
00252 
00258     BYTE GetStopBits() const;
00259 
00266     PBoolean SetInputFlowControl(
00267       FlowControl flowControl   
00268     );
00269 
00276     FlowControl GetInputFlowControl() const;
00277 
00284     PBoolean SetOutputFlowControl(
00285       FlowControl flowControl   
00286     );
00287 
00294     FlowControl GetOutputFlowControl() const;
00295 
00299     virtual void SaveSettings(
00300       PConfig & cfg   
00301     );
00303 
00304 
00308     void SetDTR(
00309       PBoolean state = PTrue   
00310     );
00311 
00315     void ClearDTR();
00316 
00318     void SetRTS(
00319       PBoolean state = PTrue   
00320     );
00321 
00325     void ClearRTS();
00326 
00328     void SetBreak(
00329       PBoolean state = PTrue   
00330     );
00331 
00335     void ClearBreak();
00336 
00342     PBoolean GetCTS();
00343 
00349     PBoolean GetDSR();
00350 
00356     PBoolean GetDCD();
00357 
00363     PBoolean GetRing();
00365 
00366 
00367   private:
00368     void Construct();
00369     // Platform dependent construct of the serial channel.
00370 
00371 
00372 // Include platform dependent part of class
00373 #ifdef _WIN32
00374 #include "msos/ptlib/serchan.h"
00375 #else
00376 #include "unix/ptlib/serchan.h"
00377 #endif
00378 };
00379 
00380 #endif
00381 
00382 // End Of File ///////////////////////////////////////////////////////////////

Generated on Mon Dec 10 11:18:57 2007 for PTLib by  doxygen 1.5.1