Fix sequence order in serialization function #204
Merged
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.
I am currently doing my bachelor's degree about MAVLink and LoRa. I decided to use rust and therefore rust-mavlink.
I need to serialize and deserialize MavFrames to send them over the LoRa link. While doing that, I noticed a weird behavior of the deser function. The order of serializing the header fields (system_id, component_id and sequence) does not align with the order of deserialization.
Here is a screenshot showing the problem
![image](https://private-user-images.githubusercontent.com/48621967/284258449-7d6952ab-6d54-423b-a41e-384aab6396f0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MDg3ODIsIm5iZiI6MTczOTUwODQ4MiwicGF0aCI6Ii80ODYyMTk2Ny8yODQyNTg0NDktN2Q2OTUyYWItNmQ1NC00MjNiLWE0MWUtMzg0YWFiNjM5NmYwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDA0NDgwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTExMWZiYzBlZTEzZTU0NmNmYTBiNzg0NzE2MTQzM2YxMDdjOTUyMDlhOTE5OTBlNjYxNjgyMzI2OGEzNDBiZTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Tm-b21dEPttFxj5YOblsZPOePHEUzvyjazZayUhnk_4)
Order of serialization
![image](https://private-user-images.githubusercontent.com/48621967/284258941-0d2ce99e-1ccb-4e1f-b0bf-5745aead3d59.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MDg3ODIsIm5iZiI6MTczOTUwODQ4MiwicGF0aCI6Ii80ODYyMTk2Ny8yODQyNTg5NDEtMGQyY2U5OWUtMWNjYi00ZTFmLWIwYmYtNTc0NWFlYWQzZDU5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDA0NDgwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJmYjYyZmY3YzA2ODEyMjIyNjg5MGQwNjQzYzZkYTZjYTQwYTNjMTZiMjkzNGE1MDJkODlmNjY5ZTM1NmYxOTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ZNiAgF14gYXWcgZ7ogWaN2Ga-Pwkv8FZ2g6RJc379mY)
Old order of deserialization
![image](https://private-user-images.githubusercontent.com/48621967/284259126-3ea06dac-d578-479e-a93c-9bf017dfd9fc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MDg3ODIsIm5iZiI6MTczOTUwODQ4MiwicGF0aCI6Ii80ODYyMTk2Ny8yODQyNTkxMjYtM2VhMDZkYWMtZDU3OC00NzllLWE5M2MtOWJmMDE3ZGZkOWZjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDA0NDgwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYwNzAyZGU3OTkyMDI0MTYyMjVlNGU1MjgzMjg5MGEwYWM3YzE1YTIzMzBiOWIwZGY4MDliYjIxOGRhODRjM2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.vmJkscvK9e8xdtBnWC5uTZWcYtPa8f28fpc7b5v9mBc)
Also, if you look closely, the values are all over the place and do not match (it's not a corrupt message problem). I am going to open a separate issue for that (#205), as I am still investigating it and is not related to the header.