pyhys / minimalmodbus

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

feat: add ignoreslaveaddress parameter #130

Open penguintamer opened 7 months ago

penguintamer commented 7 months ago

Allows bypassing slave address check for individual responses

closes #101

j123b567 commented 7 months ago

To be honest, I don't like the idea of polluting every single function with this parameter.

Wouldn't it be better to implement this as a state of the instrument?

You can later set this parameter forever for universal addresses

instrument.ignore_slave_address = True

Or do one time exchanges

with instrument.expect_invalid_slave_address():
    instrument.write_register(..., NEW_ADDRESS)
    instrument.address = NEW_ADDRESS