资 源 简 介
An incomplete, but usable and easily extensible NMEA GPS output message parser in C#. At the moment it parses most of: GGA, RMC, GLL, GSA, GSV. I use no generics here, so you can use it also with older .NET versions before 2.0.
Setup parsing
Create a parser instance, connect to NewMessage event, set up the source System.IO.Stream and start the parser. The parser has its own thread to read bytes from the source Stream.
gps.parser.Nmea parser = new gps.parser.Nmea();parser.NewMessage += new gps.parser.Nmea.NewMessageEventHandler(HandleNewMessage);parser.Source = System.IO.File.OpenRead(file); // you may want to bufferparser.Start();
Process the events
You are notified for each full parsed message, and can access data from it as shown:
private void HandleNewMessage(gps.parser.NmeaMsg msg){ gps.parser.Field f = null; switch(msg.id) { case gps.parser.NmeaMessage.MsgType.GGA: ... f = (gp