pyhys / minimalmodbus

Easy-to-use Modbus RTU and Modbus ASCII implementation for Python.
Apache License 2.0
308 stars 145 forks source link

Handling of broadcast - no response expected #43

Closed j123b567 closed 3 years ago

j123b567 commented 4 years ago

When using address 0, no slave should reposne, so there is no answer expected (no need to wait for timeout etc.)

How to implement correctly this behavior in minimalmodbus?

After investigating the source code little bit, I must change the source itself. In function _perform_command, I set number_of_bytes_to_read = 0 when the address is broadcast. This generates exception minimalmodbus.NoResponseError without any timeout which is good compromise for me, but what is the correct solution for this?

If there is no good solution for this now, I can create pull-request, but currently, I don't know the target behavior which will fit to library ideas, e.g. what to return.

pyhys commented 3 years ago

I have now merged your PR. Thanks! I mentioned you in AUTHORS