Hello,
so far getting byte values is working but I'd like some opinions on the byte order.
Should byte 0 be the LSB or MSB?
Modbus being big-endian the first byte in the register (register is a 16-bit word) is the MSB. The second is the LSB.
But in my PLC when I configure the variables the first byte value at a given address is the LSB, the second the MSB.
To summarize:
PLC configuration
BYTE first AT %QB616
BYTE second AT %QB617
MODBUS register 308 (word value)
second | first
modbus4j
should this be
batchRead.addLocator("second", slaveId, RegisterRange.INPUT_REGISTER, 308, DataType.BYTE, (byte) 0);
batchRead.addLocator("first", slaveId, RegisterRange.INPUT_REGISTER, 308, DataType.BYTE, (byte) 1);
or
batchRead.addLocator("first", slaveId, RegisterRange.INPUT_REGISTER, 308, DataType.BYTE, (byte) 0);
batchRead.addLocator("second", slaveId, RegisterRange.INPUT_REGISTER, 308, DataType.BYTE, (byte) 1);
I would prefer the latter.
Regards
jmbsps