Skip to content

PositionManager/LinkManager: fall back to internal GPS when NMEA disabled#14588

Open
julianoes wants to merge 1 commit into
mavlink:masterfrom
julianoes:pr-nmea-fallback-internal-gps
Open

PositionManager/LinkManager: fall back to internal GPS when NMEA disabled#14588
julianoes wants to merge 1 commit into
mavlink:masterfrom
julianoes:pr-nmea-fallback-internal-gps

Conversation

@julianoes

@julianoes julianoes commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Switching NMEA off (e.g. Disabled in Comm Links) closed the UDP socket but left QGCPositionManager on the dead NMEA source, freezing the GCS position with no way back to the built-in GPS.

Add QGCPositionManager::resetNmeaSourceDevice() to tear down the NMEA source and, if active, revert to the platform default (e.g. integrated Android GPS). LinkManager calls it when NMEA is no longer configured, and also tears down a lingering serial NMEA port there.

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 31.72%. Comparing base (f29efd3) to head (253bb41).
⚠️ Report is 170 commits behind head on master.

Files with missing lines Patch % Lines
src/PositionManager/PositionManager.cpp 0.00% 11 Missing ⚠️
src/Comms/LinkManager.cc 0.00% 9 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (30.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14588      +/-   ##
==========================================
+ Coverage   25.47%   31.72%   +6.25%     
==========================================
  Files         769      785      +16     
  Lines       65912    67107    +1195     
  Branches    30495    31083     +588     
==========================================
+ Hits        16788    21292    +4504     
+ Misses      37285    31394    -5891     
- Partials    11839    14421    +2582     
Flag Coverage Δ
unittests 31.72% <0.00%> (+6.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/PositionManager/PositionManager.h 80.00% <ø> (+40.00%) ⬆️
src/Comms/LinkManager.cc 15.50% <0.00%> (+5.42%) ⬆️
src/PositionManager/PositionManager.cpp 13.38% <0.00%> (-1.87%) ⬇️

... and 459 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c85eb6e...253bb41. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Build Results

Platform Status

Platform Status Details
Linux Passed View
Windows Passed View
MacOS Passed View
Android Passed View

All builds passed.

Pre-commit

Check Status Details
pre-commit Failed (non-blocking) View

Pre-commit hooks: 0 passed, 0 failed, 0 skipped.

Test Results

linux-coverage-integration: 34 passed, 0 skipped
linux-coverage-unit: 109 passed, 0 skipped
Total: 143 passed, 0 skipped

Code Coverage

Coverage: 68.0%

No baseline available for comparison

Artifact Sizes

Artifact Size
QGroundControl 221.84 MB
QGroundControl-aarch64 179.44 MB
QGroundControl-installer-AMD64 137.96 MB
QGroundControl-installer-AMD64-ARM64 80.48 MB
QGroundControl-installer-ARM64 109.22 MB
QGroundControl-linux 87.11 MB
QGroundControl-mac 87.10 MB
QGroundControl-windows 86.15 MB
QGroundControl-x86_64 191.65 MB
No baseline available for comparison

Updated: 2026-07-22 05:19:33 UTC • Commit: 253bb41 • Triggered by: Android

This comment was marked as resolved.

@DonLakeFlyer

Copy link
Copy Markdown
Contributor

@julianoes Can you address the review. I believe both of these are correct from a bug standpoint

@julianoes
julianoes force-pushed the pr-nmea-fallback-internal-gps branch from 6da033d to 4034403 Compare July 20, 2026 21:28
@julianoes

Copy link
Copy Markdown
Contributor Author

@DonLakeFlyer done.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/Comms/LinkManager.cc:540

  • When switching NMEA to "Disabled", this deletes _nmeaPort before telling QGCPositionManager to tear down the active QNmeaPositionInfoSource. Since the position source may still be reading from that QSerialPort until resetNmeaSourceDevice() runs, this ordering risks a use-after-free/crash via queued events.
            if (_nmeaPort) {
                _nmeaPort->close();
                delete _nmeaPort;
                _nmeaPort = nullptr;
                _nmeaDeviceName = "";

Comment thread src/Comms/LinkManager.cc
Comment thread src/PositionManager/PositionManager.cpp
@DonLakeFlyer

Copy link
Copy Markdown
Contributor

@julianoes Can you look at new code review. It tends to be whack-a-mole unfortunately but it also tends to be correct.

@julianoes

Copy link
Copy Markdown
Contributor Author

Ha ok.

Disabling the NMEA GPS input (setting the Comm Links NMEA device back to
Disabled) closed the NMEA UDP socket but left QGCPositionManager stuck on
the now-dead NMEA source, freezing the displayed GCS position. Tear the
NMEA source down and fall back to the integrated GPS.

Addresses review:
- LinkManager only tears down _nmeaPort / resets the position source when
  NMEA is Disabled, not for a selected serial NMEA port (which is set up
  by _addSerialAutoConnectLink() and would otherwise break every tick).
- resetNmeaSourceDevice() switches away while the NMEA source is still
  valid so _setPositionSource() runs its normal cleanup (stop, disconnect,
  reset stale position/accuracy) before the source is deleted.
- Use source->disconnect(this) instead of disconnect(source). The latter
  picks the overload that drops this object's own signals to the source,
  so the source->this connections survived and were duplicated every time
  a source was re-selected, running _positionUpdated once per duplicate.
- NmeaGpsSettings.qml stores the untranslated device value instead of the
  translated combo box label, so the LinkManager string comparisons hold
  in localized builds. Settings written by older builds are migrated by
  matching the displayed text once.
@julianoes
julianoes force-pushed the pr-nmea-fallback-internal-gps branch from 4034403 to 253bb41 Compare July 22, 2026 04:26
@github-actions github-actions Bot added the QML label Jul 22, 2026
@DonLakeFlyer

Copy link
Copy Markdown
Contributor

If you've dealt with the code review then hide it marked as resolved. Then I'll run another code review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants