GithubHelp home page GithubHelp logo

nherment / node-nmea Goto Github PK

View Code? Open in Web Editor NEW

This project forked from snaewe/node-nmea-1

17.0 5.0 15.0 456 KB

extensible NMEA-0183 parser/encoder for node.js

License: MIT License

JavaScript 100.00%

node-nmea's Introduction

Build Status

nmea-0183

An extensible parser and encoder for NMEA-0183 sentences for use with node.js.

Features

  • runs under node.js

  • parses individual NMEA-0183 sentences

    (it doesn't read the serial or USB input. you have to get the sentences from somewhere yourself)

    has built-in support for several of the most common NMEA sentences

    GPGGA, GPRMC, GPGSA, GPGSV, GPVTG

    lets you add sentence parsers for those not built-in (there are literally dozens of standard and proprietary sentence types)

  • takes geographic location input and encodes it into valid NMEA-0183 sentences

API

the NMEA object

The NMEA object contains the user API functions that are used to decode and encode NMEA sentences, as well as lower level functions that are used to build additional decoder and encoder extensions. nmea = require('nmea-0183')

var GPGGASentence = "$GPGGA,123519,4807.038,N,01131.324,E,1,08,0.9,545.4,M,46.9,M, , *42"

var GPGGAObject = nmea.parse(GPGGASentence)

console.log(JSON.stringify(GPGGAObject, null, 2))

// result:
{
    "id": "GPGGA",
    "time": "123519",
    "latitude": "48.11730000",
    "longitude": "11.52206667",
    "fix": 1,
    "satellites": 8,
    "hdop": 0.9,
    "altitude": 545.4,
    "aboveGeoid": 46.9,
    "dgpsUpdate": "",
    "dgpsReference": ""
}

###error handling
function error(String) outputs null. this function is an error handler that is called by the library when an error is detected. returns null it receieves a string describing the error as input. the default handler outputs the error string generated by the library.

function setErrorHandler(function (String)) 
returns null
Sets the 'error' callback function for error handling. receives a string and does whatever. 

Examples

See tests

License

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-nmea's People

Contributors

dmh2000 avatar fnicollet avatar lumpanda avatar markcallen avatar nherment avatar sauloal avatar tjkurki avatar tonybentley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

node-nmea's Issues

longitude & latitude stored as strings?

Is there any reason why longitude & latitude are stored as strings, rather than as floats?

Using the following code, with the current latest

var sentences = [
   '$GPRMC,,V,,,,,,,,,,N*53',
   '$GPGGA,,,,,,0,00,99.99,,,,,,*48',
   '$GPGGA,182213.00,4531.14046,N,07334.85370,W,1,10,0.86,54.7,M,-32.6,M,,*58'
]

for (i=0; i<sentences.length; i++) {
    console.log(nmea.parse(sentences[i]));
}

I get the following results:

{ id: 'GPGGA',
  time: '',
  latitude: 'NaN',
  longitude: 'NaN',
  fix: 0,
  satellites: 0,
  hdop: 99.99,
  altitude: NaN,
  aboveGeoid: NaN,
  dgpsUpdate: '',
  dgpsReference: '' }
{ id: 'GPGGA',
  time: '182213.00',
  latitude: '45.51900767',
  longitude: '-73.58089500',
  fix: 1,
  satellites: 10,
  hdop: 0.86,
  altitude: 54.7,
  aboveGeoid: -32.6,
  dgpsUpdate: '',
  dgpsReference: '' }

Module reinstalling at every restart?

Every time I restart Node-RED I see the following in the syslog:

Sep 14 02:17:47 system Node-RED[5296]: [email protected] ../../tmp/d-117814-5296-1ap9h2g.p4r8/node_modules/nmea-0183
Sep 14 02:17:47 system Node-RED[5296]: 14 Sep 02:17:47 - [info] [npm:Parse] Downloaded and installed NPM module: nmea-0183

Any idea why that might be?

Error when long/lat are negative

This string: $GPGGA,134740.200,3403.130,N,-11814.617,E,1,12,1.0,0.0,M,0.0,M,,*4F

is not parsed correctly. Because the longitude parser just checks the number of characters to the left of the decimal point, it doesn't correctly interpret the value.

GSV sentence not handled correctly when there is only a single satellite present

The following sentence (which my Nokia LD-3W Bluetooth GPS dongle emitted today) results in a 'not enough tokens' error in the codes/GSV.js module.

$GPGSV,3,3,09,24,06,148,22*4D

According to this information http://www.gpsinformation.org/dale/nmea.htm#GSV there can be up to four satellites present in a GSV sentence. The above sentence only holds information for a single satellite. Which makes sense given the fact that there are 9 satellites and this is the third GSV sentence.
As far as I can tell the check done on line 9 of codes/GSV.js 'if(tokens.length < 13) {' should check for a minimum of 8 tokens. The current check assumes that there are at least two satellites 4 + 2x4 = 12 (plus a mysterious extra token??) tokens while there can be 4 +1x4 = 8 tokens when there is only one satellite.

error

hello
thanks for your work

got this error when try with nmea data from node-nmea
i'm using globalsat USB gps .


        throw new Error('ERROR:' + e);
        ^

Error: ERROR:i must be exactly 5 characters

any idea.??
thanks

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.