mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2026-11-24 16:17:22 +00:00
The preamble search of the CNAV message decoder (libswiftcnav) started at position 1 of the decoded bits buffer and stopped one window short of its end, and when it found nothing it kept the last 7 bits, which became positions 0 to 6 of the next search. The Viterbi decoder delivers 32 bits at a time, so every search saw 39 bits and tested the windows starting at 1 to 30. A preamble starting at position 31 was complete in the buffer but not tested, and lost its first bit in the shift; one starting at position 32 landed at position 0 of the next search, which was skipped. For 2 of the 32 positions of the preamble with respect to the 32-bit blocks, the first message after the start of tracking was lost although all its symbols were received. With a short capture this can leave a GPS L2C or L5 satellite without the MT10, MT11 and clock messages needed for an ephemeris set. Skipping position 0 is right only when the search follows a CRC failure, where the buffer starts with the preamble pattern that has just been rejected. Test every complete 8-bit window, from position 0 to n_decoded - 8, and skip position 0 only in that rescan (new skip_first flag of cnav_v27_part_t, set where the CRC failure is handled and cleared by the search). The new unit tests encode two consecutive CNAV messages (CRC-24Q, rate 1/2 K=7 convolutional code) and feed them to the decoder with the first preamble at each of the 32 positions, for both symbol-pair phases and both polarities, and with a preamble pattern that fails the CRC check at each distance from 8 to 371 bits ahead of the first message. Signed-off-by: Ben Gant <indigma04@gmail.com>