Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nmea

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nmea

  • 0.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Author:: Max Lapshin (mailto:max@maxidoors.ru) Copyright:: Copyright (c) 2007 Max Lapshin, Getalime License:: Distributes under the same terms as Ruby

To use NMEA parser, you should somehow get data stream from Yor gps device. For example, You can use ruby-serialport (which seems to be dead, but working). The example on Mac with installed USB-Serial driver:

require 'serialport'
require 'nmea'
@sp = SerialPort.open("/dev/tty.usbserial", 4800, 8, 1, SerialPort::NONE)
@handler = NMEAHandler.new
while(@sentence = @sp.gets) do
  NMEA.scan(@sentence, @handler)
end

NMEAHandler is a user class, that implements following interface:

class NMEAHandler
  def rmc(time, latitude, longitude, speed, course, magnetic_variation)
    # read further about types of latitude and longitude
  end
  def gsv(flag, satellites)
  end
  def gsa(mode_state, mode, satellites, pdop, hdop, vdop)
  end
  def gga(time, latitude, longitude, gps_quality, active_satellite_count, gsa_hdop, altitude, geoidal_height, dgps_data_age, dgps_station_id)
  end
end

As you can see, the following NMEA sentences are supported currently: $GPRMC, $GPGSV, $GPGSA, $GPGGA. If you need more, please contact me and provide me with several examples. I will add support for them. NMEA::scan will not try to call unexistent method on your handler, thus you can implement only those methods in your handler, you need to.

GSV handler has parameter flag. This flag can take one of the following values: :start, :continue and :finish. GSV messages appears in packs of several sentences, but NMEA::scan is stateless, thus your NMEAHandler should keep accumulate these messages.

It is important to mention, that NMEA::scan assumes, that You have classes GPS::Latitude and GPS::Longitude, which initializer, takes two arguments: degrees and minutes. You can use this example:

module GPS
  AngleValue = Struct.new :degrees, :minutes

  class AngleValue
    def to_s
      "%d %.4f%s" % [degrees.abs, minutes, symbol]
    end
  end

  class Latitude < AngleValue
    def symbol
      degrees >= 0 ? "N" : "S"
    end
  end
  class Longitude < AngleValue
    def symbol
      degrees >= 0 ? "E" : "W"
    end
  end
end

Supported devices.

Ruby NMEA has full support of Globalsat BU-353 device (http://www.usglobalsat.com/item.asp?itemid=60&catid=17).

NMEA syntax is assumed to be as in document nmea.html, taken from http://www.werple.net.au/~gnb/gps/nmea.html

FAQs

Package last updated on 25 Jul 2009

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc