GPSd under OS X

Update 7-13-11: I’ve posted an updated set of instructions on getting GPSd to compile on OS X here; this post will remain for archival purposes. For information on installing GPSDrive, see this post.

So I recently picked up a cheap GPS module on Amazon. It was about $30 with shipping, and I got a neat little dongle which connects over USB to my computer and communicates with software. It didn’t come with support for OS X (although interestingly enough it shipped with Mac OS 8 and 9 drivers), but it promised to send generic NMEA-0183, so I wasn’t too worried.

When it showed up, some quick software probing revealed that it houses a usb to serial adaptor (a Prolific PL-2303, which I’ll get to in a bit) and a gps module that’s configured to send NMEA strings through the virtual serial port. This sort of information is compatible with a host of software, but most of it is commericial, and only available at a considerable price.

Luckily, there’s a wonderful open source project called gpsd which provides support for a wide raft of devices and protocols, and talks to an even wider assortment of software. Primarily, I wanted to be able to get my gps to talk to the network scanner Kismac, and Randall Munroe’s script. Both of these were built to take information from gpsd, so I was in business. However, gpsd, which is designed to play nicely with Linux, takes some coaxing under OS X. This is meant to describe how I got it all running.

I. Hardware driver

Because the gps relies on a usb-to-serial chip to talk to the computer, it needs a driver that will emulate a serial port. The chip in my gps revealed itself as a Prolific PL-2303, a common chip that I’d had previous dealings with, and so had a driver for. This enabled me to see a serial device on my system and read raw data from it:

sethjust$ ls /dev/cu.*
/dev/cu.Bluetooth-Modem		/dev/cu.Bluetooth-PDA-Sync	/dev/cu.PL2303-0000101D
sethjust$ stty -f /dev/cu.usbserial ispeed 4800 && cat </dev/cu.usbserial

This driver also played nicely with some of the commericial software demos I’d downloaded, but oddly enough it didn’t work with gpsd. Eventually, after some debugging and consulting with one of gpsd’s developers via IRC, I replaced the driver I had (an open source replacement for proprietary driver) with the driver from Prolific’s website. Supposedly the open-source PL-2303 driver doesn’t play nicely with gpsd, and so they recommend using Prolific’s.

II. gpsd and gpsdrive

The gpsd package comes with several useful support utilities, but one that it doesn’t include is gpsdrive, a wonderful program that supports mapping and live data from gps. Getting both running under OS X is a little difficult, but I found a great document here that explains the process. A little has changed, so here’s how I got it working (though I never did get xgps or xgpsspeed to compile…):
1) Install fink if you haven’t already.
2) Install gpsdrive through fink:

$ fink install gpsdrive

3) Rename /sw/bin/gpsd to gpsd-1.06b:

$ sudo mv /sw/bin/gpsd /sw/bin/gpsd-1.06b

4) Download the latest source for gpsd. I used the latest RC for their upcoming 2.38 release and have had no problems.
5) In the gpsd source directory, run ./configure with whatever options you’d like. The earlier document had some suggestions on getting it to see X11 libraries, but I haven’t been able to make them work. I ended up using

$ ./configure --bindir=/usr/local/bin -without-x

6) Compile the software by typing “make”. You can then either install it with “sudo make install” or test it before installing:

$ ./gpsd -n /dev/cu.usbserial
$ ./cgps

In my case /dev/cu.usbserial is the device representing the PL-2303. You should replace this with your own.

Running cgps should show a live summary of the information that gpsd is getting, along with a running log of the raw data coming from the gps. You can also test gpsd by telnetting to localhost:2947, typing w and hitting enter. You should see NMEA strings from the gps.

III. Kismac and

The original reason that I embarked on this gps adventure was to use two programs: Kismac and Randall Munroe’s Kismac is easy to get running with gpsd โ€“ once you have gpsd running (e.g. gpsd -n /dev/cu.usbserial), open Kismac and set it to use gpsd for map coordinates. It should display your location on the map screen, and associate coordinates with APs. is a little harder to get running. It’s dirty (though entirely functional) code that isn’t fully mac compatible. Notably, it uses two programs (flite and figlet) that are iffy under OS X. I patched that up, replacing flite with OS X’s built-in “say” command, and commenting out the figlet bits (which display large text) in favor of the terminal output the script gives. The modified script works beautifully, although I didn’t clean up the code at all. You can get it here.

IV. Links

6 thoughts on “GPSd under OS X

  1. cardinalbiggles

    I just took a look, and MacPorts has gpsd version 2.30 – it does not have gpsdrive however. I run both Fink and MacPorts, but I haven’t tried getting them communicating as I don’t have a usb gps, but I’m assuming at the most, a simple ‘ln -s’ would so the trick. The big question is if 2.30 is a late enough version.

  2. sethjust

    I haven’t used the MacPorts version, but as long as it will talk to whatever GPS you have, it should work. The only reason I used the most recent RC is that it was more likely to have fixed some bugs. Also, older ports have some bugs with unit conversions supposedly, which is why the fink GPSd shouldn’t be used.
    As to getting MacPorts GPSd and Fink gpsdrive talking, GPSd is a TCP daemon, which means that it communicates with other programs over the network. Once gpsd is running (wherever the file is located) clients will connect to it on localhost:2947.

  3. Pingback: GPS hacken unter Mac OS X: Handgemachte Geolocation auf dem Mac » MACNOTES.DE

  4. Pingback: iPhoto, Geotagging, GPS and the Mac: A Post-Macworld Roundup | Maps & Atlas

  5. Pingback: Dabbler : GPSd under OS X (revisited)

  6. Pingback: Dabbler : GPSDrive on OS X

Leave a Reply

Your email address will not be published. Required fields are marked *