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.

Selecting Disabled (or otherwise switching off NMEA) in the Comm Links
NMEA GPS section closed the UDP socket but left QGCPositionManager stuck
on the now-dead NMEA source, so the GCS position froze and there was no
way back to the device's own GPS.

Add QGCPositionManager::resetNmeaSourceDevice() which tears down the
NMEA source and, if it was active, reverts to the default/internal
position source (e.g. the integrated Android GPS). Call it from
LinkManager when NMEA is no longer configured, and also tear down a
lingering serial NMEA port in that case.
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 30.63%. Comparing base (f29efd3) to head (6da033d).
⚠️ Report is 125 commits behind head on master.

Files with missing lines Patch % Lines
src/PositionManager/PositionManager.cpp 0.00% 12 Missing ⚠️
src/Comms/LinkManager.cc 0.00% 6 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%   30.63%   +5.16%     
==========================================
  Files         769      785      +16     
  Lines       65912    66796     +884     
  Branches    30495    30946     +451     
==========================================
+ Hits        16788    20466    +3678     
+ Misses      37285    32386    -4899     
- Partials    11839    13944    +2105     
Flag Coverage Δ
unittests 30.63% <0.00%> (+5.16%) ⬆️

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.58% <0.00%> (+5.49%) ⬆️
src/PositionManager/PositionManager.cpp 13.07% <0.00%> (-2.18%) ⬇️

... and 434 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...6da033d. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 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: 25 passed, 0 skipped
linux-coverage-unit: 103 passed, 0 skipped
Total: 128 passed, 0 skipped

Code Coverage

Coverage: 66.3%

No baseline available for comparison

Artifact Sizes

Artifact Size
QGroundControl 221.84 MB
QGroundControl-aarch64 179.43 MB
QGroundControl-installer-AMD64 137.92 MB
QGroundControl-installer-AMD64-ARM64 80.45 MB
QGroundControl-installer-ARM64 109.19 MB
QGroundControl-linux 87.09 MB
QGroundControl-mac 87.09 MB
QGroundControl-windows 86.14 MB
QGroundControl-x86_64 191.64 MB
No baseline available for comparison

Updated: 2026-07-06 03:23:40 UTC • Commit: 6da033d • Triggered by: Android

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

This PR fixes a user-visible failure mode where disabling the NMEA GPS input (e.g. setting Disabled in Comm Links) closes the NMEA UDP socket but leaves QGCPositionManager stuck on the now-dead NMEA source, freezing the displayed GCS position. It adds an explicit teardown path for the NMEA position source and wires LinkManager to invoke it when NMEA is no longer configured.

Changes:

  • Add QGCPositionManager::resetNmeaSourceDevice() to tear down an active QNmeaPositionInfoSource and (when appropriate) fall back to the platform default position source.
  • Update LinkManager::_updateAutoConnectLinks() to reset the position manager when NMEA is switched off and to clean up a lingering serial NMEA port.

Reviewed changes

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

File Description
src/PositionManager/PositionManager.h Declares resetNmeaSourceDevice() API for tearing down the NMEA source.
src/PositionManager/PositionManager.cpp Implements NMEA source teardown and fallback behavior.
src/Comms/LinkManager.cc Calls the new reset method when NMEA is disabled and cleans up NMEA serial resources.

Comment thread src/Comms/LinkManager.cc
Comment on lines 527 to 540
} else {
_nmeaSocket->close();
#ifndef QGC_NO_SERIAL_LINK
// NMEA was switched off (e.g. back to "Disabled"): also tear down any serial NMEA port
if (_nmeaPort) {
_nmeaPort->close();
delete _nmeaPort;
_nmeaPort = nullptr;
_nmeaDeviceName = "";
}
#endif
// Revert QGCPositionManager to the integrated GPS if it was using an NMEA source
QGCPositionManager::instance()->resetNmeaSourceDevice();
}
Comment on lines +104 to +126
void QGCPositionManager::resetNmeaSourceDevice()
{
if (!_nmeaSource) {
return;
}

const bool wasCurrent = (_currentSource == _nmeaSource);

_nmeaSource->stopUpdates();
(void) disconnect(_nmeaSource);
if (wasCurrent) {
// Clear so _setPositionSource() doesn't try to touch the source we're about to delete
_currentSource = nullptr;
}

delete _nmeaSource;
_nmeaSource = nullptr;

if (wasCurrent) {
// Fall back to the platform's default position source (e.g. the integrated Android GPS)
_setPositionSource(QGCPositionManager::InternalGPS);
}
}
@DonLakeFlyer

Copy link
Copy Markdown
Contributor

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

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