fix(autopilot-manager): refresh the autopilot version after a reflash#101
Merged
Conversation
The cached version was requested only while it read "Unknown", and nothing ever reset it, so the first value latched for the life of the process. After flashing new firmware the UI kept reporting the old version until something else (QGC connecting) asked the FC for AUTOPILOT_VERSION, whose reply mavlink-router fans out to our endpoint. Invalidate the cache on the heartbeat-gap episode and on the flash path. The flash needs its own call because disconnect() stops the message loop, so the heartbeat-gap branch cannot run during a flash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The autopilot version in the UI's System Information latched on first read and never updated after flashing new firmware, until QGC was opened.
Problem
The message loop requests AUTOPILOT_VERSION only while the cached version still reads
"Unknown", and nothing ever reset it back — it was assigned only in__init__. Once a real version landed, the request was never issued again, and PX4 does not send AUTOPILOT_VERSION unsolicited.flash_firmwaretears the link down and rebuilds it on the sameMAVLinkConnection, so the cache survived a flash untouched.Opening QGC masked the bug: QGC requests AUTOPILOT_VERSION itself, and since that message carries no target fields, mavlink-router fans the reply out to every endpoint including autopilot_manager on 14571, where the handler takes it unconditionally.
Solution
Clear the cached version and git hash so the existing 5-second poll re-arms, at both points where the FC may come back running different firmware: the heartbeat-gap episode, and the flash. The flash needs its own call rather than relying on the gap —
disconnect()stops the message loop, so that branch cannot run during a flash. The invalidation sits after the flash guard clauses, so a missing firmware file or absent FC does not discard a valid version.Verified by driving the real message loop against a fake FC that answers version requests: the version now refreshes from 1.14.3 to 1.15.0 across a simulated reflash with no QGC involved.