rs232-vcc.h
Go to the documentation of this file.
00001 //======================================================================
00027 //======================================================================
00028 
00029 #ifndef RS232_VCC_h
00030 #define RS232_VCC_h
00031 
00032 #include "sdhlibrary_settings.h"
00033 
00034 #if SDH_USE_VCC
00035 # pragma warning(disable : 4996)
00036 # pragma warning(disable : 4290)
00037 # pragma once
00038 #endif
00039 
00040 //----------------------------------------------------------------------
00041 // System Includes - include with <>
00042 //----------------------------------------------------------------------
00043 
00044 #include <windows.h>
00045 
00046 //----------------------------------------------------------------------
00047 // Project Includes - include with ""
00048 //----------------------------------------------------------------------
00049 
00050 #include "sdhexception.h"
00051 #include "serialbase.h"
00052 #include "sdhlibrary_settings.h"
00053 
00054 
00055 //#define RS_232_TEST
00056 #define SDH_RS232_VCC_ASYNC 0
00057 
00058 NAMESPACE_SDH_START
00059 
00060 class VCC_EXPORT cRS232Exception: public cSerialBaseException
00061 {
00062 public:
00063     cRS232Exception( cMsg const & _msg )
00064     : cSerialBaseException( "cRS232Exception", _msg )
00065     {}
00066 };
00067 
00071 class VCC_EXPORT cRS232 : public cSerialBase
00072 {
00073 private:
00074 #ifndef RS_232_TEST
00075     HANDLE       _hCOM;
00076 #endif
00077 #if SDH_RS232_VCC_ASYNC
00078     OVERLAPPED   o;
00079 #endif
00080     COMMTIMEOUTS comm_timeouts;
00081     long         read_timeout_us; // for caching the read timeout in ms
00082 
00083 protected:
00085     int port;
00086 
00088     unsigned long baudrate;
00089 
00090 
00091 public:
00100     cRS232( int _port, unsigned long _baudrate, double _timeout, char const* _device_format_string = "" );
00101     ~cRS232(void);
00102 
00103     void Open( void )
00104     throw (cRS232Exception*);
00105     void Close( void )
00106     throw (cRS232Exception*);
00107 
00108     virtual void SetTimeout( double _timeout )
00109         throw (cSerialBaseException*);
00110 
00111 #ifndef RS_232_TEST
00112     bool IsOpen()
00113     throw()
00114     { return _hCOM != NULL; }
00115 #else
00116     bool IsOpen() { return true; }
00117 #endif
00118     int write( char const *ptr, int len=0 )
00119     throw (cRS232Exception*);
00120 
00129     ssize_t Read( void *data, ssize_t size, long timeout_us, bool return_on_less_data )
00130     throw (cRS232Exception*);
00131 
00132     char* readline(char* line, int size, char* eol, bool return_on_less_data)
00133     throw (cRS232Exception*);
00134 
00136     virtual bool UseCRC16()
00137     {
00138         return true;
00139     }
00140 };
00141 
00142 NAMESPACE_SDH_END
00143 
00144 #endif


schunk_sdh
Author(s): Florian Weisshardt
autogenerated on Mon Oct 6 2014 07:29:15