No GPS? No problem! Using GPSDirect to develop location-aware apps (Part 1)

In an earlier blog post titled "Develop location-aware, Metro style apps when your development system doesn’t have GPS", one option I presented for those wishing to develop high-precision location-based Windows Store apps is to hook up an external GPS to your computer. What I want to do now is explore this method in greater detail, and I’m creating a three-part series on doing so with a software application called GPSDirect from TurboIRC.COM Software & Research. In part one, we’ll introduce the GPSDirect sensor driver and learn how to use it. In parts two and three, we’ll look at connecting an external GPS recevier and an Android-based smart phone as a GPS provider.

Part 1. Introducing GPSDirect

Part 2. Using an external, handheld GPS.

Part 3. Using an Android smartphone as a GPS receiver

Part 1: Introducing GPSDirect

For our GPS solutions we’ll make use of the GPSDirect NEMA Sensor Driver which was developed by Michael Chourdakis at TurboIRC.COM Software & Research. It takes any COM-connected GPS receiver and turns it into a Windows Location Sensor. Though this software was originally created for the Windows 7 Sensor API, it also works with the Windows 8 Location API for both Windows Store Apps and desktop applications. Both a 32-bit and 64-bit driver are provided.

Almost all general purpose GPS units are capable of emitting NMEA 0183 sentances over a serial port. NMEA stands for the National Mareine Electronics Association, and standard 0183 defines a communication protocol for marine devices such as sonar, echosounders, GPS receivers, and its predecessor, LORAN. The NMEA protocol is extremely simple, with messages transmitted in plain ASCII text in the form of "sentances". These devices emerged in the days when serial ports were the primary means of interacting with computer systems, and as such even modern devices with only USB connectors still provide NMEA output via a virtual COM port by embedding a USB-to-serial adapter internally. Nearly every USB-connected GPS receiver, commonly referred to as a GPS "mouse", is really a serial port device.

This USB-based GPS receiver shows up as a virtual serial port in Windows.

GPSDirect is basically a bridge solution. It's middleware that takes a GPS device connected on a virtual COM port and connects it to the Windows Location Sensor. To date, not many manufacturers provide a true sensor driver for their GPS receivers, and GPS receivers that are integrated into tablet and ultrabook platforms are still fairly rare. For those wishing to develop precision location-aware apps-- or even just use them-- GPSDirect represents the best way to make that possible when a native GPS sensor is not available on the system. The down side is that, being middleware, you have to jump through some extra hoops to use it and you can't expect to plug in your GPS receiver and have everything just work. The rest of Part 1 discusses those hoops in detail.

Download and install GPSDirect

From the GPSDirect download page, select the 32- or 64-bit driver as is appropriate for your system. The GPSDirect download is a simple EXE file. There is no installer, nor is there a driver installation procedure (but see "Running GPSDirect", below), however GPSDirect does unpack a few support files when it executes so I like to put it in a separate folder to keep things tidy. For this example, create a "GPSDirect" folder inside of your Documents folder and move the executable there.

Running GPSDirect

GPSDirect is a desktop application which includes a user mode driver that installs itself upon demand. Double-click to execute the binary. Windows 8 may ask you to enable location services as shown in the screenshot below. If so, click on "yes", since location-based applications won't work without the location service.

You will then be presented with the GPSDirect user interface window, a portion of which is shown below. Before the driver can install itself, it has to know which COM port your GPS is connected to, and at what speed it communicates. These parameters are set in the main user interface.

Note that drop-down menu for the connection speed only goes up to 19200 baud, but you can type any value in there. I have used external GPS data loggers that communicate at 115200 baud successfully with GPSDirect. In addition to COM ports, GPSDirect can also communicate with a network-connected GPS device. In this case, enter an IP address for the NMEA source and a port number in the Baud Rate/Port Number box. GPSDirect also includes a simulator mode which sets a random latitude, longitude, and altitude, and then changes them slightly every second.

Select the COM port that your GPS is attached to, provide the baud rate, and then hit "Install" to install the driver. This step will require administrator privileges since this is the point where the driver is actually installed on your system. If this is the first time you have run GPSDirect, you will also be presented with a Windows Security dialog, asking if you want to install the sensor device. To prevent this dialog from coming up again in the future, you can check the box to always trust software from the author.

Once the driver installs, the GPSDirect driver will start showing up as a location sensor in Device Manager.

Monitoring GPSDirect

When you first run GPSDirect, meaning after you have set your port settings and hit "Install", you may not see much output. Until your GPS device has started tracking satellites, in fact, it may not appear that GPSDirect is doing anything at all but once your receiver starts acquiring signals the display will update.

The upper right window lists the satellites that have been found by the device, showing their almanac information (satellite number, azimuth, and elevation), and the strength of the signal being received. The lower frame shows the time reported by the GPS receiver, and once a fix is obtained it will display:

  • latitude and longitude in decimal degrees (X and Y)
  • altitude in meters (Z)
  • speed in knots
  • bearing in decimal degrees
  • DOP (Dilution of Precision, mathematical limits on accuracy due to the current satellite geometry)

It will also periodically print one of the NMEA sentance that was received from the device. 

The GPSDirect window will contnue to update as long as the GPS receiver is on and active, though if signal reception is lost it may blank out again until satellite signals can be reaquired.

You do not need to keep this window open. You can close it using the red X (there is no "close" button) and if you later want to monitor your device, you can simply run GPSDirect again. The driver will remain active until you explicitly uninstall it.

Stopping GPSDirect

Stopping GPSDirect really means uninstalling the driver, and that is done with the "Uninstall" button. When you press this, GPSDirect closes the COM port, uninstalls the driver, and exits.

Things to keep in mind

  • As with any system where an external device is connected to a computer, the stability of the system is dependant on the stability of the connection. If a cable comes out, the GPS receiver powers off, or if the computer goes to sleep, GPSDirect may or may not be able to seamlessly continue. It may be necessary to explicitly uninstall the driver and reinstall to get things working again.
  • COM ports do not support multiple connections. If GPSDirect is using a COM port, other software will not be able to, and visa-versa.
  • Your virtual COM port will change if you move your USB-connected device between ports. Always verify in device manager that your device is attached to the port that you think it is.


In Part 2, we'll hook up an external GPS using GPSDirect.

Next -->


§

Per informazioni più dettagliate sulle ottimizzazioni basate su compilatore, vedere il nostro Avviso sull'ottimizzazione.