3.3.0 • Published 1 year ago

nmea-simple v3.3.0

Weekly downloads
241
License
MIT
Repository
github
Last release
1 year ago

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 (separated by "\r\n"). Each line can then be passed into parseNmeaSentence to get the decoded packet.

var SerialPort = require("serialport");
var nmea = require("nmea-simple");

var port = new SerialPort(
    "/dev/ttyO2",
    {
        baudrate: 9600,
        parser: SerialPort.parsers.readline("\r\n")
    }
);

port.on("data", function(line) {
    try {
        var 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
  • GSA
  • GST
  • GSV
  • HDG
  • HDM
  • HDT
  • MTK
  • MWV
  • RDID
  • RMC
  • VHW
  • VTG

The following sentence types can be encoded by this library:

  • DBT
  • GGA
  • GLL
  • 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 and the documentation was expanded based on the excellent analysis and descriptions by Eric S. Raymond.

3.3.0

1 year ago

4.0.0-beta4

1 year ago

4.0.0-beta1

2 years ago

4.0.0-beta2

2 years ago

4.0.0-beta3

2 years ago

3.2.0

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.0

4 years ago

2.4.0

5 years ago

2.3.0

7 years ago

2.2.0

7 years ago

2.1.0

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.2

8 years ago

2.0.1-beta

8 years ago

2.0.0-beta

8 years ago

1.0.0

8 years ago