-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Automatic protocol version handshake #5233
Conversation
Matching firmware PR: PX4/PX4-Autopilot#7344 |
@DonLakeFlyer Firmware PR is through. If you can review / cross-test we can get this in (but its not needed for v3.2). |
@DonLakeFlyer Full documentation: https://mavlink.io/en/mavlink-version.html#version-handshaking |
This isn't quite right. It treats all links as a single group. Either mavlink 1 or 2 based on lowest common denominator vehicle reporting. It should really be on a link by link basis based only on the vehicles on the specific link. That said, I think that gets way more complicated. This should be fine for 3.2. And maybe forever. I still don't get how if there is a radio that doesn't support mav 2 in the middle how this works. Mavlink defaults to mav 1 for status flags doesn't it? So initial send of MAV_CMD_REQUEST_PROTOCOL_VERSION will be over mavlink 1 protocol. And it will go through. Is the link supposed to start out as mav 2 and then fall back? If so I don't see the code for that. |
@DonLakeFlyer The reason I don't want to treat it link-by-link, vehicle-by-vehicle is that managing that configuration space is super error prone (imagine that you can send geofence over one link, but not over another - how do you want to deal with that?). Anyone who knows what he is doing will use MAVLink 2 exclusively. The only reason to have detection and fallback is to ensure that random users don't get bitten when they upgrade to a new QGC version and their old plane is not yet supporting MAVLink 2 throughout. But really, the main focus here is to enable a safe upgrade path - I'm not really trying to support mixed setups. In terms of detection: The trick is that the PROTOCOL_VERSION message is sent in MAVLink 2 framing. That ensures that the link supports 2.0. But the message will in the future be also important for cases where we have v2.1 or v2.5. |
This is good to go. If the remote vehicle does not support discovery but sends MAVLink 2 it will stick with that as default. |
@DonLakeFlyer I haven't tested this yet on hardware, but wanted to see if it fits the flash. This branch teaches the SiK radio to respond properly to PROTOCOL_VERSION, which in turn would allow QGC to detect wether or not the radio can do MAVLink 2. It likely will require adjustments to this pull, but this would be the watertight solution. |
I will test this one round more and then get it in. @bkueng This is needed for polygons and stuff as it switches the system automatically. |
Re-tested: With just USB connected the link auto-switches to MAVLink 2, with a 3DR Radio it stays at MAVLink 1. And with forced MAVLink 2 it also seems to work:
From QGC output: Switching outbound to mavlink 2.0 due to incoming mavlink 2.0 packet |
This still needs work - I still need to test with the upgraded radio. |
Looking through this I can't quite see if it delays the initial plan request until it knows the mavlink version? |
This extension introduces a complete version handshake mechanism which will detect wether the vehicle AND the complete link / routing infrastructure support MAVLink 2. If they do, QGC will switch to the highest protocol version supported by all connected vehicles. If a new vehicle connects, it will re-negotiate the highest possible version. This means that we error on the side of compatibility, which later can be easily changed.
…two links to the same vehicle are connected and one can only do v1
This is important to avoid having QGC hijack links that are active (we read 2000 bytes!) but are definitely not MAVLink. This can have nasty side-effects, e.g. if we would talk to an LTE modem in a laptop or alike.
…nabled, including radio status.
@DonLakeFlyer Yes it does, because it queues the command requesting the protocol version and only fully initializes when that is received. I've also taken care of the SiK / 3DR radio: This PR now contains an updated link to a stable build that is a) MAVLink 2.0 enabled and b) reacts correctly to the handshaking mechanism. Code for that is here: LorenzMeier/SiK#1 If a user has not yet updated his 3DR radio QGC will tell him now. It will still work as a link but fall back to MAVLink 1 automatically with a pop-up warning the user. With this addition this should be watertight and good upgrade path for the user base. It's properly documented, takes care of the corner cases and does not leave existing users behind. @dogmaphobic You will want to upgrade your ESP8266 bridge too. Here are the handshaking docs: https://mavlink.io/en/mavlink-version.html From my side this is now all good to go. |
I still don't see how this causes _startPlanRequest to not be called until the protocol version is known. The code in Vehicle still triggers _startPlanRequest on capability bits known and parameters ready. I don't see any checked for protocol being known as well. |
Let me re-check it. I was relatively certain that the remaining load could not happen until the first commands were handled, but I might have missed a parallel code path. I will update here. |
@DonLakeFlyer I made the dependency explicit. |
@LorenzMeier Yup. Looks good. Any reason to not merge now. Then I can use this in my GeoFence stuff as well. |
Ok, merged. |
This extension allows to negotiate with all connected vehicles the highest possible MAVLink version supported by all. It is compatible with legacy vehicle software (interprets NACK and timeouts as v1.0 requests). This allows to have the best possible version enabled without any user configuration.
Before connecting QGC:
After connecting QGC with this extension: