Leadtek Speeding Master GPS on Linux

LeadTek Speeding Master
I can’t resist buying gadgets, even when they are of no practical use (and that’s the characteristic of most gadgets) i am drawn to buying it, firing it up, see how it works, peek in it’s insides and after that it mostly ends in a box in my overcrowded hobby room. So when i saw this GPS device for only 35 € i had to buy it, even when the device has an outdated Sirf II receiver and only works when attached to a power source. 35 € is just no money for such an ingenious device.

The next thing is of course connect it to my Linux system and see how much trouble it will be to get things working. The Leadtek GPS is a RS232 serial device but comes with a serial to USB convertor. So when i plugged it in, the convertor registers on the system:

# dmesg | tail
usb 4-1: new full speed USB device using uhci_hcd and address 2
usb 4-1: configuration #1 chosen from 1 choice
usbcore: registered new interface driver usbserial
drivers/usb/serial/usb-serial.c: USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
drivers/usb/serial/usb-serial.c: USB Serial Driver core
drivers/usb/serial/usb-serial.c: USB Serial support registered for pl2303
pl2303 4-1:1.0: pl2303 converter detected
usb 4-1: pl2303 converter now attached to ttyUSB0
usbcore: registered new interface driver pl2303
drivers/usb/serial/pl2303.c: Prolific PL2303 USB to serial adaptor driver

And it shows up on a lsusb output:

# lsusb
Bus 001 Device 001: ID 0000:0000
Bus 001 Device 004: ID 413c:a005 Dell Computer Corp.
Bus 001 Device 006: ID 0b97:7762 O2 Micro, Inc. Oz776 SmartCard Reader
Bus 001 Device 005: ID 0b97:7761 O2 Micro, Inc.
Bus 003 Device 001: ID 0000:0000
Bus 003 Device 002: ID 046d:c016 Logitech, Inc. M-UV69a Optical Wheel Mouse
Bus 004 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 004 Device 001: ID 0000:0000
Bus 005 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000

To communicate with the GPS the documentation says the baudrate should be 38400 bits per second, so we will configure that for the first USB serial port and see what happens.

# /bin/stty -F /dev/ttyUSB0 speed 38400 raw cs8
38400

(i had to repeat the command twice on my system because the first time it reported back 9600 bps)

And Lo and Behold, there is the NMEA data spilling out:

# cat < /dev/ttyUSB0
$GPGGA,120523.932,5210.0992,N,00430.9070,E,1,08,1.2,57.4,M,,,,0000*30
$GPRMC,120523.932,A,5210.0992,N,00430.9070,E,0.00,,080707,,,A*7A
$GPVTG,,T,,M,0.00,N,0.0,K,A*13

Since humans are not optimally equipped for interpreting these sequences of data, we need a program to convert the messages into sensible information, for instance coordinates. I will use gpsd for this purpose. It's a daemon which can provide the information gathered from a GPS device to one or more clients even if they are not running locally. On my Fedora Core 6 system the program was available through yum:

#yum -y install gpsd gpsd-clients

First we will start it up in debug mode to see whether it understands our GPS:

# gpsd -N -n -D 5 /dev/ttyUSB0

gpsd: CLK 0x07
gpsd: Raw SiRF packet type 0x29 length 91: 2900000204059b02a5f30607d707080c143ed61f0000801f18412002b0f4cb000016f20000048f1500000000000000000000000000da0000018f00000000000002a35
c1100000000001c2453000000000000000000000000060800
gpsd: Raw SiRF packet type 0x02 length 41: 02003ba1d70004b582004c8357000000000000040802019b0043cb8006081d1a1c1b19000000000000
gpsd: MND 0x02: Navtype = 0x4, Status = 1, mode = 3
gpsd: <= GPS: $GPGGA,122016,5210.0993,N,00430.9087,E,1,06,1.60,12.3,M,46.766,M,,*44\x0d\x0a$GPRMC,122016,A,5210.0993,N,00430.9087,E,0.0000,0.000,080707,,*27\x0d\x0a$GPGSA,A,3,0
8,29,26,28,27,25,,,,,,,2.7,1.6,1.2*3C
gpsd: Raw SiRF packet type 0x09 length 9: 09004300040028007c
gpsd: THR 0x09: SegStatMax=0.360, SegStatLat=  0, AveTrkTime=0.215, Last MS= -0
gpsd: Raw SiRF packet type 0x07 length 20: 07059b0043cb800600017a970016870f02a5f306

That's looking good, so now we can run it as intended:

# gpsd -n /dev/ttyUSB0

And have a client connect to finally show us our position:

$ xgps -speedunits kph -altunits meters

xgps display
click on the image to see it in a seperate window

Now you could program a tomahawk missile with these coordinates and wipe me of the face of the earth (better ring first to see if i am at home, otherwise it would be a total waste of such an expensive missile). But before spending a million dollar on a rocket it might be interesting to know how accurate these coordinates are, otherwise you might wipe out my neigbhors, and they are perfectly amicable people.
One way of getting an impression is to build a so called scatter graph of the GPS data. The GPS outputs coordinate data approximately once every second, so we could collect one hour of coordinates and put them into a graph. The way to do this is actually very simple with gpsd:

$ gpsprof -n 3600 | gnuplot -persist
gpsprof: looking for fix...first fix in 0.73sec, gathering samples...

Here is the resulting graph:

gps scatter graph
click on the image to see it in a seperate window

This is all the help you will get from me, both in connecting the GPS device and in programming the missile with my home coordinates.

Have fun!