DecodeGPS Assembly for the Visual Studio .NET Compact Framework (PocketPC)
Keywords: Decode GPS Compact Framework 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. Note the use of Invoke to delegate a handler that executes in the STAThread context of the UI for displaying output data. Serial communications is not well emulated by the PPC emulator, thus all use, including debugging, should be done on actual hardware. The example provided here employs my CFSerialIO DLL for the serial interface routines.
This DLL is designed to be thread safe. Thus, it may be employed in or called from a worker thread if desired. Source code is available to readers of my book (or for a nominal charge), but it is not included in the download. Contact me if you are interested.
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
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
If you want to employ this on a non-PocketPC compatible platform, contact me (above) for information about how to obtain the source code.
Source code for the class module is available to readers of my book, Visual Basic Programmer's Guide to Serial Communications 5, published September 2014 (click here for information). Send me email about this (firstname.lastname@example.org).
Download Now (about 50 Kb).
5/15/2004 - Fix problem with non-US dates (System.Globalization now used).
6/10/2004 - Add Altitude and Number of Satellites in Use.
1/28/2005 - Improve Example.
8/3/2006 - Add GPSDecode Error event. Improved error handling.
Return to Hard & Software