-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update NMEA parser to handle bad chars #1014
Conversation
- it turns out that it is common for the first set of data returned by a gps module to include incorrectly framed characters that break the unicode conversion. - This change ignores exceptions thrown by the unicode decoder and keeps on going until it can read a correctly framed line.
- prior to this change it just kept going, but it should not try to parse a linve with a back checksum.
donkeycar/parts/gps.py
Outdated
if (message == "GPRMC") or (message == "GNRMC"): | ||
|
||
if (message == "GPRMC") or (message == "GNRMC"): | ||
if True or debug: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is always True - why do we need the if
. Also we are printing, not logging into the shell, is this intended. I would expect to just have:
logger.debug(line)
so if we set global logging to Debug, it will log, otherwise is won't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted it; it was left over from finding the problem.
@@ -57,6 +57,9 @@ def _readline(self) -> str: | |||
return self.gps.readline().decode() | |||
except serial.serialutil.SerialException: | |||
pass | |||
except UnicodeDecodeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the real fix, this looks good.
@Ezward - can you please also update the version in |
@Ezward - can you please pull from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
data returned by a gps module to include incorrectly
framed characters that break the unicode conversion.
unicode decoder and keeps on going until it
can read a correctly framed line.