Commit 58c22b47 authored by Pavel Vaynerman's avatar Pavel Vaynerman

fixed minor bug in MBTCPMaster..

parent 37265acb
......@@ -191,6 +191,9 @@ int main( int argc, char **argv )
mb.setTimeout(tout);
mb.connect(ia,port);
if( verb )
cout << "connection: " << (mb.isConnection() ? "YES" : "NO") << endl;
while( 1)
{
......
......@@ -47,14 +47,13 @@ int ModbusTCPMaster::nTransaction = 0;
mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
ModbusMessage& reply, timeout_t timeout )
{
// if( !isConnection() )
if( iaddr.empty() )
{
dlog[Debug::WARN] << "(query): unknown ip address for server..." << endl;
return erHardwareError;
}
if( !isConnection() )
reconnect();
if( !isConnection() )
......@@ -185,6 +184,8 @@ void ModbusTCPMaster::reconnect()
delete tcp;
}
if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << "(ModbusTCPMaster): reconnect " << iaddr << endl;
tcp = new ost::TCPStream(iaddr.c_str());
}
// -------------------------------------------------------------------------
......
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