pyhys / minimalmodbus

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

Function code 16 not accepting integers for `Float` payload anymore #78

Closed alihamdan closed 1 year ago

alihamdan commented 2 years ago

The commit type checking with mypy introduced a regression where Float payloads with function code 16 no longer accept integer values. This behavior is caused by this assert statement https://github.com/pyhys/minimalmodbus/blob/185afffd2d65b585f69bc5e3f640270d2bd27444/minimalmodbus.py#L1619-L1621

I believe this should allow int values as the underlying struct.pack handles the conversion.

pyhys commented 1 year ago

Fixed in the latest release. Thanks for the report!