00001 //====================================================================== 00028 //====================================================================== 00029 00030 #ifndef RS232_CYGWIN_H_ 00031 #define RS232_CYGWIN_H_ 00032 00033 //---------------------------------------------------------------------- 00034 // System Includes - include with <> 00035 //---------------------------------------------------------------------- 00036 00037 #include <string> 00038 #include <termios.h> 00039 00040 //---------------------------------------------------------------------- 00041 // Project Includes - include with "" 00042 //---------------------------------------------------------------------- 00043 00044 #include "sdhexception.h" 00045 #include "serialbase.h" 00046 #include "sdhlibrary_settings.h" 00047 00048 //---------------------------------------------------------------------- 00049 // Defines, enums, unions, structs, 00050 //---------------------------------------------------------------------- 00051 00052 NAMESPACE_SDH_START 00053 00054 00055 //---------------------------------------------------------------------- 00056 // Global variables 00057 //---------------------------------------------------------------------- 00058 00059 00060 //---------------------------------------------------------------------- 00061 // Function and class member declarations 00062 //---------------------------------------------------------------------- 00063 00064 00065 00066 00067 00071 class cRS232Exception: public cSerialBaseException 00072 { 00073 public: 00074 cRS232Exception( cMsg const & _msg ) 00075 : cSerialBaseException( "cRS232Exception", _msg ) 00076 {} 00077 }; 00078 //====================================================================== 00079 00080 00084 class cRS232 : public cSerialBase 00085 { 00086 00087 protected: 00089 int port; 00090 00092 std::string device_format_string; 00093 00095 unsigned long baudrate; 00096 00098 int fd; 00099 00101 tcflag_t BaudrateToBaudrateCode( unsigned long baudrate ) 00102 throw (cRS232Exception*); 00103 00104 int status; 00105 00106 termios io_set_old; 00107 00108 public: 00119 cRS232( int _port, unsigned long _baudrate, double _timeout, char const* _device_format_string = "/dev/ttyS%d" ); 00120 00124 void Open( void ) 00125 throw (cRS232Exception*); 00126 00128 bool IsOpen( void ) 00129 throw(); 00130 00132 void Close( void ) 00133 throw (cRS232Exception*); 00134 00136 00144 int write( char const *ptr, int len=0 ) 00145 throw (cRS232Exception*); 00146 00155 ssize_t Read( void *data, ssize_t size, long timeout_us, bool return_on_less_data ) 00156 throw (cRS232Exception*); 00157 }; 00158 //====================================================================== 00159 00160 NAMESPACE_SDH_END 00161 00162 #endif 00163 00164 00165 //====================================================================== 00166 /* 00167 Here are some settings for the emacs/xemacs editor (and can be safely ignored): 00168 (e.g. to explicitely set C++ mode for *.h header files) 00169 00170 Local Variables: 00171 mode:C++ 00172 mode:ELSE 00173 End: 00174 */ 00175 //======================================================================