Skip to content

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 cyborg.py 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
,,,3.6,2.2,2.8*3E
$GPRMC,060645.994,A,4537.5498,N,12259.8000,W,000.0,327.4,120109,,,A*70
$GPVTG,327.4,T,,M,000.0,N,000.0,K,A*0F
$GPGGA,060646.994,4537.5498,N,12259.8000,W,1,06,2.2,137.3,M,-21.5,M,,0000*63
$GPGSA,A,3,23,25,13,04,32,20,,,,,,,3.^C

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 cyborg.py

The original reason that I embarked on this gps adventure was to use two programs: Kismac and Randall Munroe’s cyborg.py. 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.

cyborg.py 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

{ 2 } Comments

  1. cardinalbiggles | January 14, 2009 at 3:47 pm | Permalink

    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 | January 14, 2009 at 5:50 pm | Permalink

    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.

{ 4 } Trackbacks

  1. […] sich sein Geolocation-Tool selber zusammenhacken möchte: Seth Just hat eine Anleitung veröffentlicht, wie man unter Mac OS X billige GPS-Module via USB zur Kommunikation mit dem GPS-Daemon GPSd […]

  2. […] files, one about using an old Garmin GPS. And, for those who like to futz with the command line, Seth describes how he got the GPSd daemon working under OS X (via Make: […]

  3. Dabbler : GPSd under OS X (revisited) | July 10, 2011 at 8:07 pm | Permalink

    […] been almost 2 and half years since I originally posted about GPSd and OS X. That post got quite a bit of traffic for a while, but a whole lot has changed since then. If […]

  4. Dabbler : GPSDrive on OS X | February 11, 2012 at 6:48 pm | Permalink

    […] on OS X, I set my sights on GPSDrive, an open source navigation and map viewing program. When I posted about GPS a couple years ago, I installed GPSDrive, using the version from Fink. However, the latest version of GPSDrive on Fink […]

Post a Comment

Your email is never published nor shared. Required fields are marked *