pymodbus-dev/pymodbus

v3.7.0 Coil read actually send broadcast write

ulfaric opened this issue · 20 comments

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")

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.

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,

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.

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.

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.

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.

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.

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.

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

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

Reopen as a 3.7.1 reminder.