Go Down

Topic: Parsing a string. (Read 570 times) previous topic - next topic


Guys, I want to parse data sent through the serial connection:

Here's the example sting:


It spits out other data with a different starting header, and I only want the $GPRMC data to be read, and sent to me. plus, I only want these data points:


Another problem is, is that the data should be expressed like this:

13 24.9294 & 121 35.8584

how do I get about this dilemma?

Thanks guys!



Jul 10, 2013, 11:14 am Last Edit: Jul 10, 2013, 11:20 am by nid69ita Reason: 1
You can try using strtok() function and use ',' as token if it is a real string (array of char null terminated).

my name is IGOR, not AIGOR


You could also look at (or use) the TinyGPS library which already knows how to parse GPS data.
The art of getting good answers lies in asking good questions.


I used a regular expression to parse a similar (or identical) string from my GPS.


I was too lazy to work out dozens of strtok calls, so one regular expression call did it instead.

Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

Go Up