SerialPort.h++
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __ccxx_SerialPort_hxx
00024 #define __ccxx_SerialPort_hxx
00025
00026 #include <commonc++/Common.h++>
00027 #include <commonc++/Stream.h++>
00028
00029 namespace ccxx {
00030
00036 class COMMONCPP_API SerialPort : public Stream
00037 {
00038 public:
00039
00041 enum BaudRate { BaudOther = -1, Baud300 = 300, Baud600 = 600,
00042 Baud1200 = 1200, Baud1800 = 1800, Baud2400 = 2400,
00043 Baud4800 = 4800, Baud9600 = 9600, Baud19200 = 19200,
00044 Baud38400 = 38400, Baud57600 = 57600,
00045 Baud115200 = 115200, Baud230400 = 230400 };
00046
00048 enum Parity { ParityOther = -1, ParityNone, ParityOdd, ParityEven,
00049 ParityMark, ParitySpace };
00050
00052 enum DataBits { DataBitsOther = -1, DataBits5 = 5, DataBits6 = 6,
00053 DataBits7 = 7, DataBits8 = 8 };
00054
00056 enum StopBits { StopBitsOther = -1, StopBits1 = 1, StopBits2 = 2,
00057 StopBits15 = 3 };
00058
00060 enum FlowControl { FlowOther = -1, FlowOff, FlowHardware, FlowXOnXOff };
00061
00068 SerialPort(const String &device);
00069
00071 virtual ~SerialPort() throw();
00072
00078 virtual void open() throw(IOException);
00079
00085 void flush() throw(IOException);
00086
00091 void setTimeout(int msec) throw(IOException);
00092
00099 void setBaudRate(BaudRate baud) throw(IOException);
00100
00108 BaudRate getBaudRate() throw(IOException);
00109
00116 void setParity(Parity parity) throw(IOException);
00117
00125 Parity getParity() throw(IOException);
00126
00133 void setDataBits(DataBits bits) throw(IOException);
00134
00142 DataBits getDataBits() throw(IOException);
00143
00150 void setStopBits(StopBits bits) throw(IOException);
00151
00159 StopBits getStopBits() throw(IOException);
00160
00168 void setFlowControl(FlowControl flow) throw(IOException);
00169
00177 FlowControl getFlowControl() throw(IOException);
00178
00185 void sendBreak(uint_t duration);
00186
00193 static BaudRate lookupBaudRate(uint_t baudRate) throw();
00194
00195 protected:
00196
00197 String _device;
00198
00199 private:
00200
00201 CCXX_COPY_DECLS(SerialPort);
00202 };
00203
00204 };
00205
00206 #endif // __ccxx_SerialPort_hxx
00207
00208