You need to sign in or sign up before continuing.
Commit a4db3837 authored by Pavel Vainerman's avatar Pavel Vainerman

ModbusTCP: Исправил ошибку предыдущего коммита

parent 5dbcb71b
...@@ -69,20 +69,26 @@ mbErrCode ModbusTCPServer::receive( ModbusRTU::ModbusAddr addr, timeout_t timeou ...@@ -69,20 +69,26 @@ mbErrCode ModbusTCPServer::receive( ModbusRTU::ModbusAddr addr, timeout_t timeou
} }
} }
// Если получили пакет по TCP if( !qrecv.empty() )
// то вроде задержек с остальной частью быть не должно {
// а если пакет, не нам, то обработка пройдёт быстро.. // check addr
// (поэтому ставим условный timeout) unsigned char _addr = qrecv.front();
// не != 0, т.к. в recv стоит assert(timeout) if( _addr != addr )
timeout = 1;
do
{ {
// buf.addr = curQueryHeader.uID; tmProcessing.setTiming(replyTimeout_ms);
// res = recv_pdu(buf,mec); ErrorRetMessage em( buf.addr, buf.func, erBadReplyNodeAddress );
buf = em.transport_msg();
send(buf);
printProcessingTime();
usleep(1000);
tcp.disconnect();
return res;
}
}
res = recv( addr, buf, timeout ); res = recv( addr, buf, timeout );
if( res!=erNoError && res!=erBadReplyNodeAddress ) if( res!=erNoError ) // && res!=erBadReplyNodeAddress )
{ {
if( res < erInternalErrorCode ) if( res < erInternalErrorCode )
{ {
...@@ -92,7 +98,7 @@ mbErrCode ModbusTCPServer::receive( ModbusRTU::ModbusAddr addr, timeout_t timeou ...@@ -92,7 +98,7 @@ mbErrCode ModbusTCPServer::receive( ModbusRTU::ModbusAddr addr, timeout_t timeou
printProcessingTime(); printProcessingTime();
} }
usleep(10000); usleep(1000);
tcp.disconnect(); tcp.disconnect();
return res; return res;
} }
...@@ -106,8 +112,6 @@ mbErrCode ModbusTCPServer::receive( ModbusRTU::ModbusAddr addr, timeout_t timeou ...@@ -106,8 +112,6 @@ mbErrCode ModbusTCPServer::receive( ModbusRTU::ModbusAddr addr, timeout_t timeou
return erTimeOut; return erTimeOut;
} }
} }
}
while( res == erBadReplyNodeAddress );
if( res!=erNoError ) if( res!=erNoError )
{ {
......
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