Skip to content

fix(Comms): check link connection state in _isSerialPortConnected - #15033

Open
ginolee218 wants to merge 1 commit into
mavlink:masterfrom
ginolee218:fix/android-serial-is-connected
Open

fix(Comms): check link connection state in _isSerialPortConnected#15033
ginolee218 wants to merge 1 commit into
mavlink:masterfrom
ginolee218:fix/android-serial-is-connected

Conversation

@ginolee218

@ginolee218 ginolee218 commented Sep 3, 2026

Copy link
Copy Markdown

Description

On Android, LinkManager::_isSerialPortConnected() returned true as long as any
SerialLink instance was found in _rgLinks, without checking whether the link was
actually connected.

In `LinkManager::_addSerialAutoConnectLink()` on Android:
```cpp
if (AndroidSerial::usePosixSerial() || !_isSerialPortConnected()) {
    portList = QGCSerialPortInfo::availablePorts();
}

When a connected USB serial port disconnected, rebooted, or lost connection, the
disconnected SerialLink instance remained in _rgLinks. As a result,
_isSerialPortConnected() incorrectly continued to return true, blocking
QGCSerialPortInfo::availablePorts() from running. This caused auto-reconnect on Android
to stall after disconnection until the app was restarted.

This PR adds if (link->isConnected()) inside _isSerialPortConnected(), ensuring it only
reports true when a serial link is actively connected, allowing port scanning and auto-
reconnection to resume after a disconnect.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/Build changes
  • Other

Testing

  • Tested locally
  • Added/updated unit tests
  • Tested with simulator (SITL)
  • Tested with hardware

Platforms Tested

  • Linux
  • Windows
  • macOS
  • Android
  • iOS

Flight Stacks Tested

  • PX4
  • ArduPilot

Screenshots

Checklist

  • I have read the Contribution Guidelines
  • I have read the Code of Conduct
  • My code follows the project's coding standards
  • I have added tests that prove my fix/feature works
  • New and existing unit tests pass locally

Related Issues


By submitting this pull request, I confirm that my contribution is made under the terms of the project's dual license (Apache 2.0 and GPL v3).

On Android, _isSerialPortConnected() returned true as long as a
SerialLink instance existed in _rgLinks, even when disconnected.
This prevented availablePorts() from probing new or reconnected
serial devices after a disconnect or reboot. Check link->isConnected()
so it only reports true when actively connected.
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for your first pull request! 🎉

A maintainer will review this soon. Please ensure:

  • CI checks pass
  • Code follows coding standards
  • Changes tested on relevant platforms

We appreciate your contribution to QGroundControl!

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.49%. Comparing base (f29efd3) to head (c6460f3).
⚠️ Report is 354 commits behind head on master.

Files with missing lines Patch % Lines
src/Comms/LinkManager.cc 0.00% 2 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   #15033      +/-   ##
==========================================
+ Coverage   25.47%   34.49%   +9.02%     
==========================================
  Files         769      945     +176     
  Lines       65912    85627   +19715     
  Branches    30495    39467    +8972     
==========================================
+ Hits        16788    29537   +12749     
+ Misses      37285    36459     -826     
- Partials    11839    19631    +7792     
Flag Coverage Δ
unittests 34.49% <0.00%> (+9.02%) ⬆️

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

Files with missing lines Coverage Δ
src/Comms/LinkManager.cc 15.60% <0.00%> (+5.52%) ⬆️

... and 662 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 a8150b0...c6460f3. 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 Sep 3, 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: 2 passed, 76 failed, 7 skipped.

Test Results

linux-coverage-integration: 52 passed, 0 skipped
linux-coverage-unit: 185 passed, 0 skipped
linux-sanitizers-integration: 31 passed, 0 skipped
linux-sanitizers-unit: 185 passed, 0 skipped
Total: 453 passed, 0 skipped

Code Coverage

Coverage: 70.6%

No baseline available for comparison

Artifact Sizes

Artifact Size
QGroundControl 253.10 MB
QGroundControl-aarch64 177.31 MB
QGroundControl-installer-AMD64 128.43 MB
QGroundControl-installer-AMD64-ARM64 70.81 MB
QGroundControl-installer-ARM64 99.56 MB
QGroundControl-linux 84.76 MB
QGroundControl-mac 84.76 MB
QGroundControl-x86_64 189.56 MB
No baseline available for comparison

Updated: 2026-09-03 10:17:38 UTC • Commit: c6460f3 • Triggered by: Linux

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.

2 participants