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

#629 Add kwarg 'reset_socket' to disable closing sockets on error #631

Merged
merged 1 commit into from
May 13, 2021

Conversation

dhoomakethu
Copy link
Contributor

@dhoomakethu dhoomakethu commented May 13, 2021

Closes #629

Starting pymodbus 2.5.0 on error client is closed and a new socket is initialized on a new request. This seems to be having adverse effect on the functionality of pymodbus with some of the hardwares. As a workaround, introducing new kwarg reset_socket which is set to True by default implying socket will be closed on error. Setting this to False will keep the socket open till client is explicitly closed or application is stopped.

Example usage

client = ModbusSerialClient(method='rtu',....., reset_socket=False)

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

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

The patch is tested using homeassistant with the modbus integration, and works as intended.

HA will upgrade a.s.a.p. if/when a patch release is available.

Thanks for the help
Jan I (maintainer of the modbus integration in HA).

pymodbus/repl/server/cli.py Show resolved Hide resolved
pymodbus/repl/server/cli.py Show resolved Hide resolved
@dhoomakethu dhoomakethu merged commit 6c15a3a into dev May 13, 2021
camtarn pushed a commit to camtarn/pymodbus that referenced this pull request Dec 6, 2021
pymodbus-dev#629 Add kwarg 'reset_socket' to disable closing sockets on error
@janiversen janiversen deleted the home-assit-fix-#629 branch April 5, 2022 07:55
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modbus RTU (serial) connection fails after first command in 2.5.1, (works in 2.3.0)
2 participants