Conversation
Multi band receivers such as the ZED-F9P report two to three signals per satellite, so numSigs regularly exceeds UBLOX_MAX_SIGNALS and the payload grows past MAX_UBLOX_PAYLOAD_SIZE. The parser discarded the whole frame, counted an error and then rescanned the payload for the next sync pattern, so the error counter kept climbing while the satellite list stayed empty, because UBX-NAV-SAT is not enabled on M9 and later. UBX-NAV-SIG and UBX-NAV-SAT payloads that do not fit are now read to the end and checksummed, only the signals beyond UBLOX_MAX_SIGNALS are dropped. The parser stays byte aligned and does not have to resync. Fixes iNavFlight#10941
|
ⓘ 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 QodoPreserve oversized UBX-NAV-SIG and NAV-SAT frames
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
Problem
With a u-blox ZED-F9P on INAV 8.0.0 the Configurator GPS tab shows the
Errorscounter climbing (342 of 654 messages in the reporter's screenshot) whileSatsshows 32, and the CLI shows no satellite information (gpssatsis empty). Disabling UBX-NAV-SIG on the receiver makes the errors disappear. Reported in #10941. Fixes #10941.Cause
src/main/io/gps_ublox.c:900-904on maintenance-10.x: any frame whose declared payload length exceedsMAX_UBLOX_PAYLOAD_SIZEis dropped,gpsStats.errorsis incremented and the parser resyncs.MAX_UBLOX_PAYLOAD_SIZEisUBLOX_MAX_SIGNALS * 16 + 8= 1032 bytes (src/main/io/gps_ublox.h:35-37), so the buffer holds 64 NAV-SIG signals. A multi-band receiver reports two or three signals per satellite, so NAV-SIG regularly carries more than 64 signals and every frame is discarded. On receivers with protocol version above 23.01 INAV enables NAV-SIG and disables NAV-SAT (gps_ublox.c:1069-1077), sosatelites[]is never filled andgpssatsstays empty.Change
Oversized UBX-NAV-SIG and UBX-NAV-SAT frames up to
UBLOX_MAX_ACCEPTED_PAYLOAD_SIZE(255 * 16 + 8 bytes, the most a U1 count can declare) are now received to the end and checksummed; only the firstMAX_UBLOX_PAYLOAD_SIZEbytes are stored, so signals beyondUBLOX_MAX_SIGNALSare dropped and the parser stays byte aligned. After the eight-byte header the declared length is compared with8 + count * record size; a mismatch is counted as an error and resyncs, and every other oversized message keeps the old drop-and-resync path._payload_lengthis clamped toMAX_UBLOX_PAYLOAD_SIZEbefore the frame handlers run and the NAV-SIG handler uses the clamped count for both of its loops. TwoSTATIC_ASSERTs pinUBLOX_MAX_ACCEPTED_PAYLOAD_SIZE >= MAX_UBLOX_PAYLOAD_SIZEandsizeof(ubx_nav_sig) <= UBLOX_BUFFER_SIZE.Test
Not run on hardware or SITL. Cause verified by reading
src/main/io/gps_ublox.c:900-904and the message setup atgps_ublox.c:1069-1077on maintenance-10.x; The Qodo finding on the first commit (a short frame with an oversized declared length would swallow the following frames) is addressed by the header length check in ad33673. The existingnavSigStructureSizesunit test (src/test/unit/gps_ublox_unittest.cc:92) only checks struct sizes and is unchanged.Flash / RAM
Not measured yet. The upstream firmware CI has not been released for this PR, so no size report exists.
Docs
No documentation change needed: no setting, CLI command or documented limit changes, and
UBLOX_MAX_SIGNALSis a build-time define that is not mentioned under docs/.