Configuring EVDO GPS under Ubuntu
For Christmas, Santa brought an ASUS EeePC 1005HA for my 10 year old son. Santa, being a staunch anti-Micro$oft zealot just like myself, had the common decency to remove the WEENDOZE installed on this netbook and install Ubuntu 9.10 on it before his midnight romp through my living room to leave it under the Christmas tree. My kid just loves it. Unfortunately, he also loves the internet.While we were on the road during the holidays, my son complained constantly about not having internet access. So, I did a little research and I purchased the Cradlepoint CTR500 cellular-ready travel router. I will blog about this interesting little device at some later time; however, while configuring this device, I happened to click on a configuration page labeled GPS and I learned that my Sprint/Sierra Wireless AC597E EVDO modem had GPS capabilities! Having been lost on some of the back roads near Penn State where my 19 year old son is attending school, knowing precisely where we were would have helped immensely to plot our way with mapquest.com or maps.google.com. Thus, I was hell bent on getting this GPS capability accessible on either my Ubuntu laptop and or my MacBookPro.
Surprisingly, the Sierra Wireless site was most helpful. In order to use the EVDO card's GPS capabilities, the GPS capabilities only need to be enabled or turned-on. This is done with special syntax AT commands. So, I plugged in the Sierra Wireless AC597E EVDO modem and tried the commands manually.
# cu -l /dev/EVDO0
Connected.
ATZ
OK
AT!GPSTRACK=2,60,100,1000,5
Tracking initiated
OK
AT!GPSSTATUS
198001066000000 Last Fix Status = ACTIVE
198001066000000 Last DLoad Status = NONE
198001066000000 Fix Session Status = ACTIVE
198001066000000 DLoad Session Status = NONE
OK
According to the Sierra Wireless site, the third
/dev/ttyUSBn
device created when the EVDO card is inserted is the device which will emit the GPS tracking data. In a previous entry, I wrote about how I'd used udev to configure this EVDO modem with the device names of /dev/EVDO0
, /dev/EVDO1
and /dev/EVDO2
irrespective of the actual /dev/ttyUSBn
device names. Thus, the GPS data would come streaming out from device /dev/EVDO2
. I checked this out with:
# cat /dev/EVDO2
$GPGGA,134022.0,4007.382476,N,07416.126785,W,0,05,1.0,-5.0,M,,,,*32
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,,V,,,,,,,,,,N*53
and there it was... GPS data!
There I am at 4007.382476,N,07416.126785,W which is 40° 07' 22.569" of North latitude and 74° 16' 07.364" of West longitude. I went to http://atlas.mapquest.com/maps/latlong.adp and plugged in these coordinates. The web page wouldn't accept the decimal part of the latitude's and longitude's seconds but, even without them, I was placed in the middle of Rutgers Road, Jackson, NJ. Close enough to verify that the GPS was functioning and far too close for government work!
Now, all I needed was some GPS software. A little googling indicated that I would need several packages to take advantage of the GPS capabilities of this EVDO card. So, I entered:
# sudo apt-get install gpsd gpsdrive gpsd-clients gpsdrive-scripts
After installation, I configured the gpsd with:
# sudo dpkg-reconfigure gpsd
electing to start gpsd automatically, defined the Device the GPS receiver is attached to as
/dev/EVDO2
, the Options to gpsd as -F /var/run/gpsd.sock
and finally indicated affirmatively to the question, Should gpsd handle attached USB GPS receivers automatically? With gpsd now configured and launched, I tested out several of the GPS tools and utilities that were downloaded and installed.Up until now, I was relying on manually enabling the GPS functionality in the Sierra Wireless AC597E card. I could, considering how little I might employ this feature, just continue to manually enable the GPS functionality but that's not as much fun as trying to figure out a way to have it configured automatically. If you recall, I've already setup udev to configure unique and specific names for the devices created when the card is inserted; thus, it wouldn't take much more effort to have udev handle the GPS initialization of the card.
The original udev configuration for the Sierra Wireless AC597E was:
# Create /dev/EVDO* symlinks for Sierra EVDO modem
KERNEL=="ttyUSB*", DRIVERS=="sierra", ATTRS{port_number}=="0",
SYMLINK+="EVDO0"
KERNEL=="ttyUSB*", DRIVERS=="sierra", ATTRS{port_number}=="1",
SYMLINK+="EVDO1"
KERNEL=="ttyUSB*", DRIVERS=="sierra", ATTRS{port_number}=="2",
SYMLINK+="EVDO2"
To initialize the card's GPS capabilities, I would only need to specify a run script for the
/dev/EVDO0
device.I created a directory
/usr/local/bin/Sierra_Wireless-AC597E
and a file called init-GPS.sh
in this directory. In the file I places the following commands:
#!/bin/bash
#set -x
#if [ "${ACTION}" = "add" ] && [ -f "${DEVNAME}" ]
#then
echo $(date): ${ACTION} ${DEVNAME} >> /var/log/init-GPS.log
echo -n -e 'ATZ\r' > ${DEVNAME}
echo -n -e 'AT!GPSTRACK=2,60,100,1000,5\r' > ${DEVNAME}
echo -n -e 'AT!GPSSTATUS\r' > ${DEVNAME} ; head --lines=11 ${DEVNAME} >> /var/log/init-GPS.log
echo '==============================================' >> /var/log/init-GPS.log
#fi
I commented the conditional statements out as I was more interested in seeing if the card had initialized properly every time. The trick to implementing this is to
echo
the AT commands to the EVDO card properly. By default, echo
will send a new-line character. I found that this caused problems with the initialization, so I opted for echo -n
to suppress the new-line. However, I now needed to terminate the command line sent to the device. In order to do that, I would need to explicitly send it a carriage-return. So, in addition to the switch to suppress the new-line, I also needed to enable escapes with echo -n -e
. This turned out to work perfectly.I amended the original udev configuration for the Sierra Wireless AC597E to execute this script when the device was inserted. The contents of this file now reads:
# Create /dev/EVDO* symlinks for Sierra EVDO modem
KERNEL=="ttyUSB*", DRIVERS=="sierra", ATTRS{port_number}=="0",
SYMLINK+="EVDO0",
RUN+="/usr/local/bin/Sierra_Wireless-AC597E/init-GPS.sh
KERNEL=="ttyUSB*", DRIVERS=="sierra", ATTRS{port_number}=="1",
SYMLINK+="EVDO1"
KERNEL=="ttyUSB*", DRIVERS=="sierra", ATTRS{port_number}=="2",
SYMLINK+="EVDO2"
The same file contents as before with the addition of the run-script to the first device.
However, I wanted to garner more status information when the card was inserted and initialized. Simply logging the time and device name didn't provide me with that. So, after sending the last command, I decided to pipe or redirect the device to the log file. The problem here is that there is never seen any end-of-file that would permit
cat
or cp
or other command to complete. So, in order to insure that the initialization script would complete, I opted to use the head
command and specify a number of lines to output. This would insure that the script would complete and the device would become both configured and available.The log file now appears as:
Wed Jan 13 11:12:31 EST 2010: add /dev/ttyUSB0
ATZ
OK
AT!GPSTRACK=2,60,100,1000,5
Tracking initiated
OK
AT!GPSSTATUS
198001066000000 Last Fix Status = ACTIVE
198001066000000 Last DLoad Status = NONE
198001066000000 Fix Session Status = ACTIVE
198001066000000 DLoad Session Status = NONE
==============================================
Everything I could ever need or want to know about the EVDO device's initialization for GPS functionality is nicely and neatly detailed in the log file.
With this configuration script now in place, the EVDO card's GPS capabilities are enabled when the card is inserted into the ExpressCard slot, and the EVDO card's networking capabilities and configuration are completely unscathed.
I'm now awaiting an opportunity to be able to watch GPS plotting and tracking information in action as I'm traveling about in a moving vehicle; however, since I'm usually the one in the driver's seat, this opportunity may take some time in coming. In the mean time, I will be setting off to explore the configuration of this EVDO card's GPS capabilities under OS X on my 17" MacBookPro.