pyhys / minimalmodbus

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

broadcast expects answer? #95

Closed r0oland closed 1 year ago

r0oland commented 1 year ago

According to the modbus standard, devices should not answer to a broadcast: "In broadcast mode, the master can send a request to all slaves. No response is returned to broadcast requests sent by the master. The broadcast requests are necessarily writing commands. All devices must accept the broadcast for writing function. The address 0 is reserved to identify a broadcast exchange."

However, when writing a register via

instrument.address = 0
instrument.write_register(4000,4,functioncode=6)

I get a timeout and an error message.

Maybe I am missing something, but seems to me one should simply change the _perform_command() function to not expect a response when the address is set to 0?

r0oland commented 1 year ago

I dug a little deeper and found your TestDummyCommunicationBroadcast function, but it looks to me that this function also runs into the default serial timeout of 0.05s?

r0oland commented 1 year ago

I am sorry...I was simply on an old version because of using conda rather than pip...my apologies.