0.0
No commit activity in last 3 years
No release in over 3 years
Fetches, and converts GPS coordinates using the SerialPort gem.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.2.0, ~> 0.2
>= 0.1.9, ~> 0.1
>= 1.3.0, ~> 1.3
 Project Readme

Introducing the Serialport_gps gem

Defaults:

  • port: /dev/ttyAMA0

  • baud_rate: 96000

  • refresh_rate: 8 seconds

    require 'serialport_gps'

    gps = SerialPortGPS.new gps.start

Output:

{:time=>2014-07-05 21:53:40 +0000, :latitude=>55.92721483, :longitude=>-3.13518783}
{:time=>2014-07-05 21:53:44 +0000, :latitude=>55.92720717, :longitude=>-3.13513767}
{:time=>2014-07-05 21:53:52 +0000, :latitude=>55.92721417, :longitude=>-3.135116}
{:time=>2014-07-05 21:54:00 +0000, :latitude=>55.92722817, :longitude=>-3.13505783}
{:time=>2014-07-05 21:54:08 +0000, :latitude=>55.92722067, :longitude=>-3.1469765}
{:time=>2014-07-05 21:54:16 +0000, :latitude=>55.92720633, :longitude=>-3.13509533}
{:time=>2014-07-05 21:54:24 +0000, :latitude=>55.92720567, :longitude=>-3.1350735}
{:time=>2014-07-05 21:54:32 +0000, :latitude=>55.92721317, :longitude=>-3.13508183}

There is a callback proc which can be passed in at initialization which is triggered when new GPS data has arrived. The default callback which can be seen from the output above is used for testing purposes, as well as demonstrating what the gem outputs.

Using a callback

require 'serialport_gps'
 

gps_notification = lambda do |x|
  puts "%-13s %-12s, %-12s" % 
                       [x.time.strftime("%H:%M:%S%P"), x.latitude, x.longitude]
end

gps = SerialPortGPS.new callback: gps_notification
gps.start

output:

GPS listener starting ...
GPS listener created

09:08:01am    55.94625383 , -3.1169905  
09:08:09am    55.9462515  , -3.11973   
09:08:17am    55.94624667 , -3.116976

Resources

gps serialport gem