Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respond to MAVLINK 2 PROTOCOL_VERSION request #2449

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

jonathanreeves
Copy link

MAVSDK comfortably supports MAVLINK 2, but the server component doesn't currently respond to the MAVLINK_MSG_ID_PROTOCOL_VERSION request, and thus GCSes like QGroundControl fall back to MAVLINK 1 when establishing communication.

This change adds the MAVLINK_MSG_ID_PROTOCOL_VERSION handler with a corresponding capability to communicate to clients that MAVLINK 2 is supported.

QGroundControl log before:

InitialConnectStateMachineLog: Sending REQUEST_MESSAGE:PROTOCOL_VERSION
VehicleLog: _waitForMavlinkMessage msg:timeout 300 1000
...
InitialConnectStateMachineLog: REQUEST_MESSAGE PROTOCOL_VERSION command acked but message never received
InitialConnectStateMachineLog: "Setting _maxProtoVersion to 100 due to timeout on receiving PROTOCOL_VERSION message."
VehicleLog: _setMaxProtoVersionFromBothSources using protocol version message
VehicleLog: _setMaxProtoVersion before:after 200 100

QGroundControl log after:

InitialConnectStateMachineLog: Sending REQUEST_MESSAGE:PROTOCOL_VERSION
VehicleLog: _waitForMavlinkMessage msg:timeout 300 1000
VehicleLog: _sendMavCommandFromList command:tryCount "MAV_CMD_REQUEST_MESSAGE" 0
MissionControllerLog: _recalcFlightPathSegments homePositionValid false
VehicleLog: _waitForMavlinkMessageMessageReceived message received 300
VehicleLog: _waitForMavlinkMessageClear
VehicleLog: "_handleCommandAck command(MAV_CMD_REQUEST_MESSAGE) result(MAV_RESULT_ACCEPTED)"
InitialConnectStateMachineLog: PROTOCOL_VERSION received mav_version: 300
VehicleLog: _setMaxProtoVersionFromBothSources using protocol version message

Copy link
Collaborator

@JonasVautherin JonasVautherin left a comment

Choose a reason for hiding this comment

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

Thanks!

I didn't know that QGC was checking the version like this 👍. I just have a nitpick on the format of the static constexpr 👍.

@@ -25,6 +25,14 @@ class ServerPluginImplBase;

class ServerComponentImpl {
public:
static constexpr mavlink_protocol_version_t kMavlinkVersionInfo{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking at other static constexpr in the project, it feels like they are usually written more like this:

Suggested change
static constexpr mavlink_protocol_version_t kMavlinkVersionInfo{
static constexpr mavlink_protocol_version_t MAVLINK_VERSION_INFO {

Copy link
Author

Choose a reason for hiding this comment

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

Good call, sorry I should have looked at that more carefully. Change pushed to my fork and re-tested, thanks for the review and feedback!

Copy link

sonarcloud bot commented Nov 24, 2024

Copy link
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.

Thanks!

@julianoes julianoes merged commit 5a124d9 into mavlink:main Nov 25, 2024
38 of 39 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.

3 participants