Repository navigation
Conversation
StreamParser(source, verify_checksum=True) checks each UAS Local Set packet against its Checksum item (tag 1) as received and skips packets that fail, with a warning. UASLocalMetadataSet.checksum_valid() checks a parsed packet. Default behavior is unchanged. KLVParser keeps the raw BER length bytes of the last item, so packets sent with a long-form length still verify.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #58.
StreamParsernever checked the Checksum item (tag 1), so a packet with a bad length or corrupted bytes decoded as if it were fine. That is what cost two days in the issue.StreamParser(source, verify_checksum=True)checks each UAS Local Set packet against its checksum as it was received, and skips packets that fail with aUserWarning. The default isFalse, so nothing changes for current users.UASLocalMetadataSet.checksum_valid()checks a parsed packet.KLVParserkeeps the raw BER length bytes of the last item, so a packet sent with a long-form length still verifies. (bytes(packet)re-encodes the length in short form, which changes the sum.)One thing this turned up:
data/DynamicConstantMISMMSPacketData.binstill carries the checksum from the ST 0902.5 example (0xAA43), but its content sums to0x3E1E. The comment intest_common.pysays the file was patched; only the content was. I left the file as is and use it as the bad-checksum case. Happy to patch its last two bytes instead if you prefer.Tests: 4 new tests in
test/test_streamparser.py(valid packet, stale sample, bit flip skipped with a warning, long-form length).python -m unittest discover -s test -t .: 120 tests pass.I ran into this while checking my Rust KLV crate (misb) against klvdata on the public Day Flight and Night Flight samples. klvdata matched on all 641 values; the stale checksum was the only difference.