stephane / modbusino

Small Modbus slave, RTU (serial) for Arduino

Home Page:http://libmodbus.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modbusino with more than one slave error

csardopt opened this issue · comments

If you have a network with more than one slave there will be wrong responses (exception responses that shouldn't be done).
Supose that master makes a query to slave 1, then slave 2 sees the answer and sends "something", that I suppose is "response_exception".
The same applies to other slaves... more slaves more mess...

Basic solution: eliminate or comment the answer "response_exception" in Modbusino.cpp, line 191 and line 214.
Better solution: Make a better analyse of the frame to see it's not a answer from other slave...
Hope this will be corrected because it's an nice modbus library for Arduino.

commented

Thank csardopt for posting this error and thank karlp for fixing it. At first, I tried karlp's code but somehow the problem was still there. With karlp's definition of this new error, I found another cause. Since arduino 1.0, Serial.flush() is repurposed to waiting for ongoing data sent complete rather than dropping received data. I changed Serial.flush() to Serial.read() and slightly modify the loop in flush() function and get arduino work. However, my arduino still has a small chance to respond this error while my other non-arduino modbus devices don't, but the chance now is acceptable.