Open intelligentandgoodlooking opened 3 years ago
Yes, the _u8ResponseBufferLength needs the stepup, but to avoid buffer overrun, the assignment should be moved inside brackets at 'if (i < ku8MaxBufferSize)' or else _u8ResponseBufferLength is increased even if no register is stored.
In the case with odd number of bytes, 'if (u8ModbusADU[2] % 2)', _u8ResponseBufferLength = i + 1; should be done inside the brackets, as i is already stepped from the for-statement.
Description
when a 1 word (2 byte) response is received _u8ResponseBufferLength is erroneously set to 0 instead of 1 similarly, a 16 word (32 byte) response is received, _u8ResponseBufferLength is set to 15 instead of 16. This causes available() to return 1 less than it should.
Issues Resolved
It seems like not many people use the available() function.
Check List
General
git diff --check
before committing.The following have been modified to reflect new features, if warranted
The following have NOT been modified