[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
The Core of An NMEA Interpreter

The Core of An NMEA Interpreter

The first step in making an NMEA interpreter is writing a method which does two things: separating each sentence into its individual words and examining the first word to figure out what information is available to extract. Listing 1-1 shows the start of the interpreter class. (Listing 1-1: The core of an NMEA interpreter is a function which divides NMEA sentences into individual words.)

'*******************************************************
'**  A basic NMEA interpreter
'*******************************************************
Public Class NmeaInterpreter
  ' Processes information from the GPS receiver
  Public Function Parse(ByVal sentence As String) As Boolean
    ' Divide the sentence into words
    Dim Words() As String = GetWords(sentence)
    ' Look at the first word to decide where to go next
    Select Case Words(0)
      Case "$GPRMC"      ' A "Recommended Minimum" sentence was found!
        ' Indicate that the sentence was recognized
        Return True
      Case Else
        ' Indicate that the sentence was not recognized
        Return False
    End Select
  End Function
  ' Divides a sentence into individual words
  Public Function GetWords(ByVal sentence As String) As String()
    Return sentence.Split(","c)
  End Function
End Class


Written By Jon Person (http://www.gpsdotnet.com)


last edited (December 21, 2004) by jperson, Number of views: 3183, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.