-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modbus is retrying the shit out of the RD #19
Comments
Your bug description is correct, and your retry method sounds good to me. |
Even after the change proposed by @stei-f, I'm still getting high latency times to read a single register. Is this normal? |
OK, had a different text here, but decided to measure it again. What you can do is request a range of registers, and it will take the same time as requesting one register. |
@stei-f I did measure using time.time as well. |
I'm using this library here 24/7. I'm also power-cycling the RD on regular basis, and reconnect.
Problems I saw was, the communication was kind of slow. Reconnecting is very unreliable and sometimes lead python to die due to deep recursion.
So I added a retry limit for the modbus stuff. And suddenly nothing goes. I debugged how many retries it did take for a single command, and it was up to 600!
Ok, so I found a bug:
3 minimalmodbus.TIMEOUT = 0.5 #???
Does nothing, I guess. (?)
According to the documentation of minimalmodbus, you have to set it like this:
snipped from init:
And by doing this, this module here gets decently fast. I only getting a single retry once in a while.
By the way, what I did, when implementing a retry:
I think you get it. The object (class) stores a retry value. The object a retry counter. Be aware that this is NOT thread safe (but the whole module is not). Also you can softlock the module. So I also added some helpers to check and reset:
Maybe the developer likes this idea. (I just did want to get rid of the deep recursion happening.) Also by doing so, you can blind fire the thing against a none powered RD, and "estimate" from the result that it is not powered.
(If I would know how to do git in this webpage, I could do a "push" request or something. Than you could see my version, and take over what you like.)
The text was updated successfully, but these errors were encountered: