Closed kazuyatada closed 3 years ago
You're right. This is a hangover from the original jmod version but I can't think why the cost of creating request objects was deemed to be so high that it reuses them?? I think I will look to change it so that they are all local instances which will avoid this problem altogether and allow checks to be added to the other request types if needed
Expected Behavior
It should be possible to read if it is in the range up to the last readable address (65535).
Actual Behavior
Under certain conditions, results will fail even in the range up to the last readable address (65535).
The setReference() method does the comparison: bitCount + ref > 65536. This bitCount is an instance variable. Since ModbusTCPMaster recycles ReadInputDiscretesRequest instances, the second and subsequent requests use the bitCount of the previous one for comparison. In other classes (e.g.: ReadCoilsRequest, ReadInputRegistersRequest), the setReference() method do not make such a comparison, so you probably don't need to make a comparison in ReadInputDiscretesRequest either.
Steps to Reproduce the Problem
Result.
Specifications