Fix GPS capability poll blocking for 500ms every 5 seconds#11332
Open
sensei-hacker wants to merge 2 commits intoiNavFlight:maintenance-9.xfrom
Open
Fix GPS capability poll blocking for 500ms every 5 seconds#11332sensei-hacker wants to merge 2 commits intoiNavFlight:maintenance-9.xfrom
sensei-hacker wants to merge 2 commits intoiNavFlight:maintenance-9.xfrom
Conversation
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.
Contributor
ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
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.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where
gpsProcessNewSolutionDatawas 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 (everyGPS_CAPA_INTERVAL= 5s) waited on_ack_statefor ACK/NAK: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
ptWaitTimeoutalways hit the full 500ms (GPS_CFG_CMD_TIMEOUT_MS) timeout. During this window the protothread was blocked and could not loop back to callgpsProcessNewSolutionData.At 10 Hz GPS, this means ~5 position fixes go unprocessed every 5 seconds.
Fix
Remove the
ptWaitTimeoutcalls 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. TheGPS_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 blockingptWaitTimeoutcalls from periodic MON-VER and MON-GNSS polls ingpsProtocolStateThreadmain loop