Git Product home page Git Product logo

nmea-simple's Introduction

NPM version Travis CI Build Status

NMEA 0183 sentence parser and encoder

This library parses and encodes some NMEA 0183 sentences. These are typically used by GPS recievers to send information on position, heading, speed and acuracy. The official standard can be found here and is described in clear terms here.

Example

Typically, you will get NMEA sentences via the serial port from a GPS module. You can use the serialport NPM package to read the lines (and the @serialport/parser-readline parser to separate the input by "\r\n"). Each line can then be passed into parseNmeaSentence to get the decoded packet.

const SerialPort = require("serialport");
const Readline = require("@serialport/parser-readline")
const nmea = require("nmea-simple");

const port = new SerialPort(
    "/dev/ttyUSB0",
    {
        baudRate: 9600
    }
);

const parser = port.pipe(new Readline({ delimiter: '\r\n' }))

parser.on("data", line => {
    try {
        const packet = nmea.parseNmeaSentence(line);

        if (packet.sentenceId === "RMC" && packet.status === "valid") {
            console.log("Got location via RMC packet:", packet.latitude, packet.longitude);
        }

        if (packet.sentenceId === "GGA" && packet.fixType !== "none") {
            console.log("Got location via GGA packet:", packet.latitude, packet.longitude);
        }

        if (packet.sentenceId === "GSA") {
            console.log("There are " + packet.satellites.length + " satellites in view.");
        }
    } catch (error) {
        console.error("Got bad packet:", line, error);
    }
});

TypeScript

This project is written in TypeScript. The library can be used by plain JavaScript as shown above, and the typing information is also included with the library so that anyone wishing to use TypeScript will gain the benefits of the type information.

Packet types supported

The following sentence types can be parsed by this library:

  • APB
  • BWC
  • DBT
  • DTM
  • GGA
  • GLL
  • GNS
  • GSA
  • GST
  • GSV
  • HDG
  • HDM
  • HDT
  • MTK
  • MWV
  • RDID
  • RMC
  • VHW
  • VTG
  • ZDA

The following sentence types can be encoded by this library:

  • DBT
  • GGA
  • GLL
  • GNS
  • HDM
  • HDT
  • MTK
  • MWV
  • VTG

This is a fork of the nmea package with all dependencies removed and TypeScript typing information added.

Acknowledgements

This module was based on the NPM nmea and nmea-0183 packages (with date decoding borrowed from GPS) and the documentation was expanded based on the excellent analysis and descriptions by Eric S. Raymond.

nmea-simple's People

Contributors

101100 avatar jamesp avatar tjkurki avatar tkurki avatar angas avatar drewf7 avatar duncanbarnes avatar efink-novetta avatar yetzt avatar chopj avatar fphillips avatar jksdua 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.