N3Roaster / typica

Free software for coffee roasting operations.
https://typica.us
MIT License
26 stars 8 forks source link

Modbus RTU Devices Not Robust to Failure #126

Closed N3Roaster closed 9 years ago

N3Roaster commented 9 years ago

I was recently contacted with an issue in which a Modbus RTU device would stop receiving measurements randomly. Examining the code, there seemed to be two possibilities:

1) A CRC failure would result in Typica no longer sending commands, but it would be possible to re-start communications by sending a new SV if the device was configured to allow that. 2) If the response is for any reason not receieved in full, it would wait for that response forever with no hope of recovery.

I was able to replicate the described issue by introducing a temporary short on the RS-485 connection. The solution is to change the behavior in both of the above scenarios.

In the event of a CRC failure, Typica should re-send the previous command. There should also be a timer that is set whenever a command is sent and stopped only when a complete response has been received. If this timer times out, the response buffer should be cleared and Typica should re-send the previous command.

N3Roaster commented 9 years ago

If anybody running Windows is experiencing this issue and would like to test this solution, a build is available at http://www.randomfield.com/programs/typica/Typica-modbus-fix.zip