brainelectronics / micropython-modbus

MicroPython Modbus RTU Slave/Master and TCP Server/Slave library
GNU General Public License v3.0
104 stars 45 forks source link

read_input_registers is limited 16 bit? #93

Open mofm opened 3 months ago

mofm commented 3 months ago

Description

The documentation of my Modbus device is as follows:

"Signed Measurement (32-bit)
Decade Exponent (Signed 8-bit)
Binary Signed value (24 bit)
Example: - 123456*10-3 = FDFE 1DC0(16)"

But as it is written in the documentation of the umodbus.serial library: "Input registers can hold values ​​between 0 and 65535. If supported by the client device, data can be marked as signed values ​​to represent -32768 through 32767."

So this function only supports 16 bit values? Also, if positive values ​​do not exceed 65000, there is no problem. But negative values ​​are returned, such as 65xxx. How can I fix this?

Reproduction steps

1. 2. 3. ...

MicroPython version

v1.23.0

MicroPython board

Raspberry Pico

MicroPython Modbus version

# e.g. v2.3.3
# use the following command to get the used version
import os
from umodbus import version
print('MicroPython infos:', os.uname())
print('Used micropthon-modbus version:', version.__version__))

Relevant log output

No response

User code

No response

Additional informations

No response