dotMorten / NmeaParser

Library for handling NMEA message in Windows Desktop, Store, Phone, Universal, and Xamarin (Android + iOS), coming from files, bluetooth, serial port or any stream
https://dotmorten.github.io/NmeaParser/
Apache License 2.0
262 stars 89 forks source link

Invalid argument: Null value parsing bad GGA #94

Closed ramtechjoe closed 3 years ago

ramtechjoe commented 3 years ago

I am getting a null value exception parsing sentences when there is missing data. I know the sentence is invalid, but it would be helpful if the exception was being handled cleaner.

The sentence: $GPGGA,181651.98,LAT,DIR,LON,DIR,0,,,,M,,M,,*43

Looking at the code in the GGA constructor I believe the culprit is: NumberOfSatellites = int.Parse(message[6], CultureInfo.InvariantCulture);

The sentence for the number of satellites is an empty string, so int.Parse is throwing the exception. As I mentioned I know the issue is a bad sentence being received, but handling a little cleaner would be helpful

Just a note: As I have told you before, love this library. It has saved countless hours having a simple to implement NMEA parser

dotMorten commented 3 years ago

Fixed: Empty string will be interpreted as '0'