I’m trying to complete comprehensive Ublox serial GPS library that is working apart from a slight issue with the NMEA data.
The NMEA format is if there is no valid data, send nothing so you end up with a load of ‘,’
This is an example of one of my data lines from the GPS:
VTG,,T,,M,0.018,N,0.033,K,D
You can see the two ,,
I have nine fields, If I use this,
sscanf(NMEAline[passLine], "VTG,%f,%c,%f,%c,%f,%c,%f,%c,%c"
Clearly things go wrong, sscanf is looking for data between the ,,
Is there a workaround or do I process the data first and ‘add’ a character between the ,,
I did try this as the RAW serial data is being received
if (gpsbuff[bufferIndex-2] == ',' && gpsbuff[bufferIndex-1] == ',') {
gpsbuff[bufferIndex-1] = '0';gpsbuff[bufferIndex] = ',';
bufferIndex++;
}
This does work 90% of the time but on occasions it tends to add a ‘0’ to the next and/or previous field, even if I slow the baud rate down I get the same issue.
Any suggestions would be appreciated.
Paul