Commit f3a75105 authored by Pavel Vainerman's avatar Pavel Vainerman

(ComPort): исправил ошибку в функции getTimeout(), а также перевёл

класс на использование msec, в соответсвии с общей "политикой" библиотеки
parent 72c4c8b9
......@@ -8,7 +8,7 @@
Name: libuniset
Version: 1.7
Release: alt7
Release: alt8
Summary: UniSet - library for building distributed industrial control systems
......@@ -335,6 +335,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Fri Mar 07 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt8
- fixed bug in ComPort class (getTimeout. eterbug #9890)
* Wed Feb 12 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt7
- revert last changes ("ModbusMaster: add thread for check connection")
......
......@@ -82,9 +82,9 @@ public:
void setCharacterSize(CharacterSize);
void setStopBits(StopBits sBit);
virtual void setTimeout(int timeout);
void setWaiting(bool waiting);
inline int getTimeout(){ return uTimeout*1000; } // msec
virtual void setTimeout( int msec );
inline int getTimeout(){ return uTimeout/1000; } // msec
void setWaiting( bool waiting );
virtual unsigned char receiveByte();
virtual void sendByte(unsigned char x);
......
......@@ -257,9 +257,9 @@ void ComPort::sendByte(unsigned char x)
}
// --------------------------------------------------------------------------------
// Lav: убрать, переделать в receiveBlock
void ComPort::setTimeout(int timeout)
void ComPort::setTimeout( int msec )
{
uTimeout=timeout;
uTimeout = msec * 1000;
}
// --------------------------------------------------------------------------------
// Lav: ситуация, когда отправлено меньше запрошенного, не типична и должна
......
......@@ -73,10 +73,10 @@ ComPort485F::ComPort485F( string dev, int gpio_num, bool tmit_ctrl ):
}
}
// --------------------------------------------------------------------------------
void ComPort485F::setTimeout(int timeout)
void ComPort485F::setTimeout( int msec )
{
tout_msec = timeout / 1000;
ComPort::setTimeout(timeout);
tout_msec = msec;
ComPort::setTimeout(msec);
}
// --------------------------------------------------------------------------------
unsigned char ComPort485F::m_receiveByte( bool wait )
......
......@@ -35,7 +35,7 @@ ModbusRTUMaster::ModbusRTUMaster( const string dev, bool use485, bool tr_ctl ):
port->setCharacterSize(ComPort::CSize8);
port->setStopBits(ComPort::OneBit);
port->setWaiting(true);
port->setTimeout(replyTimeOut_ms*1000);
port->setTimeout(replyTimeOut_ms);
// port->setBlocking(false);
}
// -------------------------------------------------------------------------
......@@ -51,7 +51,7 @@ ModbusRTUMaster::ModbusRTUMaster( ComPort* com ):
port->setCharacterSize(ComPort::CSize8);
port->setStopBits(ComPort::OneBit);
port->setWaiting(true);
port->setTimeout(replyTimeOut_ms*1000);
port->setTimeout(replyTimeOut_ms);
// port->setBlocking(false);
}
// -------------------------------------------------------------------------
......@@ -116,7 +116,7 @@ int ModbusRTUMaster::getNextData( unsigned char* buf, int len )
void ModbusRTUMaster::setChannelTimeout( timeout_t msec )
{
if( port )
port->setTimeout(msec*1000);
port->setTimeout(msec);
}
// --------------------------------------------------------------------------------
mbErrCode ModbusRTUMaster::sendData( unsigned char* buf, int len )
......
......@@ -35,7 +35,7 @@ ModbusRTUSlave::ModbusRTUSlave( const string dev, bool use485, bool tr_ctl ):
port->setCharacterSize(ComPort::CSize8);
port->setStopBits(ComPort::OneBit);
port->setWaiting(true);
port->setTimeout(recvTimeOut_ms*1000);
port->setTimeout(recvTimeOut_ms);
// port->setBlocking(false);
}
......@@ -49,7 +49,7 @@ ModbusRTUSlave::ModbusRTUSlave( ComPort* com ):
port->setCharacterSize(ComPort::CSize8);
port->setStopBits(ComPort::OneBit);
port->setWaiting(true);
port->setTimeout(recvTimeOut_ms*1000);
port->setTimeout(recvTimeOut_ms);
// port->setBlocking(false);
}
......@@ -129,9 +129,9 @@ int ModbusRTUSlave::getNextData( unsigned char* buf, int len )
void ModbusRTUSlave::setChannelTimeout( timeout_t msec )
{
if( msec == UniSetTimer::WaitUpTime )
port->setTimeout(15*60*1000*1000); // используем просто большое время (15 минут). Переведя его в наносекунды.
port->setTimeout(15*60*1000); // используем просто большое время (15 минут).
else
port->setTimeout(msec*1000);
port->setTimeout(msec);
}
// --------------------------------------------------------------------------------
mbErrCode ModbusRTUSlave::sendData( unsigned char* buf, int len )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment