port.h

Go to the documentation of this file.
00001 //======================================================================
00002 // File:        port.h
00003 // Author:      Matthias Toussaint
00004 // Created:     Sat Nov 25 13:49:23 CET 2006
00005 // Project:     QtDMM
00006 // Description: Base class for multimter port
00007 //----------------------------------------------------------------------
00008 // This file  may  be used under  the terms of  the GNU  General Public
00009 // License  version 2.0 as published   by the Free Software  Foundation
00010 // and appearing  in the file LICENSE.GPL included  in the packaging of
00011 // this file.
00012 // 
00013 // This file is provided AS IS with  NO WARRANTY OF ANY KIND, INCLUDING 
00014 // THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
00015 // PURPOSE.
00016 //----------------------------------------------------------------------
00017 // Copyright 2006 Matthias Toussaint
00018 //======================================================================
00019 
00020 #ifndef PORT_HH
00021 #define PORT_HH
00022 
00023 #include <string>
00024 #include <sstream>
00025 
00034 class Port
00035 {
00036 public:
00037   enum Error
00038   {
00039     Ok = 0,
00040     SyntaxError,
00041     PermissionDenied,
00042     NoSuchPort,
00043     ConfigError,
00044     OpenError,
00045     WriteError,
00046     ReadError,
00047     UnknownBaudRate,
00048     UnknownNumberOfBits,
00049     UnknownParity,
00050     UnknownStopBits,
00051     NoData,
00052     BadFileDescriptor,
00053     BadAddress,
00054     Interrupted,
00055     Invalid,
00056     IOError,
00057     IsDirectory,
00058     UnknownError
00059   };
00060   
00062   Port();
00064   virtual ~Port();
00065   
00074   virtual Error open( const std::string & config )=0;
00077   virtual Error close()=0;
00082   virtual Error writeByte( int byte ) const;
00087   virtual Error readByte( int *byte ) const;
00093   virtual Error writeString( const char *string, ssize_t len ) const;
00099   virtual Error readString( char *string, ssize_t len ) const;
00105   static const char *errorString( Error err );
00106    
00107 protected:
00108   int m_handle;
00109   
00113   Error errnoValue() const;
00114   
00115 };
00116 
00117 #endif // PORT_HH

Generated on Mon Jan 22 23:24:18 2007 for cdmm by  doxygen 1.4.6