I can't seem to find an example of parsing a character array.
I have the following code that obtains array from a GPS.
// MANAGES THE CHARACTERS RECEIVED BY GPS
while (serGPS.available()) {
GPS_info_char=serGPS.read();
if (GPS_info_char == '
I now need to check the character "A" or "V" at the position after the second comma ",".
If it is "A" I must read the Time/Date/Lat/Lon.
If it is "V" I must do something else.
This I can do in a String, but not in a character array.
Could someone steer me in the right direction please.
){ // start of message
message_started=true;
received_char=0;
}else if (GPS_info_char == '*'){ // end of message
for (i=0; i<received_char; i++){
Serial.write(GPS_info_buffer[i]); // writes the message once it has been completely received
// GNRMC,064509.000,A,2545.7696,S,02813.1923,E,0.28,149.40,230218,,,A,V
// GPRMC,064602.000,V,,,,,0.00,149.40,230218,,,N,V
}
Serial.println();
message_started=false; // ready for the new message
}
else if (message_started==true){ // the message is already started and I got a new character
if (received_char<=GPS_INFO_BUFFER_SIZE){ // to avoid buffer overflow
GPS_info_buffer[received_char]=GPS_info_char;
received_char++;
}else{ // resets everything (overflow happened)
message_started=false;
received_char=0;
}
}
}
I now need to check the character "A" or "V" at the position after the second comma ",".
If it is "A" I must read the Time/Date/Lat/Lon.
If it is "V" I must do something else.
This I can do in a String, but not in a character array.
Could someone steer me in the right direction please.