Custom objects: more convenient parsing of sentence name (was: Update TinyGPS++.cpp) #71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Mikal,
I am using your "TinyGPS++" library to create a generic NMEA info display for use on a boat. Thank you for your great work, the library works very well!
Nevertheless I 'd ask you for a modification in the handling of custom NMEA sentences. :-)
Background:
In the present version V1.0.2 the parser looks at the complete first term in a NMEA sentence - even though the actual identification of the NMEA sentence is only done in the last three characters of the first term, the first two characters are a manufacturer code.
Example: These two NMEA sentences "VHW" contain the same information, but differ in the first two characters ("II" vs. "VW"), (and the checksum):
$IIVHW,,,307.,M,08.08,N,14.97,K10
$VWVHW,,,307.,M,08.08,N,14.97,K11
To parse the data using TinyGPS++ two separate definitions are needed:
TinyGPSCustom nmeaLogSpeedKmh(gps, "GPVHW", 7); // Log Speed in km/h
TinyGPSCustom nmeaLogSpeedKmh(gps, "IIVHW", 7); // Log Speed in km/h
This makes it almost impossible to write a generic code, that works regardless of the manufacturer ID in the first two characters.
My request: The parser in TinyGPS++ can easily be modified to look only at the relevant sentence identifiers (VHW in the example above) and use this definition:
TinyGPSCustom nmeaLogSpeedKmh(gps, "VHW", 7); // Log Speed in km/h
With that change, the "VHV" data set can be extracted from NMEA sentences by any manufacturer without changing the software.
The only modification required is in line 223 of "tinygps.cpp", replacing "!strstr" for "strcmp", see - code change