Return to Hard & Software

DecodeGPS Assembly for the Visual Studio .NET Desktop Framework

Keywords: Decode GPS Visual Studio .NET Visual Basic Example

This simple DLL uses the GPRMC (RMC) and GPGGA (GGA) sentences from the standard NMEA-0183 serial data stream that are output by most GPS receivers.  The data decoded here provides most of the information that would be useful for PocketPC and Embedded CE 4.x applications.  In addition to simple decoding, there are four properties that provide additional features.  These are the DecimalLatitude and DecimalLongitude properties that provide Latitude and Longitude in decimal format (such as is required by mapping programs, such as Microsoft MapPoint™), and the LocalTime and LocalDate properties that provide time and date appropriate to the local time zone.  The Altitude and Number of Satellites used also are provide.  Special Note: Altitude may not be correct, even though a valid navigation solution is provided!  Four satellites, or more, are required to correctly calculate altitude, but only three satellites are needed for a valid navigation solution.  Thus, use the altitude information with caution.  Check to make sure that at least four satellites were in use for the current navigation solution (not three) -- and use all navigation data with care; GPS receivers have been known to err.

The use of this DLL is straight forward.  Add a reference to it in your project and instantiate a variable of DecodeGPS type.  Add an event handler for the GPSDecoded event (property data may be polled, however valid data is available only after a GPSDecoded event, where the Boolean event parameter is True).  Thus, the most robust design will use this event mechanism.  Call the GPSStream method and pass it the serial data received from your GPS receiver. 

A VB .NET example that illustrates this process is included in the download. This example also uses the MapPoint 2004 ActiveX control to display a map centered around the current decoded GPS Latitude and Longitude.  Thus, to fully use this example you must also install MapPoint.  At this writing a demo version of MapPoint is available from Microsoft.

This example also allows replaying of a pre-recorded GPS log file.  Thus, you can view the results by decoding the data from this file without the use of a GPS receiver.  Naturally, serial data from an actual GPS receiver would be better. 

The example uses the DesktopSerialIO dll (available for download from this site).  Both DesktopSerialIO and DecodeGPS dlls are included in the download.

The DecodeGPS DLL is designed to be thread safe.  Thus, it may be employed in or called from a worker thread if desired.

Standard caveats: This DLL is provided free, without warranty of any kind. You are free to use it for any purpose that you deem reasonable, but the author is not responsible for any such use (or misuse), or for any damage that might result from its use. Treat this software like you would any beta software. It may work as described, but if it does not, you received what you paid for.  If you want to employ this on a non-PocketPC compatible platform, contact me (above) for information about how to obtain the source code.

Note:  The examples shown use MapPoint 2004.  MapPoint 2006 code is identical (though there are a few new APIs in 2006, these simple examples do not address those areas).

 Source code for the class module is available to readers of my book, Visual Basic Programmer's Guide to Serial Communications 5 (click here for information).  Send me email about this (dick_grier@msn.com). 

Visual Studio 2003 Download Now (about 300 Kb).

Visual Studio 2005 (use System.IO.Ports for serial IO) Download Now (about 370 Kb).

Return to Hard & Software