Mavlink: Fix forwarding of messages with target system/component id #12559
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.
Mavlink does not correctly forward messages that have the
target_system
ortarget_component
routing fields in the message.Some investigation revealed that the
Mavlink::forward_message
function is incorrectly utilizing themavlink_msg_entry_t.target_system_ofs
andmavlink_msg_entry_t.target_component_ofs
fields. These offsets are intended to be used relative to the start of the message payload. But, as implemented, these offsets are incorrectly being used relative to the start of the message. This pull-request corrects that problem.I also correctly made use of the
mavlink_msg_entry_t.flags
field to determine if a message contains atarget_system
ortarget component field
. The previous check incorrectly assumed that they would always be non-zero if present.See here: https://mavlink.io/en/guide/routing.html#c-library-mavgen
Quote:
Test Configuration
All testing was performed on px4_fmu-v5 hardware. The following system setup was used:
Host PC (Custom Mavlink Utility) <--> PX4 TELEM1 (Mode: Normal, Forwarding: Y)
PX4 TELEM2 (Mode: Onboard, Fowarding: Y) <--> Companion Computer App (Custom Mavlink Utility)
Mavlink status