00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef PTLIB_SERIALCHANNEL_H
00035 #define PTLIB_SERIALCHANNEL_H
00036
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040
00041
00042 class PConfig;
00043
00044
00046
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
00376
00377
00378
00379 #ifdef _WIN32
00380 #include "msos/ptlib/serchan.h"
00381 #else
00382 #include "unix/ptlib/serchan.h"
00383 #endif
00384 };
00385
00386
00387 #endif // PTLIB_SERIALCHANNEL_H
00388
00389
00390