Skip to content

Fix default no-response behavior for force listen only#2941

Merged
janiversen merged 2 commits into
pymodbus-dev:devfrom
MrAlaskan:fix/diag-force-listen-only-no-response
Jun 24, 2026
Merged

Fix default no-response behavior for force listen only#2941
janiversen merged 2 commits into
pymodbus-dev:devfrom
MrAlaskan:fix/diag-force-listen-only-no-response

Conversation

@MrAlaskan

Copy link
Copy Markdown
Contributor

Summary

This PR fixes the default behavior of diag_force_listen_only().

Previously, the method used no_response_expected=False by default, so the client would wait for a reply after sending Force Listen Only Mode.

According to the Modbus specification for Diagnostics sub-function 0x08 / 0x0004, no response is returned for this request.

Change

  • Before: diag_force_listen_only(..., no_response_expected=False)
  • After: diag_force_listen_only(..., no_response_expected=True)

Rationale

This aligns the client default behavior with the protocol and with the method's own docstring, which already states that no response is returned.

Without this change, a default call to diag_force_listen_only() can incorrectly fall into a timeout or retry path even when the request was successfully accepted by the remote device.

@janiversen janiversen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can actívate or deactivate the function, so the default value does not really matter.

However your point about the documentation is correct.

Thanks

@janiversen janiversen merged commit 347979f into pymodbus-dev:dev Jun 24, 2026
15 of 16 checks passed
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