Trouble parsing NMEA data from Serial Port.

Posted by rross on Stack Overflow See other posts from Stack Overflow or by rross
Published on 2010-04-18T18:47:34Z Indexed on 2010/04/18 18:53 UTC
Read the original article Hit count: 463

Filed under:
|
|
|
|

I'm retrieving NMEA sentences from a serial GPS. Then string are coming across like I would expect. The problem is that when parsing a sentence like this:

$GPRMC,040302.663,A,3939.7,N,10506.6,W,0.27,358.86,200804,,*1A

I use a simple bit of code to make sure I have the right sentect:

        string[] Words = sBuffer.Split(',');
        foreach (string item in Words)
        {
            if (item == "$GPRMC")
            {
                return "Correct Sentence";
            }
            else
            {
                return "Incorrect Sentence
            }
        }

I added the return in that location for the example. I have printed the split results to a text box and have seen that $GPRMC is indeed coming across in the item variable at some point. If the string is coming across why won't the if statement catch? Is is the $? How can I trouble shoot this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about nmea