Parsing GPS Data - Partially Working

Trying to work through this, but I’m too “green” to understand what I’m seeing. After messing around, this is better.

Notice how split() is parsing with ‘,’ and the data header $GPVTG is shifted.

[0] “$GPRMC”
[1] “140752.00”
[2] “A”
[3] “4355.94889”
[4] “N”
[5] “07859.68009”
[6] “W”
[7] “0.201”
[8] “”
[9] “060320”
[10] “”
[11] “”
[12] "A64 // << has line ending, not comma separated. How to parse this?
$GPVTG"
[13] “”
[14] “T”
[15] “”
[16] “M”
[17] “0.201”
[18] “N”
[19] “0.373”
[20] “K”
[21] "A
27

New Code:

void draw(){

background(0);

while(gpsPort.available() > 0){
// inStringGPS = gpsPort.readStringUntil(13); //‘D’, 10, 9
inStringGPS = gpsPort.readString();
}

gpsData = split(inStringGPS, ‘,’);
String blockRMC = gpsData[0];

if (str3.equals(blockRMC) == true){
float gpsData2 = float(split(inStringGPS, ‘,’));
gpsHeading = int(gpsData2[8]);
}
text(gpsHeading, 40, 40);

// print(inStringGPS); // for troubleshooting
printArray(gpsData);
}

Note: removed serialEvent() and used while(gpsPort.available() > 0) in the draw() function.

I know this is not correct, but I’m starting to understand the issue. I just don’t know how
to break up the comma separated and line ending in the buffer.

:confused:

1 Like