Fix off-by-one error in WriteMultipleCoils calculation. For full bytes, the Byte Count field was calculated too high:
8 // 8 + 1 = 2
while only one byte is needed to represent 8 coils.
Offset the values length before the truncating division to correctly
round to whole bytes. This is easier than what the standard
formulates:
N = Quantity of Outputs / 8, if the
remainder is different of 0 ==> N = N+1
Note that the actual data bytes were already handled with the correct
length. So in case of 8 coils, uModbus would send a Byte Count of 2,
but only one data byte before the checksum
Coverage decreased (-0.5%) to 95.814% when pulling 4db2279ab12d491245bb063b00bb3d38348fac0c on acolomb:fix-length-writing-multiple-coils into 63c7679fa3feb4d85e8b4c3ef892c2f264dbf4b2 on AdvancedClimateSystems:master.
Fix off-by-one error in WriteMultipleCoils calculation. For full bytes, the Byte Count field was calculated too high: 8 // 8 + 1 = 2 while only one byte is needed to represent 8 coils.
Offset the values length before the truncating division to correctly round to whole bytes. This is easier than what the standard formulates: N = Quantity of Outputs / 8, if the remainder is different of 0 ==> N = N+1
Note that the actual data bytes were already handled with the correct length. So in case of 8 coils, uModbus would send a Byte Count of 2, but only one data byte before the checksum