Two weeks ago, I ordered myself a GPS system. More specifically, I picked the Garmin Nuvi 350, which is NOT a traditional GPS, but a Personal Navigation System. I was mildly disappointed that it did not support the saving or dumping of raw GPS data. After playing with it, and figuring out the basic hacks for it within a few days (I was fully up on it by Thursday, got it on Tuesday) I acquired a "straight GPS" from my buddy Erik. The second device is a Delorme Earthmate USB. This thing is great, and like many devices, has better support in Linux than it does in Windoze.

I got GPSDrive working, talking to gpsd, along with a horribly written BASH script that I fat fingered and failed me this morning. Here's the corrected one:


#!/bin/bash
# $HOME/GPS/scripts/FollowMe.sh
# author: Me!
# last updated: Mon Jul 07 07:19:56 EDT
# abstract: Polls gpsd and sends results to brightkits
# this script is NOT pretty, but it's commented

# start gpsd as root
sudo gpsd -n /dev/ttyUSB0

# create directory for this run's data and define files
DATE=`date +%y%m%d-%H%M%S`
mkdir ~/GPS/$DATE
GPSDUMPFILE=~/GPS/$DATE/dump.nmea
GPSDRIVEFILE=~/GPS/$DATE/dump.gpsdrive
RSLTFILE=~/GPS/$DATE/dump.rslt

# poll gpsd every $INTERVAL minutes
INTERVAL=10

# my shitty while loop
X=1

while [ $X -eq "1" ]
do
# poll gpsd with netcat and output to the nmea dump file
echo r | nc -i 3 localhost 2947 >> $GPSDUMPFILE
# convert the nmea data to simpler gpsdrive data
gpsbabel -i nmea -f $GPSDUMPFILE -o gpsdrive -F $GPSDRIVEFILE
# sample most recent result
CURRENTRESULT=`tail -1 $GPSDRIVEFILE`
# for debugging, echo the result to the terminal and read the result
# with festival
echo $CURRENTRESULT
echo '(SayText "Uploading current location to bright kite dot com '$CURRENTRESULT'")' | festival --pipe
# create the file that will be mailed
echo "@ $CURRENTRESULT" > $RSLTFILE
# mail the file with mutt (keep in mind that your .muttrc will be
# used for this
mutt -b whereami@checkin.com whereami@checkin.com < $RSLTFILE
# i know... bash can do this, but i used bc :-P
sleep `echo "$INTERVAL * 60" | bc -l `
done

# the script is just killed by a C-c


I know, it's not pretty at all, but it works (I think... I only missed the "@" symbol last night in the $RSLTFILE, but I was tired.

Check my twitter and brightkite feeds around 1600 today, and it should be working :-)

0 comments:

Newer Post Older Post Home