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

Max retries #186

Merged
merged 8 commits into from
Apr 24, 2023
Merged

Max retries #186

merged 8 commits into from
Apr 24, 2023

Conversation

ColinFinck
Copy link
Collaborator

As suggested in #184, I've fixed the infinite loop when reading from a broken Modbus RTU bus by introducing a maximum number of retries. When that number is reached, the code gives up and returns an error to the caller.

MAX_RETRIES is a constant that is set to 20 for now. Feel free to change that or make it configurable.

I had to edit other parts of the RTU code, which assumed that decoding can never fail. I took the opportunity to make them more readable and more consistent with the TCP code. Should get obvious when you check this PR commit by commit.

Let me know if this can go through or if there's anything I have to change.

Fixes #184

Copy link
Member

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

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

Thank you very much! Just some minor comments/questions.

Please rebase on main, I have just fixed the unrelated pre-commit issue.

src/codec/rtu.rs Show resolved Hide resolved
src/codec/rtu.rs Show resolved Hide resolved
src/codec/rtu.rs Outdated Show resolved Hide resolved
src/codec/rtu.rs Outdated Show resolved Hide resolved
src/codec/rtu.rs Outdated Show resolved Hide resolved
@uklotzde
Copy link
Member

While you are at it: Please add an entry to the changelog. I guess it is time to finally release this new version.

@ColinFinck
Copy link
Collaborator Author

I've addressed all your comments.
If you still have that Serial-to-USB adapter, which originally made you skip errors and implement error recovery, please verify that my new code still works with that. Other than that, it should be good to go.

@uklotzde uklotzde merged commit f9782f7 into slowtec:main Apr 24, 2023
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.

Infinite retry loop with heavy CPU load
2 participants