Nmeasharp - C# parser for nmea gps out messages

  •        1755

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 parsingCreate 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 eventsYou 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 = (gps.parser.Field)msg.Fields[gps.parser.GGA.FieldIds.X]; if((f != null) && f.HasValue) { double longitude = f.GetDouble(position.x); ... } ... break; case gps.parser.NmeaMessage.MsgType.Done: ... // done break; }}Look at Field class for more details, on how to discover data type of variables at run-time (if ever needed). For the very lazyI provide an easy to use MinimalNmeaPositionNotifier wrapper around the raw parser events. The wrapper reports only the most useful GPS position data once per new position (GGA and RMC only): gps.parser.Nmea parser = new gps.parser.Nmea();gps.parser.MinimalNmeaPositionNotifier minimal = new gps.parser.MinimalNmeaPositionNotifier();minimal.Init(parser);minimal.NewGspPosition += new gps.parser.MinimalNmeaPositionNotifier.NewGspPositionEventHandler(NewGspPosition);parser.Source = System.IO.File.OpenRead(file); // you may wanto to bufferparser.Start(); //asyncThe new gps position event is fired on every new position and looks like: private void NewGspPosition(gps.parser.GpsPosition pos){ // access: pos.x, pos.y, pos.speed, pos.course, pos.hdop, etc. // all data are in metric system ...}You can write your own other wrappers or extend the provided one. More informationThe source of the parser is a System.IO.Stream. The parser uses only CanRead and ReadByte methods of the stream, so you can easily inherit from System.IO.Stream and wrap as stream any data source, such as a serial port (infinite stream), or even delay file input to simulate various baud rates. Extending the parser to process a new NMEA output message type is very easy. Look at GGA, GGL, etc classes for more details. You need to create a class like the one shown next, and register it as parser.MessageHandler.Add(new GGL()); (like this you can even replace existing message parsers): public class GLL : NmeaMsg{public class FieldIds{ public static readonly int X = 2; // longitude...}//EOCpublic GLL(){ id = NmeaMsg.MsgType.GLL; Field f = null; f = new Field(Field.ValueType.GEODEGREES); f.index = new int[] { 3, 4 }; // field indexes in message fields.Add(FieldIds.X, f); ...}public override bool CanHandle(string[] nmea){ return nmea[0].Trim().Equals("$GPGLL");}public override NmeaMsg CreateEmpty(){ return new GLL();}}//EOCHave a look at gps2coords.cs for a complete command-line example, that parses an input NMEA text file and outputs another file made of floating coordinates. There are no bugs as far as I know, but feel free to find any and fix them, or extend the parser. Do not expect much support thought.




Related Projects


raspBerry+ is a web-based administration platform for Blackberry Enterprise Server for MS Exchange (BES). You can group-based activate/kill/delete/add and get status of users, their handhelds and services. With a little download-area and a comment-system


RASP's A Sneakernet Proxy; download using a thumbdrive.


RasmusDSP is an embeddable Audio/MIDI processor. It contains various filters and generators (including SoundFont 2.0 compatible synthesizer). Has a script interpreter which is used to describe instruments, route Audio/MIDI signal between processor units.


An acronym for cRoss-plAtform accesS control for Enterprise Applications. Rasea aims to become a reference in access control as a service based on the RBAC model.


Rascal, the Advanced Scientific CALculator, is a platform independent modular calculator. Based on modules for integer, doubles, strings, vectors and matrices it can be easily extended with existing C or C++ code.


RARS is the Robot Auto Racing Simulation, in which the drivers are robot programs. It is intended as a competition among programmers. It consists of a simulation of the physics of cars, a graphic display of the race, and a robot driver for each car.


This small program allows you to play a video directly from a RAR file and do so in real-time. Both VLC and MPlayer are supported video players.


RAReXtract is a Front-End for the UnRAR command line utility for Mac OS X 10.5 (Leopard). Its purpose is the rapid and convenient extraction of RAR archives with a double click.

RAR Expander

Rar Expander is a MacOSX program which extracts the files contained in single or multi-volume RAR archives. It uses the official unRAR library internally so it is fully compatible with archives produced by WinRAR.


This program uses a brute force algorithm to guess your encrypted compressed file\'s password. If you forget your encrypted file password, this program is the solution. This program can crack zip,7z and rar file passwords.


RArcInfo is a package for R (http://www.r-project.org) to import data from binary Arc/Info V7.X coverages and E00 files . This will allow R users to used it as a primary GIS tool.

rar brute force shell script - rarbrute

This is rarbrute, a shell script to brute force encrypted rar files under unix and linux. A long wordlist and a paper about security in internet cafes is included.

Raquel Database System

The system will : 1. use RAQUEL (= Relational Algebra Query, Update and Executive Language) for programming, implementing Third Manifesto principles. 2. have a 'Lego-like' architecture of building blocks and plug-ins, for wider applicability.


RAPv4 is an engine for building web application with only a business description (in XML format). NEW 04/2006 : Stable 2006 release. Add new functions like mail, sms, web services, graph, map engine (GIS), Excel output, QBE... and also a beta release of


2d Scroller. Clone of Raptor: Call of the Shadows and Tyrian. Fun game written in c++ using allegro.


Lightweight XML based transformation tool written in C that builds upon expat, tidylib and XSLT to tranform authored web content (incl. Word processor generated HTML) into styled web content suitable for publication.


RapidSMS is an open-source internet and communications platform


RapidSmith is a research-based FPGA CAD tool framework written in Java for modern Xilinx FPGAs. Based on XDL, its objective is to serve as a rapid prototyping platform for research ideas and algorithms relating to low level FPGA CAD tools.

Rapidshare Mass Downloader

What this program does is bringing out human interaction while downloading files from rapidshare(without premium account). It downloads all the rapidshare links sequentially to the specified location.

rapido visual profiler

rapido is a visual profiler for linux-x86. It traces function call using the ptrace interface and displays the information collected in a nice visual flow chart. rapido does not require the re-compilation of the application.