Repository navigation
Conversation
gpsParseFrameUBLOX() only looked for PROTVER after the hardware string was recognised. Receivers newer than M10 stayed at Proto 0.00 and were configured over legacy CFG messages they do not answer, so auto-config never completed. Parse the protocol version from every extension field, read the two-digit major/minor as integers instead of through fastA2F(), drop MON-VER payloads shorter than the header, and let a known protocol version finish detection. Adds gps_ublox_protocol_unittest.
The ZED-X20P reports hwVersion 000B0000 in MON-VER. Without a table entry it stays UBX_HW_VERSION_UNKNOWN and gpsConfigure() skips the constellation setup, so gps_ublox_use_galileo/beidou/glonass never reach the receiver. Add UBX_HW_VERSION_UBLOX20 (0x54) in the u-blox series, so the existing ">= UBX_HW_VERSION_UBLOX10" checks cover it: GNSS setup over CFG-VALSET, MON-GNSS poll at start-up and MON-RF polling. The F9P is not added. It reports 00190000, the same ID as the M9, and is already handled as UBLOX9. The test uses a MON-VER captured from a ZED-X20P running HPG 2.10.
The X20 answers MON-GNSS with message version 1, which the parser ignores, so the start-up capability poll waits its full 3 x 500 ms. Nothing refreshes the GPS timeout in that loop and gps.c restarts the driver after 1000 ms. Since aa0d822 made the X20 known hardware, it entered that loop and never finished configuration. Refresh the timeout on each poll; the receiver already answered MON-VER. The test now answers MON-GNSS with a capture from a ZED-X20P and checks the longest gap without a timeout refresh.
The F9P reports the M9 hardware ID, answers MON-GNSS version 0 and still accepts legacy CFG messages. The test uses replies captured from a ZED-F9P running HPG 1.51 and checks that it keeps the M9 path: constellations over CFG-GNSS, the rest over CFG-VALSET, and no GPS timeout during start-up.
…le-driven The hardware and protocol version decoders become pure functions in gps_ublox_utils.c, so gps_ublox_unittest.cc tests them directly with tables of known IDs, valid formats, the old float truncation cases and malformed fields. The protocol harness that drove the whole driver through a fake serial port, its CMake target and the target.h change are dropped. No behaviour change.
A receiver whose hardware ID is not in the table but that reports PROTVER 15.00 or newer (the first M8 protocol with CFG-GNSS and MON-GNSS) now gets the GNSS capability poll, the constellation detection from the MON-VER extensions and the constellation setup. Such a receiver uses the M10 signal keys from protocol 34.00 on: below that, the documented firmware (M9, F9P, F9R) lacks BDS_B1C, and M9 and F9P still accept CFG-GNSS. Known hardware keeps its current path. The decisions become pure functions in gps_ublox_utils.c with table tests. ubloxEffectiveNavHz() returns the rate configureRATE is asked for, including the 20/40 Hz limit that configureRATE used to apply on its own, so the satellite info divider in iNavFlight#12001 can use the same value.
gps.c counts its timeout from the last gpsSetProtocolTimeout() call, not from received frames, so the MON-VER retries only got two of their three polls when an answer was lost. The timeout is now refreshed on each poll, as the MON-GNSS loop already does. If none of the three polls brings a hardware or protocol version, the driver restarts as on a communication loss instead of setting the receiver up on the legacy path. The capability bits were cleared after MON-VER had set GAL/BDS/GLO from its extensions. M8 to M10 set them again from MON-GNSS, but the X20 answers MON-GNSS version 1, so gpsinfo showed no constellations for it. They are now cleared before MON-VER; on M8 to M10 a lost MON-GNSS answer now leaves the MON-VER bits in place instead of none. Document 0x54 (X20, hwVersion 000B0000) in gps_ublox.h, and drop the typeconversion.h include that is unused since fastA2F went.
The ZED-F9P reports the M9's hardware ID. It is now told apart by the MOD= extension of MON-VER (fallback: the "EXT CORE 1." base version) and reported as 0x89, series 0b10. The capability checks compare the generation, so the F9 keeps every M9 decision except the constellation setup. F9 and X20 get their constellations through the CFG-SIGNAL enable keys only and keep the receiver's signal defaults. The F9 rejects the single-band masks INAV sent, which reset the constellation settings to their defaults, and the X20's default signal plan has no BeiDou B1I. A MON-GNSS reply in a version INAV does not parse (X20: version 1) ends the startup poll and stops the periodic poll.
|
RAM / Flash usage vs. base commit
See RAM/flash optimization guide for techniques to reduce usage. |
|
Test firmware build ready — commit Download firmware for PR #12083 251 targets built. Find your board's
|
|
Hardware test done with both receivers. Setup: IFLIGHT_BLITZ_ATF435, receiver on a UART at 115200 baud, ZED-F9P
No driver restarts in any run. This is the pattern of #10236, and it is gone with the PR. ZED-X20P
Over USB the X20 acknowledged all 64 transitions between the 8 combinations with the enable keys, each within 63 ms. ConfiguratoriNavFlight/inav-configurator#2813 (CI build of 6675bb4) against this firmware: Auto-detect reports "u-blox ZED-F9P" and "u-blox ZED-X20P" and selects the matching preset. Limitation: the X20 needs #12001 at 115200 baudWith NAV-SIG at the navigation rate the X20's UART is overbooked once reception is good (12 to 14 satellites): 98 to 102 % load, 45 kB backlog in the receiver, data about 4 s old while INAV shows Not tested
|
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoRecognize ZED-F9P and ZED-X20P and configure their constellations safely
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Code Review by Qodo
1. GPS never works if version detection fails
|
| // Without a version the receiver would be set up on the legacy path, so restart like a communication loss | ||
| if (gpsState.hwVersion == UBX_HW_VERSION_UNKNOWN && gpsState.swVersionMajor == 0) { | ||
| ptStop(0); | ||
| } |
There was a problem hiding this comment.
1. Gps never works if version detection fails 🐞 Bug ☼ Reliability
After three MON-VER polls with no recognised hardware ID and no PROTVER, gpsProtocolStateThread now calls ptStop(0). Before, it went on to gpsConfigure on the legacy path. Once stopped, the thread no longer runs gpsProcessNewSolutionData (the only caller that refreshes lastMessageMs), so gpsThread times out and restarts the protocol. This repeats every cycle: a receiver that sends navigation data but doesn't answer MON-VER, or answers with an unknown ID and no PROTVER extension, never gets a fix. Before this change, such a receiver was configured with the legacy messages and worked.
Agent Prompt
## Issue description
When no hardware or protocol version is detected after the MON-VER retries, `gpsProtocolStateThread` calls `ptStop(0)`. GPS then restarts over and over, and a receiver that never answers MON-VER (or has an unknown ID and no PROTVER) is never usable. The previous behaviour configured it on the legacy path.
## Fix Focus Areas
- src/main/io/gps_ublox.c[1239-1242]
## Recommended Fix
Don't stop on the first failed detection. Either keep the old fallback (continue to `ptSpawn(gpsConfigure)`; the periodic MON-VER poll in the main loop already retries detection), or restart only a limited number of times (e.g. track a counter across restarts) and then fall back to the legacy configuration instead of stopping forever.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Builds on #12021 (X20 detection via PROTVER). Until that is merged this branch carries its commits; the change here is the last commit, 2c92c0f.
Background
00190000and is configured like an M9.configureGNSS()enables Galileo with E1 only and GLONASS with L1 only (sigCfgMask = 0x01). The F9P accepts GPS, Galileo, GLONASS and QZSS only with both bands on or both off and answers anything else with ACK-NAK (ZED-F9P Integration Manual §3.1.4.3, Table 3). INAV then resetsgps_ublox_use_galileo/beidou/glonassto their defaults while the receiver keeps its factory setup. u-blox F9 series GNSS support #10236 shows it: Galileo and GLONASS switched themselves off, BeiDou stayed on.configureGNSS10()enables whenever GLONASS is off.Changes
ubloxRefineHardwareVersion(): hardware00190000with a MON-VER extensionMOD=...F9...becomesUBX_HW_VERSION_UBLOX_F9= 0x89 (series 0b10, as reserved in the header). WithoutMOD=the swVersion decides: the F9 reportsEXT CORE 1., the M9EXT CORE 4..MSP_GPSSTATISTICSreports 0x89, CLIstatusshowsUBLOXF9.SBAS_ENA,GAL_ENA,BDS_ENA,QZSS_ENA,GLO_ENA. The per-signal keys stay at the receiver defaults, so the band rules cannot be broken. A constellation the receiver does not list in MON-VER/MON-GNSS is not sent (X20 HPG 2.00/2.02 have no GLONASS). ArduPilot's CFGv2 sends only these keys as well. M8, M9, M10 and unknown receivers keep their paths.gps_ublox_nav_hzdescription: F9P and X20P rate limits (data sheets).No new settings, no PG version change.
Behaviour change: with the default
gps_ublox_use_glonass = OFFan F9P now runs GPS, Galileo and BeiDou instead of its factory four constellations.Testing
gps_ublox_unittest, table-driven: hardware refinement (real F9P/M9/X20 MON-VER strings; M8, M10, X20 and unknown hardware with F9 strings stay unchanged), capability matrix including F9 and X20, enable-key lists per constellation and supported mask.gps_null_port_unittest,gps_heartbeat_unittestand the fullchecktarget (601 tests) pass.Flash / RAM
Against maintenance-10.x + #12021, built locally. The size bot compares against 7e82f68, the merge base with maintenance-11.x, so its table includes the maintenance-10.x changes since then; compared with its report on #12021 the difference is +264 B on MATEKF405 and +424 B on MATEKF722.
Open
hwVersionvalues indocs/development/msp/are not updated yet: the doc rule needs amsp_messages.jsonversion bump, which depends on the final target branch.Configurator presets for both receivers: iNavFlight/inav-configurator#2813.