libmodbus icon indicating copy to clipboard operation
libmodbus copied to clipboard

Flush buffer before send

Open swordfish6975 opened this issue 7 years ago • 1 comments

This is to help avoid transaction IDs getting out of wack and failing every time on that check after a connection error.

We are testing to a socomec device on a 3g modem, using these https://hub.docker.com/u/edgepro/ docker containers (everything but mb-mqtt).

The same test can be completed by ifdown the ubuntu running docker with the emulated slave container and trying to make a request then running ifup after that you will always get a invalid data error back. The flush before send fixes the issue, if their is a better way to fix this problem with transaction IDs getting confused after error possibly due to flaky comms please advise. I am usualy a C# developer so this is quite new to me. Thanks

swordfish6975 avatar May 11 '18 06:05 swordfish6975

if this flush can be done in userland code , by calling modbus_flush() , then i vote against the merging of this commit into the library , because a library like libmodbus is easier maintainable in the long run , if it provides modular building-blocks in form of its functions , than to try to address endless hardware-specific corner cases , that can be solved in userland code .

for example i call modbus_flush() before modbus_close() to omit connection-problems on reconnection-attempts in error-situations . i've implemented it outside the libmodbus libray in my userland code , simply by calling the above mentioned libmodbus functions . it works perfectly fine and changes in the libmodbus libray are not necessary .

dreamflow avatar Apr 08 '20 08:04 dreamflow