UniSet
1.4.0
|
00001 // ------------------------------------------------------------------------- 00002 #ifndef ModbusRTUSlave_H_ 00003 #define ModbusRTUSlave_H_ 00004 // ------------------------------------------------------------------------- 00005 #include <string> 00006 #include "Mutex.h" 00007 #include "Debug.h" 00008 #include "Configuration.h" 00009 #include "PassiveTimer.h" 00010 #include "ComPort.h" 00011 #include "ModbusTypes.h" 00012 #include "ModbusServer.h" 00013 // ------------------------------------------------------------------------- 00022 class ModbusRTUSlave: 00023 public ModbusServer 00024 { 00025 public: 00026 ModbusRTUSlave( const std::string dev, bool use485=false, bool tr_ctl=false ); 00027 ModbusRTUSlave( ComPort* com ); 00028 virtual ~ModbusRTUSlave(); 00029 00030 void setSpeed( ComPort::Speed s ); 00031 void setSpeed( const std::string s ); 00032 ComPort::Speed getSpeed(); 00033 00034 virtual ModbusRTU::mbErrCode receive( ModbusRTU::ModbusAddr addr, timeout_t msecTimeout ); 00035 00036 virtual void cleanupChannel(){ if(port) port->cleanupChannel(); } 00037 00038 virtual void terminate(); 00039 00040 protected: 00041 00042 // realisation (see ModbusServer.h) 00043 virtual int getNextData( unsigned char* buf, int len ); 00044 virtual void setChannelTimeout( timeout_t msec ); 00045 virtual ModbusRTU::mbErrCode sendData( unsigned char* buf, int len ); 00046 00047 std::string dev; 00048 ComPort* port; 00049 bool myport; 00050 00051 private: 00052 00053 }; 00054 // ------------------------------------------------------------------------- 00055 #endif // ModbusRTUSlave_H_ 00056 // -------------------------------------------------------------------------