Add MessageData trait to allow serialize ***_DATA structs into into MAVLinkV[1|2]MessageRaw #163
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.
Problem
Microcontrollrs firmware consumes very many FLASH (
.text
) bytes.Below is a piece of real code which parses Mavlink message from
MAVLinkV2MessageRaw
. TheMAVLinkV2MessageRaw
previously received by using UART DMA.Optimization settings:
Classic
MavMessage::parse
:Use
***_DATA::deser
:If I add message serialization then
Note that I can not use
***_DATA
for serialization in current API.P.S. Typical FLASH size for microcontrollers (Blue Pill STM32F103C8T6) is 64 KB.
My code with receiving and transmitting Mavlink messages consumes 218KB (Mavlink
***_DATA::ser
and***_DATA::deser
consume ~135KB).Solution
I propose to add this API:
It only new API, no breaking changes (with little exception, see questions).
It allows serialize and parse
***_DATA
structs without usingMessage
(for examplemavlink::common::MavMessage
). Thus compiler will be generate only code for limited series of***_DATA
structs.Unresolved questions
***_DATA:: ser
toserialize
orserialize_payload
?MessageData::ENCODED_LEN
toMessageData::SERIALIZED_LEN
?MAVLinkV[1|2]MessageRaw::calculate_crc
as unnecessary. This is right?