Skip to content

Instantly share code, notes, and snippets.

@mort
Created April 16, 2011 09:41
Show Gist options
  • Save mort/923018 to your computer and use it in GitHub Desktop.
Save mort/923018 to your computer and use it in GitHub Desktop.
GPS tracking
require 'rubygems'
require 'serialport'
require 'redis'
port_str = '/dev/tty.iBT-GPS-SPPslave'
baud_rate = 9600
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE
sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
Redis = Redis.new
while str = sp.gets do
if (str) =~ /^\$GPGGA/
# puts str
arr = str.split(',')
# puts arr.inspect
Redis.lpush arr[1], "#{arr[2]}#{arr[3]}"
Redis.lpush arr[1], "#{arr[4]}#{arr[5]}"
Redis.lpush arr[1], arr[9]
print '*'
else
print '.'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment