Receiving GPS data is a job just like receiving any other serial communication. But the data received will also have to be parsed so it can be used for control and display purposes. The procedure for receiving the GPS data is:

  1. Start the relevant Serial connection, e.g. Serial1.begin(9600) also called SerialGPS in the RFzero and is alredy initialized via the RFzero.Init() function
  2. Collect the incoming GPS data, e.g. in an ISR function (see below)
  3. Parse the GPS data (see below)

GPS receiver ISR handler

Receiving the GPS data in the RFzero is taken care of by an Interrupt Serial Routine (ISR) that is triggered every time a character is received.

GPS data parser

Parsing, or splitting, the GPS data string into the relevant pieces can be done in many ways. Below is one example of splitting the NMEA $GPGGA frame to pieces that are used in the RFzero. But the same principle can be applied to any kind of data in a string separated by a delimiter, in his case a comma (,). The pieces of data parsed by ParseNMEAFrame(char *gpsNMEA) are written to global variables but they could also be returned by the function if relevant. The return value from the parser is either an integer combining the UTC minutes and seconds (100 x minutes + seconds) or -1 if the GPS data was invalid.

Parsing the string by a delimiter is a safer way for strings where each chunk may vary in length from time to time.

If you need to parse another NMEA frame, e.g. $GPRMC, all you have to do is either modify the existing parser or add it to the parser through another if (0 == strncmp(“$GPRMC,”, gpsNMEA, 7))  check.