GithubHelp home page GithubHelp logo

ianfixes / nmea Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maxlapshin/nmea

0.0 2.0 0.0 243 KB

Ruby NMEA parser

Home Page: http://nmea.rubyforge.org/

Ruby 21.99% C++ 43.44% C 12.63% HTML 17.79% Makefile 0.08% Ragel in Ruby Host 4.08%

nmea's Introduction

NMEA Ruby Gem

  • Author: Max Lapshin
  • Copyright: Copyright (c) 2007 Max Lapshin, Getalime
  • License: Distributes under the same terms as Ruby

Usage

To use NMEA parser, you should somehow get data stream from Your 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

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.

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

nmea's People

Contributors

maxlapshin avatar ianfixes avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.