You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "chenzihan0416 (via GitHub)" <gi...@apache.org> on 2026/01/05 11:50:59 UTC

[PR] drivers/sensors: update upper->parsebuffer every new line [nuttx]

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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] drivers/sensors: update upper->parsebuffer every new line [nuttx]

Posted by "chenzihan0416 (via GitHub)" <gi...@apache.org>.
chenzihan0416 closed pull request #17768: drivers/sensors: update upper->parsebuffer every new line
URL: https://github.com/apache/nuttx/pull/17768


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] drivers/sensors: update upper->parsebuffer every new line [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #17768:
URL: https://github.com/apache/nuttx/pull/17768#issuecomment-3710139953

   @chenzihan0416 why did you close it? Since like a good fix


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] drivers/sensors: update upper->parsebuffer every new line [nuttx]

Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on code in PR #17768:
URL: https://github.com/apache/nuttx/pull/17768#discussion_r2662336775


##########
drivers/sensors/gnss_uorb.c:
##########
@@ -595,6 +595,7 @@ static void gnss_parse(FAR struct gnss_upperhalf_s *upper,
     {
       if (*buffer == '$')
         {
+          upper->parsenext = 0;

Review Comment:
   Good fix! Isn't this the only required line for this bug fix? I think the sensor monitor stuff is accidentally mixed in.



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org