WriteCoilsRequest
-
Hi,
I'm Andrex
(http://mango.serotoninsoftware.com/forum/posts/list/379.page#1831)after some test of tcp transport I found some unexpected exception while send more than 1016 coil values.
After decompiling modbus4J.jar shipped with the version 1.8.2 of mango I found that line 60 of
com.serotonin.modbus4j.msg.WriteCoilsRequest
/* 60 */ this.data = new byte[ModbusUtils.popByte(queue)];
is the origin of th exception.
After changing the line to/* 60 */ this.data = new byte[ModbusUtils.popUnsignedByte(queue)];
(using unsigned value) my test pass correctly.
I dont know if the original row is incorrect or if my change is a good correction, but I hope to be helpful.
Regards
Andrea -
Hi Andrea,
Thanks for reporting this. You are correct, an unsigned byte should be popped at that point. I've made the fix in the code.
-
Oh, also, i believe a similar change is required in WriteRegistersRequest at line 59:
data = new byte[ModbusUtils.popByte(queue)];
... should be:
data = new byte[ModbusUtils.popUnsignedByte(queue)];