Menu

#1082 Modbus with no polling: client FB keeps on opening TCP connection

1.8.x
closed-fixed
nobody
None
FORTE
Bug
Normal
2016-08-27
2016-08-25
No

When using Modbus, if no read polling is provided (client FB use only to perform Modbus write), client FB keeps on opening TCP connection to the Modbus TCP server.
Root cause in the code: in modbusclientconnection.cpp, in CModbusClientConnection::tryPolling method, there is a check at the end :
if((nrErrors == m_nNrOfPolls)
in case m_nNrOfPolls and nrErrors are both equal to 0, the flag m_bConnected is set to false...
My suggestion would be the following:
if((nrErrors == m_nNrOfPolls) && (m_nNrOfPolls != 0)) {
modbus_close(m_pModbusConn); // in any case it is worth trying to close the socket
m_bConnected = false;
m_pModbusConnEvent = new CModbusConnectionEvent(1000); // changed to 1000 as set at startup
m_pModbusConnEvent->activate();
}

Discussion

  • Zoitl Alois

    Zoitl Alois - 2016-08-27
    • status: open --> closed-fixed
    • Milestone: Backlog --> 1.8.x
     

Log in to post a comment.

MongoDB Logo MongoDB