tcpserial.h
Go to the documentation of this file.
00001 //======================================================================
00028 //======================================================================
00029 
00030 #ifndef TCP_SERIAL_H_
00031 #define TCP_SERIAL_H_
00032 
00033 //----------------------------------------------------------------------
00034 // System Includes - include with <>
00035 //----------------------------------------------------------------------
00036 
00037 #if SDH_USE_VCC
00038 # include <sys/timeb.h>
00039 # include <time.h>
00040 # include <winsock.h>
00041 #else
00042 # include <sys/time.h>
00043 #endif
00044 #include <string>
00045 
00046 //----------------------------------------------------------------------
00047 // Project Includes - include with ""
00048 //----------------------------------------------------------------------
00049 
00050 #include "sdhexception.h"
00051 #include "serialbase.h"
00052 #include "basisdef.h"
00053 
00054 #include "sdhlibrary_settings.h"
00055 
00056 //----------------------------------------------------------------------
00057 // Defines, enums, unions, structs,
00058 //----------------------------------------------------------------------
00059 
00060 NAMESPACE_SDH_START
00061 
00062 //----------------------------------------------------------------------
00063 // Global variables
00064 //----------------------------------------------------------------------
00065 
00066 
00067 //----------------------------------------------------------------------
00068 // Function and class member declarations
00069 //----------------------------------------------------------------------
00070 
00071 
00075 class VCC_EXPORT cTCPSerialException: public cSerialBaseException
00076 {
00077 public:
00078     cTCPSerialException( cMsg const & _msg )
00079         : cSerialBaseException( "cTCPSerialException", _msg )
00080     {}
00081 };
00082 //======================================================================
00083 
00084 
00088 class VCC_EXPORT cTCPSerial : public cSerialBase
00089 {
00090 
00091 protected:
00092 
00093     std::string tcp_adr;
00094 
00096     int tcp_port;
00097 
00099 #if SDH_USE_VCC
00100     SOCKET fd;
00101 #else
00102     int    fd;
00103     static const int INVALID_SOCKET = -1;
00104 #endif
00105 private:
00107     struct  timeval timeout_timeval;
00109     long    timeout_us;
00110 
00111 public:
00112     static double const TIMEOUT_WAIT_FOR_EVER_S;
00113     static double const TIMEOUT_RETURN_IMMEDITELY_S;
00114     static long const   TIMEOUT_WAIT_FOR_EVER_US;
00115     static long const   TIMEOUT_RETURN_IMMEDITELY_US;
00116 
00126     cTCPSerial( char const* _tcp_adr, int _tcp_port, double _timeout )
00127         throw (cTCPSerialException*);
00128 
00132     void Open( void )
00133         throw (cTCPSerialException*);
00134 
00136     bool IsOpen( void )
00137         throw();
00138 
00140     void Close( void )
00141         throw (cTCPSerialException*);
00142 
00144 
00152     int write( char const *ptr, int len=0 )
00153         throw (cTCPSerialException*);
00154 
00163     ssize_t Read( void *data, ssize_t size, long timeout_us, bool return_on_less_data )
00164         throw (cTCPSerialException*);
00165 
00167     void SetTimeout( double _timeout )
00168         throw (cSerialBaseException*);
00169 
00173     virtual tErrorCode GetErrorNumber()
00174     {
00175 #if SDH_USE_VCC
00176         return WSAGetLastError();
00177 #else
00178         return errno;
00179 #endif
00180     }
00181 };
00182 //======================================================================
00183 
00184 NAMESPACE_SDH_END
00185 
00186 #endif
00187 
00188 
00189 //======================================================================
00190 /*
00191   Here are some settings for the emacs/xemacs editor (and can be safely ignored):
00192   (e.g. to explicitely set C++ mode for *.h header files)
00193 
00194   Local Variables:
00195   mode:C++
00196   mode:ELSE
00197   End:
00198 */
00199 //======================================================================
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


schunk_sdh
Author(s): Florian Weisshardt
autogenerated on Tue Mar 5 2013 14:44:11