Update CRC to be capable of calculating CRC when data is received in chunks #61
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.
Description
We have addressed the issue where CRC variants could not be utilized for data chunks. An example of its use is when receiving large data, such as a firmware file, which cannot be received in a single operation.
When data arrives in chunks, it is necessary to continue calculating the CRC when new data arrives. This is where we can store the last calculated CRC value and provide it when the next set of data arrives. To enable this functionality, we have introduced a pointer called
last_crc_ptr
. For the first data chunk, we need to use the initial CRC value, so the first operation will require aNULL_PTR
(internal logic will interpret it as initial CRC value) . For every subsequent data chunk, we use the pointer to access the last CRC value.Things become more complex for CRC variants that also involve final XOR and output reflection. This operation only occurs during the last CRC operation, so it is the user's responsibility to determine when the last operation is taking place (when the last data chunk has arrived) and provide information through the
final_crc
flag."Checklist
Please check off the following items by putting an "x" in the box:
make cppcheck
on my code and fixed any reported issues.make astyle
on my code and ensured that it adheres to the project's formatting guidelines.Additional Notes
For more information on how to use it properly with data chunks see tests with the comment "
// Test with message in chunks"
Example: https://github.com/IMProject/IMUtility/pull/61/files#diff-3606d33130e3178a90da898bed06d65b10f0163b4ba0ceb8255f25540943aba8R173-R177