Skip to content

Fix GPS capability poll blocking for 500ms every 5 seconds#11332

Open
sensei-hacker wants to merge 2 commits intoiNavFlight:maintenance-9.xfrom
sensei-hacker:fix/gps-capa-poll-stall
Open

Fix GPS capability poll blocking for 500ms every 5 seconds#11332
sensei-hacker wants to merge 2 commits intoiNavFlight:maintenance-9.xfrom
sensei-hacker:fix/gps-capa-poll-stall

Conversation

@sensei-hacker
Copy link
Member

@sensei-hacker sensei-hacker commented Feb 13, 2026

Summary

Fixes a bug where gpsProcessNewSolutionData was not called for 500ms every 5 seconds due to unnecessary blocking in the u-blox capability polling loop.

Problem

In gpsProtocolStateThread, the periodic MON-VER and MON-GNSS polls (every GPS_CAPA_INTERVAL = 5s) waited on _ack_state for ACK/NAK:

pollGnssCapabilities();
ptWaitTimeout((_ack_state == UBX_ACK_GOT_ACK || _ack_state == UBX_ACK_GOT_NAK), GPS_CFG_CMD_TIMEOUT_MS);

In the u-blox protocol, MON-class messages respond with data, not ACK/NAK (only CFG-class messages produce ACK/NAK). So the condition was never satisfied and ptWaitTimeout always hit the full 500ms (GPS_CFG_CMD_TIMEOUT_MS) timeout. During this window the protothread was blocked and could not loop back to call gpsProcessNewSolutionData.

At 10 Hz GPS, this means ~5 position fixes go unprocessed every 5 seconds.

Fix

Remove the ptWaitTimeout calls entirely. The receiver thread parses MON-VER/MON-GNSS responses asynchronously regardless of whether the state thread waits, and nothing between the polls and the next loop iteration depends on the updated data. The GPS_CAPA_INTERVAL (5s) guard already prevents re-polling too frequently.

This matches ArduPilot's approach to capability polling — fire-and-forget, with responses handled asynchronously as they arrive.

Testing

Changes

  • src/main/io/gps_ublox.c — Remove blocking ptWaitTimeout calls from periodic MON-VER and MON-GNSS polls in gpsProtocolStateThread main loop

The periodic MON-VER and MON-GNSS polls in the main GPS loop waited on
_ack_state for ACK/NAK. MON-class messages never produce ACK/NAK (only
CFG-class messages do), so ptWaitTimeout always hit the full 500ms
timeout. This blocked gpsProcessNewSolutionData from being called,
causing a data processing stall every GPS_CAPA_INTERVAL (5s).

Wait on actual response data instead, matching the pattern already used
in the initialization code: hwVersion change for MON-VER, and
lastCapaUpdMs timestamp for MON-GNSS.
@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Feb 13, 2026

ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

@sensei-hacker sensei-hacker added Bugfix Testing Required Release Notes Add this when a PR needs to be mentioned in the release notes labels Feb 13, 2026
The receiver thread parses MON-VER/MON-GNSS responses asynchronously.
Nothing between the polls and the next loop iteration depends on the
updated data, so the waits just block position fix processing for no
benefit. The 5-second GPS_CAPA_INTERVAL already prevents re-polling
too frequently.
@breadoven
Copy link
Collaborator

A quick test shows this fixes the problem. Updates occur at the 10 Hz rate for the GPS used with no noticeable delay, Hopefully the glitch should be gone especially for multirotors which suffered from a regular 5s nodding twitch at speed.

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

Labels

Bugfix Release Notes Add this when a PR needs to be mentioned in the release notes Review effort 2/5 Testing Required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants