Fix calculation of ISO-TP SF size field length #56
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Given the following setup:
When sending a 7 byte payload, the full ISO-TP frame with size and address fields would have a minimum size of
7 (data) + 1 (addr) + 1 (header + size field) = 9
. According to the standard, when receiving a CAN frame with a data length of >8 byte, the size field must have a length of 12 bit and the first four bits must be equal to 0. However, the current implementation does not correctly calculate the length of the size field and uses only four bits.In the patch, I updated the size field length calculation to what I would assume to be correct. I also added a unit test to verify the correct behavior.