kochedykov / jlibmodbus

JLibModbus - is an implementation of the Modbus protocol v1.1b in java language. Java modbus library. It works. Welcome.
http://kochedykov.github.io/jlibmodbus/
Apache License 2.0
307 stars 128 forks source link

support negative value for register #86

Closed neutralhy closed 9 months ago

neutralhy commented 1 year ago

Currently, checkRegisterValue ranges from 0 to MAX_REGISTER_VALUE, but negative values can also be handled.

So I suggest code like this.

: at Modbus.java

static public boolean checkRegisterValue(int value) {
    return checkRange(value, Short.MIN_VALUE, Modbus.MAX_REGISTER_VALUE);
}
kochedykov commented 9 months ago

Fixed with commit 32a1ad7a2ca697fef4bd5487a96de4d747370b54