jlibmodbus icon indicating copy to clipboard operation
jlibmodbus copied to clipboard

Register value out of range : 65280

Open Andrii10 opened this issue 5 years ago • 3 comments

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_REGISTER_VALUE); }

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

Andrii10 avatar Jun 17 '20 08:06 Andrii10

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

FutureGUIs avatar Jun 17 '20 14:06 FutureGUIs

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

jonasgerne avatar Nov 26 '20 16:11 jonasgerne

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

kochedykov avatar Feb 03 '21 11:02 kochedykov