digitalpetri / modbus

Modbus TCP, Modbus RTU/TCP, and Modbus RTU/Serial for Java 17+.
Eclipse Public License 2.0
653 stars 222 forks source link

Modbus master V1.2.2, Floating data is incorrect #72

Closed iotclouddeveloper closed 2 months ago

iotclouddeveloper commented 2 months ago

the device reports a floating point number(11708533.0), I use 03function code,the code is
ByteBuf buf = response.getRegisters(); float result = buf.readFloat(); but I can get 11708533.0,What is the reason for this? Kind regards, Thanks.

kevinherron commented 2 months ago

Your device is probably using little-endian byte order, swapping the word order, or both.

If you can provide an example of the bytes you're receiving I might be able to help you figure out which.