The doPartition method works incorrectly based on wrong assumption that register ranges doesn't have gaps
PeterBorisenko opened this issue · comments
Peter B commented
To Reproduce
Steps to reproduce the behavior:
- Use the following data offsets with RegisterRange.HOLDING_REGISTER
private int initDataOffsets[]= {
0x0710, // device name
0x0711, // device name
0x0712, // device name
0x0780, // loads count
0x1200, // phases num
};
- Create batch read request
BatchRead<Integer> batch = new BatchRead<Integer>();
for (int i= 0; i < initDataOffsets.length; i++) {
batch.addLocator(i, new ModbusLocator(16, RegisterRange.HOLDING_REGISTER, initDataOffsets[i],
DataType.TWO_BYTE_INT_UNSIGNED, (byte) 0));
}
- Try to poll device:
BatchResults<Integer> res= batchRead(master, batch);
- If device doesn't have registers between 0x0712 and 0x0780 defined, there will be an error and res will be null.
Expected behavior
List<ReadFunctionGroup<K>> functionGroups
must be 3 here. But has 2.