chenzihan0416 opened a new pull request, #17768:
URL: https://github.com/apache/nuttx/pull/17768

   ## Summary
   
   Fix GNSS NMEA parser buffer overflow handling by resetting parse position 
after error.
   
   When the NMEA parser detects a buffer overflow (line exceeds 
`GNSS_PARSE_BUFFERSIZE`), it logs an error message but fails to reset 
`parsenext` to 0. This causes subsequent NMEA sentences to be appended to the 
corrupted buffer, leading to:
   
   1. Continuous buffer overflow errors for all following sentences
   2. Loss of valid GNSS data until the next '$' character is encountered
   3. Potential memory corruption if overflow detection fails
   
   ## Impact
   
   - Improves GNSS data reliability when receiving malformed or oversized NMEA 
sentences
   - Prevents data loss from cascading parse errors
   - No API or behavior changes for normal operation
   
   ## Testing
   
   ```bash
   nsh> echo "$GPGGA,<300_char_garbage...>*00" > /dev/ttyGNSS0
   nsh> echo 
"$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47" > 
/dev/ttyGNSS0
   ```
   before fix:
   ```bash
   ERROR: NMEA buffer overflow, invalid statement:$GPGGA,<truncated>
   ERROR: NMEA buffer overflow, invalid statement:GPGGA,123519,4807...
   ERROR: NMEA buffer overflow, invalid statement:807.038,N,01131...
   (repeating errors, no valid data parsed)
   ```
   after fix:
   ```bash
   ERROR: NMEA buffer overflow, invalid statement:$GPGGA,<truncated>
   INFO: Parsed GPGGA: lat=48.1173, lon=11.5167, alt=545.4
   (valid sentence parsed correctly after recovery)
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to