Skip to content

fix: correct CCSDS packet length calculation - #4

Merged
robamu merged 1 commit into
us-irs:mainfrom
0rlych1kk4:fix/ccsds-packet-length
Sep 1, 2026
Merged

fix: correct CCSDS packet length calculation#4
robamu merged 1 commit into
us-irs:mainfrom
0rlych1kk4:fix/ccsds-packet-length

Conversation

@0rlych1kk4

Copy link
Copy Markdown
Contributor

Summary

Fix CcsdsTcPacketOwned::len_written() and
CcsdsTmPacketOwned::len_written() to use the length of the already-serialized
payload bytes instead of the postcard serialized size of the Vec<u8> container.

Previously, len_written() overestimated the actual packet length because
postcard serialization of a Vec<u8> includes its length prefix, while
write_to_bytes() copies the payload bytes directly.

Testing

Added regression tests verifying:

packet.len_written() == packet.to_vec().len()

For both TC and TM packets.

Verified with:

cargo test -p types

Signed-off-by: 0rlych1kk4 <orlychikka@gmail.com>
@robamu

robamu commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

thanks for finding this and fixing it!

@robamu
robamu merged commit 877312d into us-irs:main Sep 1, 2026
9 checks passed
@0rlych1kk4
0rlych1kk4 deleted the fix/ccsds-packet-length branch September 2, 2026 06:33
@0rlych1kk4

Copy link
Copy Markdown
Contributor Author

Thanks, glad I spotted it. Nice to get the length calculation and regression coverage cleaned up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants