previous issue #64
I think this fix causes serious problems
The individual register size of Modbus is 2 bytes, but due to the modified code, it operates as 4 bytes.
For example, if the quantity set in the slave is 10, even if the master makes a request with setQuantity(10), the value of getQuantity() is 5 under the modified code,
and the data that should be read by 2 bytes are combined into 4 bytes and read.
Therefore, it must revert to the previous code.
static public int[] BeToIntArray(byte[] bytes) {
int[] dst = new int[bytes.length / 2];
for (int i = 0, j = 0; i < dst.length; i++, j += 2)
dst[i] = ((bytes[j] & 0xff) << 8) | (bytes[j + 1] & 0xff);
return dst;
}
previous issue #64 I think this fix causes serious problems
The individual register size of Modbus is 2 bytes, but due to the modified code, it operates as 4 bytes. For example, if the quantity set in the slave is 10, even if the master makes a request with setQuantity(10), the value of getQuantity() is 5 under the modified code, and the data that should be read by 2 bytes are combined into 4 bytes and read.
Therefore, it must revert to the previous code.
static public int[] BeToIntArray(byte[] bytes) { int[] dst = new int[bytes.length / 2]; for (int i = 0, j = 0; i < dst.length; i++, j += 2) dst[i] = ((bytes[j] & 0xff) << 8) | (bytes[j + 1] & 0xff); return dst; }