Skip to content

Fix dropped messages by libmav_receiver.cpp#2722

Merged
julianoes merged 1 commit intomavlink:mainfrom
rantalaine:fix/libmav-receiver-datagram-handling
Dec 1, 2025
Merged

Fix dropped messages by libmav_receiver.cpp#2722
julianoes merged 1 commit intomavlink:mainfrom
rantalaine:fix/libmav-receiver-datagram-handling

Conversation

@rantalaine
Copy link
Copy Markdown
Contributor

PR to receive all MAVLink messages when using libmav_receiver.cpp

Background: we noticed significant amount of messages being dropped by MAVSDK server. This was verified by comparing received message count between pymavlink and mavsdk_server, while using discretely sent msg type (CAMERA_IMAGE_CAPTURED) for easier counting. On pymavlink, all messages came through. MAVSDK dropped roughly a third of messages. Missing messages was double checked with other streams.

In mavlink_receiver.cpp, there is a comment:
// Note that one datagram can contain multiple mavlink messages.

But libmav_receiver.cpp always set datagram to nullptr after parsing one message - essentially discarding any remaining messages in the datagram.

Changes tested with PX4-based flightcontroller connected over serial to aarch64/Ubuntu 22.04-based machine running mavsdk_server binary. No message drops observed with patched code.

Enable parsing multiple messages from one datagram
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Dec 1, 2025

@rantalaine
Copy link
Copy Markdown
Contributor Author

Based on issue description probably fixes #2685

Copy link
Copy Markdown
Collaborator

@julianoes julianoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thanks! This was clearly wrong!

@julianoes julianoes merged commit 1de1e2b into mavlink:main Dec 1, 2025
53 checks passed
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