diff --git a/src/com/intelligt/modbus/jlibmodbus/Modbus.java b/src/com/intelligt/modbus/jlibmodbus/Modbus.java index b9ef374..194c465 100644 --- a/src/com/intelligt/modbus/jlibmodbus/Modbus.java +++ b/src/com/intelligt/modbus/jlibmodbus/Modbus.java @@ -290,7 +290,7 @@ static public boolean checkEndAddress(int value) { * @return "true" if register value is correct, else "false". */ static public boolean checkRegisterValue(int value) { - return checkRange(value, 0, Modbus.MAX_REGISTER_VALUE); + return checkRange((short)value, 0, Modbus.MAX_REGISTER_VALUE); } /** diff --git a/src/com/intelligt/modbus/jlibmodbus/data/ModbusHoldingRegisters.java b/src/com/intelligt/modbus/jlibmodbus/data/ModbusHoldingRegisters.java index 9fc5507..f3c3e7e 100644 --- a/src/com/intelligt/modbus/jlibmodbus/data/ModbusHoldingRegisters.java +++ b/src/com/intelligt/modbus/jlibmodbus/data/ModbusHoldingRegisters.java @@ -188,7 +188,7 @@ private void checkRange(int offset, int quantity) throws IllegalDataAddressExcep } private void checkAddress(int offset) throws IllegalDataAddressException { - if (offset > (getQuantity() - 1)) + if (DataUtils.wordLow(offset) > (getQuantity() - 1)) throw new IllegalDataAddressException(offset); }