-
Notifications
You must be signed in to change notification settings - Fork 75
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
Check sentence starts with dollar ($) sign #7
Conversation
…t the beginning of the input string
@bezineb5 I've been looking at it a bit deeper and I rethinking about it. Here's my opinion: This lib is a parser that takes an input text, parses it, and gives you back a NMEA Sentence object if the text is a valid sentence. In case the input text is not a valid sentence, the lib returns an error. Just like any JSON or YAML parses out there when you feed them with incorrectly formatted text. IMO the lib should not attempt to fix any input text as it can lead to thinking that the input text was correctly formatted. Fixing the input text should be a pre-processing that belongs to the app importing and using this lib. I've been looking at a couple of NMEA parsers and they seem to work like this. Let me know what you think. |
I agree. It makes the behavior less predictable if the lib tries to fix things. And this kind of case should only happen if there is another issue, such as a connection problem. I'll update the PR to enforce $ at the beginning, and make sure that it fails correctly with improper inputs. |
Sounds good. Instead of just checking that the sentence contains |
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.
@bezineb5 the changes look good. I'm going to update the PR title and merge it. Thanks!
Thanks to you! |
Actually, my issue is that I have some malformed NMEA sentences due to serial communication issues, which led to a crash in the library. My intention here is simply to avoid the crash, not necessarily to recover from it.
However, reading a bit about NMEA, it seems that $ is a "start delimiter", so I agree with your solution to start reading from the last $.
I'm checking the * after splitting.
I also added some tests.