SerialPort.h++

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002    commonc++ - A C++ Common Class Library
00003    Copyright (C) 2005-2009  Mark A Lindner
00004 
00005    This file is part of commonc++.
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public
00018    License along with this library; if not, write to the Free
00019    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 }; // namespace ccxx
00205 
00206 #endif // __ccxx_SerialPort_hxx
00207 
00208 /* end of header file */
Generated on Fri Sep 3 23:47:34 2010 for libcommonc++ by  doxygen 1.6.3