Daily Archives: 8/15/2003

GPS programming in Python


I just recently bought a new laptop, and on a total spur of the moment bought
a Delorme Earthmate GPS to go along with it. It’s a pretty slick little unit that
plugs into the USB port. After playing with Street Atlas 2003 for a few minutes (and getting directed over speedbump after speedbump) I decided to see if I could figure out how to get data from it.

A little quick research showed that there were two drivers for this little toy: a USB one that made it look like an HID device, and a different one that made it look like a serial device that speaks the NMEA 0183 protocol. I don’t know much about the first one, but I have docs on the second from my Garmin
days, so I set to work.

I decided to use the curses module in Python to present a simple interface. It does little more than monitor the messages output from the GPS and display
them in a somewhat neat fashion on the screen. After an hour or so of hacking around, I had the display shown on the right. Not too bad, and can be adapted to my Garmin with minimal work.

There are a few warts: opening serial ports on windows really requires a bit more work to make sure that baud rates are set. Also hot plugging the garmin doesn’t always detect when using the NMEA driver. But overall, not too bad.