GPS and Linux

so you have a bluetooth GPS reciever and you have a computer running linux with bluetooth capabilities, maybe you have not yet used them together. .. well here are a few things that may help. this tutorial has been written using Ubuntu, actually Kubuntu 8.04, i have done most things said here a few years ago with Debian Sarge so i suppose many things should work the same on other systems although here i haven't mentioned installation of any bluetooth apps as they are all already installed by default.

finding the reciever

for this we will need to use hcitool like this :

hcitool scan

If you don't have it you can install it;

apt-get install bluez-utils

this tool with the option 'scan' allows us to find the MAC addresse of the reciever (and yes it will also show you the phones and audio sets and etc of your neighbours.

example :

[manu@hal][~-20:46] hcitool scan Scanning ... 00:44:44:44:44:44 Ordinateur de christophe macmac 00:DD:DD:DD:DD:DD HOLUX GPSlim236 00:33:33:33:33:33 telephone

here we can see the MAC of the "HOLUX GPSlim236", we happy.

connecting people the GPS and the computer

we can use rfcomm to attach the GPS to /dev/rfcomm0, for this all we need to do is :

rfcomm connect 0 00:DD:DD:DD:DD:DD

if we unzoom it should look like this :

[manu@hal][~-20:52] rfcomm connect 0 00:DD:DD:DD:DD:DD Connected /dev/rfcomm0 to 00:DD:DD:DD:DD:DD on channel 1 Press CTRL-C for hangup

the "0" means the we want to attach the device to /dev/rfcomm0, you can use any other number if needed. as indicated, to hangup, press "ctrl + c" in the terminal when done.

it is now possible to read the infos directly from the reciever by exectuting "cat /dev/rfcomm0", if you are able to understand and decode the infos as they go by you might not need to go further.. . :]

[manu@hal][~-20:53] cat /dev/rfcomm0 $GPGGA,182655.235,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*4A $GPRMC,182655.235,V,0000.0000,N,00000.0000,E,,,311006,,,N*7A $GPVTG,,T,,M,,N,,K,N*2C $GPGGA,182656.235,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*49 $GPRMC,182656.235,V,0000.0000,N,00000.0000,E,,,311006,,,N*79 $GPVTG,,T,,M,,N,,K,N*2C $GPGGA,182657.235,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*48 $GPGSA,A,1,,,,,,,,,,,,,,,*1E

gpsd - the GPS server

gpsd is a gps server that will read from /dev/rfcomm0 and relay it to the programs that need gps infos, they will connect to gpsd, some older programs would connect directly to the rfcomm "thingy", nowadays they will connect to gpsd, by default on localhost, port 2947.

for our first attempt it's a good idea to launch gpsd in debug mode "-D 2" and because we don't want it to be daemonized the option "-N" will be of good use. another thing that might be useful in some cases is the "-b" option, this option tells gpsd to not try to configure the reciever in any way but only read from it. .. they say it's less performant but on some recievers it can be bad.. :] (apparantly it is a bluetooth issue).. .

gpsd -b -N -D 2 /dev/rfcomm0

and now. .. the client(s)

there are many gps clients out there for linux, here is a brief overview of a few of them :

  • xgps - this program shows the gps infos (satellites, speed, postition, etc).
  • cgps - same as xgps but in text mode. . (i like)
  • gpsdrive - this navigation tool is supposed to be able to guide you when travelling by car, boat or plane.. . i'm not sure it's complete, or actually i'm not sure i know how to use it :]]] definetly one of the most important gps client projects
  • viking - i am in the phase of discovery with this one, it has a nice interface any apparantly many possibilities
  • gpsctl - this little software piece is useful for changing the mode of a GPS reciever from NMEA to binary and vice versa

xgps and cgps

these two programs are generally used just to test the gps installation, they connect to gpsd and show satellite infos, with position and speed (if available).. very useful when you just want/need to see what's going on.

Xgps
Cgps

gpsdrive

this is supposed to be a navigation program, i'm not sure it's finished or maybe i just don't know how to use it (or maybe the ubuntu version is weirdly compiled :] ), in all cases it's one of the most serious projects out there and has actually helped me navigate through some dirt roads on vancouver island.. you will need to download the maps with the help of an IP of course (so yes, do that before leaving $home unless you have a portable IP)..

viking

this program is supposed to be able to do a lot of things, of course i'm not going into detail on what can be done with the gps clients here.. however there is an interesting thing when adding a GPS layer, i am not sure where this "bug" comes from but you can only chose from a pulldown menu, and /dev/rfcomm0 is not there, so the trick is to link ttyUSB0 (or ttyUSB1) to /dev/rfcomm0 like this:

sudo ln -s /dev/rfcomm0 /dev/ttyUSB0

without going into the details, i must say that the realtime mode is kicks arse, i recorded a journey i did and then when i got home i added a "map layer", downloaded the maps and i could see where i have been.. . very sweet. you can even goto the GPS layer and unfold untill you get to "REALTIME" and "right click" => properties and see a whole bunch of stuff.. . :]

Viking
Viking

gpsctl

if your gps can change from NMEA mode to binary and back then this tool can help you do that.. . useful if it's "stuck" in binary.. (the binary mode is usually proprietary so it can also be called "useless mode")..

to switch to NMEA mode (if only one gps device is connected) all you need is :

gpsctl -n

now you can play will all this stuff and figure out how to actually use the software for whatever the hec you wanted gps in the first place.. . if you do have comments and/or stuff to point out to me please do so . .:]