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
299 stars 128 forks source link

Register value out of range : 65280 #52

Open Andrii10 opened 4 years ago

Andrii10 commented 4 years ago

Hello I have problem with last version jlibmodbus 1.2.9.7 when I use function x05 WriteSingleRegister in public void setValue(int value) throws ModbusNumberException { if (!Modbus.checkRegisterValue(value)) { throw new ModbusNumberException("Register value out of range", value); } this.value = ((short) value) & 0xffff; } I take error Register value out of range : 65280 in method _static public boolean checkRegisterValue(int value) { return checkRange((short)value, 0, Modbus.MAX_REGISTERVALUE); }

And I fix the checkRange(value, 0, Modbus.MAX_REGISTER_VALUE) after that it worked for me Did this right or not help me?

FutureGUIs commented 4 years ago

I just had to do the same thing, remove the 'short' cast. and so far it's working fine for me.

jonasgerne commented 3 years ago

Having the same issue, using writeMultipleCoils as a workaround...

kochedykov commented 3 years ago

Yes. It is a bug. Please make a pull request.