Skip to content
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

Wait for correct response id #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

decadenza
Copy link

Due to noise/interference on the serial line (separate problem), I was having errors like:

error="modbus: response slave id '69' does not match request '1'"
error="modbus: response slave id '48' does not match request '1'"

And so on.

My system has only one slave with id 1.
I came across this issue on a different repository.
image

As I understand it, Modbus protocol specifies that master should manage the "unexpected slave" and wait for the correct one for the specified timeout setting.

Checking the code I realised that the client was not waiting for the correct timeout before throwing the error.

With this simple change my error rate has reduced, and when it happens the correct "timeout" error is given.

@decadenza
Copy link
Author

Added error value err = fmt.Errorf("modbus: response timeout")

Copy link
Contributor

@frzifus frzifus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to limit the amount of retries and to introduce a break between the retries?

@decadenza
Copy link
Author

@frzifus Yes, that is what I was doing as a sub-optimal measure. But I think it would be preferable to actually follow the specifications. The problem arises when the traffic is high. Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants