Skip to content

fix(autopilot-manager): refresh the autopilot version after a reflash#101

Merged
dakejahl merged 1 commit into
mainfrom
fix/autopilot-version-refresh
Jul 15, 2026
Merged

fix(autopilot-manager): refresh the autopilot version after a reflash#101
dakejahl merged 1 commit into
mainfrom
fix/autopilot-version-refresh

Conversation

@dakejahl

Copy link
Copy Markdown
Contributor

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_firmware tears the link down and rebuilds it on the same MAVLinkConnection, 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.

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.
@dakejahl
dakejahl merged commit 3f3b74f into main Jul 15, 2026
1 check passed
@dakejahl
dakejahl deleted the fix/autopilot-version-refresh branch July 15, 2026 21:12
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.

1 participant