Skip to content

Flush recv_buffer before each transaction write. #2581

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

Merged
merged 1 commit into from
Feb 22, 2025

Conversation

jameshilliard
Copy link
Contributor

@jameshilliard jameshilliard commented Feb 21, 2025

Ensure we don't have any non-relevant data in the buffer.

Haven't tested yet but I think this is the expected behavior based on this comment.

@@ -152,6 +152,7 @@ async def execute(self, no_response_expected: bool, request: ModbusPDU) -> Modbu
)
return response
except asyncio.exceptions.TimeoutError:
self.recv_buffer = b""
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the wrong place, since it can cause conflicts with the active callback.

It would be better placed in line 140, which is before the callback is active.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yeah I guess purging the buffer before doing the write makes more sense.

Ensure we don't have any non-relevant data in the buffer.
@jameshilliard jameshilliard changed the title Flush recv_buffer on timeout Flush recv_buffer before each transaction write. Feb 22, 2025
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.

None yet

2 participants