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

v3.7.0 Coil read actually send broadcast write #2297

Closed
ulfaric opened this issue Aug 26, 2024 · 20 comments · Fixed by #2298
Closed

v3.7.0 Coil read actually send broadcast write #2297

ulfaric opened this issue Aug 26, 2024 · 20 comments · Fixed by #2298

Comments

@ulfaric
Copy link

ulfaric commented Aug 26, 2024

Versions

  • Python: 3.12
  • OS: win11
  • Pymodbus: 3.7.0
  • Modbus Hardware (if used):

Pymodbus Specific

  • Server: tcp/rtu/ascii - sync/async
  • Client: tcp/rtu/ascii - sync/async

Description

in 3.7.0, when call client.read_coils(), it sends a broadcast write rather than read.

Code and Logs

# code and logs here.

# please use the following to format logs when posting them here
import pymodbus

pymodbus.pymodbus_apply_logging_config("DEBUG")
@janiversen
Copy link
Collaborator

janiversen commented Aug 26, 2024

You do not show your code, so it is impossible to help you. You talk about "broadcast write" which type of write (modbus function code).

Probably you have forgotten the slave parameter, please see the documentation.

please add a debug log, as requested (see your own text above), so we can see what actually happens.

@ulfaric
Copy link
Author

ulfaric commented Aug 26, 2024 via email

@janiversen
Copy link
Collaborator

We have a couple of users that use pymodbus on android (I cannot tell you how), and at least 1 is using with python 3.11 without problems.

I do not think that "broadcast write" can be caused by a android problem.

Please remark we no longer support python 3.8, so please do not report issues with that version.

Anyhow happy you got it working,

@janiversen janiversen closed this as not planned Won't fix, can't repro, duplicate, stale Aug 26, 2024
@ulfaric
Copy link
Author

ulfaric commented Aug 26, 2024 via email

@janiversen
Copy link
Collaborator

That is impossible! we have not even defined version 3.9 yet !

Our current version is 3.7.0

You still have not shared your code, so I cannot tell you if your code have been updated properly to 3.7+

Also you have still not made a debug log so we can see what is actually
happening.

@ulfaric
Copy link
Author

ulfaric commented Aug 27, 2024 via email

@ulfaric
Copy link
Author

ulfaric commented Aug 27, 2024 via email

@janiversen
Copy link
Collaborator

janiversen commented Aug 27, 2024

Please submit your code and debug log (see the description you added, it contains the instructions).

The difference between 3.6.8 and 3.6.9 should not contain any function code changes, so I am confused as to how it can send a wrong function call.

Please add:

  • the code containing the call that is wrong
  • a debug log showing the call and the hex string sent on the line
  • explain "broadcast write", do you the the device id or a different function code ?

without these 3 items I cannot help you.

You wrote "in 3.7.0, when call client.read_coils(), it sends a broadcast write rather than read.". that is what you need to clarify, because there are no broadcast write in modbus.

@ulfaric
Copy link
Author

ulfaric commented Aug 27, 2024 via email

@janiversen
Copy link
Collaborator

janiversen commented Aug 27, 2024

This is happening because you are NOT addressing your device, but relying on default, which is to send the message with the broadcast id. It does NOT change the function code.

Please read our documention, or at the very least follow the signature (especially in 3.7.0) of the call that details the parameters.

This is an open world, so why would I mind you make another version. If you use any code from pymodbus, then please remember to fork pymodbus, and base your code on that....copying the code without attribution is breaking the license (which github is monitoring).

The FOSS way would be to submit your changes to pymodbus and keep that updated for all users, but it is of course your choice.

@ulfaric
Copy link
Author

ulfaric commented Aug 27, 2024 via email

@janiversen
Copy link
Collaborator

Have a look at API_changes.rst ! but yes there are api changes since it is a x.y version…the only versions without API changes are x.y.z

the API changes in 3.7.0, does not affect well behaved programs, but only programs the violate the call signatures, and 3.7.0 adapted code can be used with all 3.6.z versions.

@ulfaric
Copy link
Author

ulfaric commented Aug 27, 2024 via email

@janiversen
Copy link
Collaborator

There are not screen shot, just copy/paste the call that is easier.

You probably use slave as a positional parameter which are likely to cause problems, or have slave=0, which is the broadcast id, so the message is correct.

@ulfaric
Copy link
Author

ulfaric commented Aug 27, 2024 via email

@janiversen
Copy link
Collaborator

That is NOT true !!!

slave=0 is broadcast pr modbus definition, the difference is that in 3.6.8 pymodbus falsely returned the first response instead of returning without waiting for response as the protocol defines.

@ulfaric
Copy link
Author

ulfaric commented Aug 27, 2024 via email

@janiversen
Copy link
Collaborator

3.7.1 will for other reasons, return the first response and disconnect if there are further responses when slave=0

@janiversen
Copy link
Collaborator

Hmmm…..you might like things to start with 0, but it actually does not depend on you, but on the device you are addressing.

@janiversen
Copy link
Collaborator

Reopen as a 3.7.1 reminder.

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 a pull request may close this issue.

5 participants
@janiversen @ulfaric and others