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

gps

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gps - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

2

bower.json
{
"name": "gps",
"main": "gps.js",
"version": "0.6.0",
"version": "0.6.1",
"homepage": "https://github.com/infusion/GPS.js",

@@ -6,0 +6,0 @@ "description": "A GPS NMEA parser library",

/**
* @license GPS.js v0.6.0 26/01/2016
* @license GPS.js v0.6.1 26/01/2016
*

@@ -306,3 +306,3 @@ * Copyright (c) 2016, Robert Eisele (robert@xarg.org)

this['events'] = {};
this['state'] = {'errors': 0, 'processed': 0};
this['state'] = { 'errors': 0, 'processed': 0 };
}

@@ -498,3 +498,6 @@

if (gsv.length % 4 % 3 === 0) {
if (gsv.length % 4 === 0) {
// = 1 -> normal package
// = 2 -> NMEA 4.10 extension
// = 3 -> BeiDou extension?
throw new Error('Invalid GSV length: ' + str);

@@ -544,3 +547,3 @@ }

'msgsTotal': parseNumber(gsv[1]),
//'satsInView' : parseNumber(gsv[3]), // Can be obtained by satellites.length
'satsInView': parseNumber(gsv[3]),
'satellites': sats,

@@ -598,3 +601,3 @@ 'signalId': gsv.length % 4 === 2 ? parseNumber(gsv[gsv.length - 2]) : null // NMEA 4.10 addition

'time': parseTime(zda[1], zda[2] + zda[3] + zda[4])
//'delta': time === null ? null : (Date.now() - time) / 1000
//'delta': time === null ? null : (Date.now() - time) / 1000
};

@@ -869,3 +872,8 @@ },

if (line.charAt(0) === '$') {
this['update'](line);
try {
this['update'](line);
} catch (err) {
this['partial'] = "";
throw new Error(err);
}
}

@@ -900,3 +908,3 @@ this['partial'] = this['partial'].slice(pos + 2);

if (typeof exports === 'object') {
Object.defineProperty(exports, "__esModule", {'value': true});
Object.defineProperty(GPS, "__esModule", { 'value': true });
GPS['default'] = GPS;

@@ -903,0 +911,0 @@ GPS['GPS'] = GPS;

/*
GPS.js v0.6.0 26/01/2016
GPS.js v0.6.1 26/01/2016

@@ -13,10 +13,10 @@ Copyright (c) 2016, Robert Eisele (robert@xarg.org)

vdop:e(a[17]),systemId:19<a.length?e(a[18]):null}},RMC:function(b,a){if(13!==a.length&&14!==a.length&&15!==a.length)throw Error("Invalid RMC length: "+b);var d=k(a[1],a[9]),c=r(a[2]),f=l(a[3],a[4]),h=l(a[5],a[6]),z=q(a[7]),A=e(a[8]),v=a[10],w=a[11];return{time:d,status:c,lat:f,lon:h,speed:z,track:A,variation:""===v||""===w?null:parseFloat(v)*("W"===w?-1:1),faa:13<a.length?n(a[12]):null,navStatus:14<a.length?a[13]:null}},VTG:function(b,a){if(10!==a.length&&11!==a.length)throw Error("Invalid VTG length: "+
b);if(""===a[2]&&""===a[8]&&""===a[6])return{track:null,trackMagetic:null,speed:null,faa:null};if("T"!==a[2])throw Error("Invalid VTG track mode: "+b);if("K"!==a[8]||"N"!==a[6])throw Error("Invalid VTG speed tag: "+b);return{track:e(a[1]),trackMagnetic:""===a[3]?null:e(a[3]),speed:q(a[5]),faa:11===a.length?n(a[9]):null}},GSV:function(b,a){if(0===a.length%4%3)throw Error("Invalid GSV length: "+b);for(var d=[],c=4;c<a.length-3;c+=4){var f=e(a[c]),h=e(a[c+3]);d.push({prn:f,elevation:e(a[c+1]),azimuth:e(a[c+
2]),snr:h,status:null!==f?null!==h?"tracking":"in view":null})}return{msgNumber:e(a[2]),msgsTotal:e(a[1]),satellites:d,signalId:2===a.length%4?e(a[a.length-2]):null}},GLL:function(b,a){if(9!==a.length&&8!==a.length)throw Error("Invalid GLL length: "+b);return{time:k(a[5]),status:r(a[6]),lat:l(a[1],a[2]),lon:l(a[3],a[4]),faa:9===a.length?n(a[7]):null}},ZDA:function(b,a){return{time:k(a[1],a[2]+a[3]+a[4])}},GST:function(b,a){if(10!==a.length)throw Error("Invalid GST length: "+b);return{time:k(a[1]),
rms:e(a[2]),ellipseMajor:e(a[3]),ellipseMinor:e(a[4]),ellipseOrientation:e(a[5]),latitudeError:e(a[6]),longitudeError:e(a[7]),heightError:e(a[8])}},HDT:function(b,a){if(4!==a.length)throw Error("Invalid HDT length: "+b);return{heading:parseFloat(a[1]),trueNorth:"T"===a[2]}},GRS:function(b,a){if(18!==a.length)throw Error("Invalid GRS length: "+b);for(var d=[],c=3;14>=c;c++){var f=e(a[c]);null!==f&&d.push(f)}return{time:k(a[1]),mode:e(a[2]),res:d}},GBS:function(b,a){if(10!==a.length&&12!==a.length)throw Error("Invalid GBS length: "+
b);return{time:k(a[1]),errLat:e(a[2]),errLon:e(a[3]),errAlt:e(a[4]),failedSat:e(a[5]),probFailedSat:e(a[6]),biasFailedSat:e(a[7]),stdFailedSat:e(a[8]),systemId:12===a.length?e(a[9]):null,signalId:12===a.length?e(a[10]):null}},GNS:function(b,a){if(14!==a.length&&15!==a.length)throw Error("Invalid GNS length: "+b);return{time:k(a[1]),lat:l(a[2],a[3]),lon:l(a[4],a[5]),mode:a[6],satsUsed:e(a[7]),hdop:e(a[8]),alt:e(a[9]),sep:e(a[10]),diffAge:e(a[11]),diffStation:e(a[12]),navStatus:15===a.length?a[13]:
null}}};g.Parse=function(b){if("string"!==typeof b)return!1;var a=b.split(","),d=a.pop();if(2>a.length||"$"!==b.charAt(0)||-1===d.indexOf("*"))return!1;d=d.split("*");a.push(d[0]);a.push(d[1]);a[0]=a[0].slice(3);if(void 0!==g.mod[a[0]]){d=this.mod[a[0]](b,a);d.raw=b;for(var c=0,f=1;f<b.length;f++){var h=b.charCodeAt(f);if(42===h)break;c^=h}d.valid=c===parseInt(a[a.length-1],16);d.type=a[0];return d}return!1};g.Heading=function(b,a,d,c){a=(c-a)*m;b*=m;d*=m;c=Math.cos(d);return(180*Math.atan2(Math.sin(a)*
c,Math.cos(b)*Math.sin(d)-Math.sin(b)*c*Math.cos(a))/Math.PI+360)%360};g.Distance=function(b,a,d,c){var f=(d-b)*m*.5;a=(c-a)*m*.5;b*=m;d*=m;f=Math.sin(f);a=Math.sin(a);return 12745.6*Math.asin(Math.sqrt(f*f+Math.cos(b)*Math.cos(d)*a*a))};g.TotalDistance=function(b){if(2>b.length)return 0;for(var a=0,d=0;d<b.length-1;d++){var c=b[d],f=b[d+1];a+=g.Distance(c.lat,c.lon,f.lat,f.lon)}return a};g.prototype.update=function(b){b=g.Parse(b);this.state.processed++;if(!1===b)return this.state.errors++,!1;var a=
this.state;if("RMC"===b.type||"GGA"===b.type||"GLL"===b.type||"GNS"===b.type)a.time=b.time,a.lat=b.lat,a.lon=b.lon;"ZDA"===b.type&&(a.time=b.time);"GGA"===b.type&&(a.alt=b.alt);"RMC"===b.type&&(a.speed=b.speed,a.track=b.track);"GSA"===b.type&&(a.satsActive=b.satellites,a.fix=b.fix,a.hdop=b.hdop,a.pdop=b.pdop,a.vdop=b.vdop);if("GSV"===b.type){for(var d=(new Date).getTime(),c=b.satellites,f=0;f<c.length;f++){var h=c[f].a;u[h]=d;p[h]=c[f]}c=[];for(h in p)3E3>d-u[h]&&c.push(p[h]);a.satsVisible=c}this.emit("data",
b);this.emit(b.type,b);return!0};g.prototype.partial="";g.prototype.updatePartial=function(b){for(this.partial+=b;;){b=this.partial.indexOf("\r\n");if(-1===b)break;var a=this.partial.slice(0,b);"$"===a.charAt(0)&&this.update(a);this.partial=this.partial.slice(b+2)}};g.prototype.on=function(b,a){return void 0===this.events[b]?(this.events[b]=a,this):null};g.prototype.off=function(b){void 0!==this.events[b]&&(this.events[b]=void 0);return this};g.prototype.emit=function(b,a){void 0!==this.events[b]&&
this.events[b].call(this,a)};"object"===typeof exports?(Object.defineProperty(exports,"__esModule",{value:!0}),g["default"]=g,g.GPS=g,module.exports=g):x.GPS=g})(this);
b);if(""===a[2]&&""===a[8]&&""===a[6])return{track:null,trackMagetic:null,speed:null,faa:null};if("T"!==a[2])throw Error("Invalid VTG track mode: "+b);if("K"!==a[8]||"N"!==a[6])throw Error("Invalid VTG speed tag: "+b);return{track:e(a[1]),trackMagnetic:""===a[3]?null:e(a[3]),speed:q(a[5]),faa:11===a.length?n(a[9]):null}},GSV:function(b,a){if(0===a.length%4)throw Error("Invalid GSV length: "+b);for(var d=[],c=4;c<a.length-3;c+=4){var f=e(a[c]),h=e(a[c+3]);d.push({prn:f,elevation:e(a[c+1]),azimuth:e(a[c+
2]),snr:h,status:null!==f?null!==h?"tracking":"in view":null})}return{msgNumber:e(a[2]),msgsTotal:e(a[1]),satsInView:e(a[3]),satellites:d,signalId:2===a.length%4?e(a[a.length-2]):null}},GLL:function(b,a){if(9!==a.length&&8!==a.length)throw Error("Invalid GLL length: "+b);return{time:k(a[5]),status:r(a[6]),lat:l(a[1],a[2]),lon:l(a[3],a[4]),faa:9===a.length?n(a[7]):null}},ZDA:function(b,a){return{time:k(a[1],a[2]+a[3]+a[4])}},GST:function(b,a){if(10!==a.length)throw Error("Invalid GST length: "+b);
return{time:k(a[1]),rms:e(a[2]),ellipseMajor:e(a[3]),ellipseMinor:e(a[4]),ellipseOrientation:e(a[5]),latitudeError:e(a[6]),longitudeError:e(a[7]),heightError:e(a[8])}},HDT:function(b,a){if(4!==a.length)throw Error("Invalid HDT length: "+b);return{heading:parseFloat(a[1]),trueNorth:"T"===a[2]}},GRS:function(b,a){if(18!==a.length)throw Error("Invalid GRS length: "+b);for(var d=[],c=3;14>=c;c++){var f=e(a[c]);null!==f&&d.push(f)}return{time:k(a[1]),mode:e(a[2]),res:d}},GBS:function(b,a){if(10!==a.length&&
12!==a.length)throw Error("Invalid GBS length: "+b);return{time:k(a[1]),errLat:e(a[2]),errLon:e(a[3]),errAlt:e(a[4]),failedSat:e(a[5]),probFailedSat:e(a[6]),biasFailedSat:e(a[7]),stdFailedSat:e(a[8]),systemId:12===a.length?e(a[9]):null,signalId:12===a.length?e(a[10]):null}},GNS:function(b,a){if(14!==a.length&&15!==a.length)throw Error("Invalid GNS length: "+b);return{time:k(a[1]),lat:l(a[2],a[3]),lon:l(a[4],a[5]),mode:a[6],satsUsed:e(a[7]),hdop:e(a[8]),alt:e(a[9]),sep:e(a[10]),diffAge:e(a[11]),diffStation:e(a[12]),
navStatus:15===a.length?a[13]:null}}};g.Parse=function(b){if("string"!==typeof b)return!1;var a=b.split(","),d=a.pop();if(2>a.length||"$"!==b.charAt(0)||-1===d.indexOf("*"))return!1;d=d.split("*");a.push(d[0]);a.push(d[1]);a[0]=a[0].slice(3);if(void 0!==g.mod[a[0]]){d=this.mod[a[0]](b,a);d.raw=b;for(var c=0,f=1;f<b.length;f++){var h=b.charCodeAt(f);if(42===h)break;c^=h}d.valid=c===parseInt(a[a.length-1],16);d.type=a[0];return d}return!1};g.Heading=function(b,a,d,c){a=(c-a)*m;b*=m;d*=m;c=Math.cos(d);
return(180*Math.atan2(Math.sin(a)*c,Math.cos(b)*Math.sin(d)-Math.sin(b)*c*Math.cos(a))/Math.PI+360)%360};g.Distance=function(b,a,d,c){var f=(d-b)*m*.5;a=(c-a)*m*.5;b*=m;d*=m;f=Math.sin(f);a=Math.sin(a);return 12745.6*Math.asin(Math.sqrt(f*f+Math.cos(b)*Math.cos(d)*a*a))};g.TotalDistance=function(b){if(2>b.length)return 0;for(var a=0,d=0;d<b.length-1;d++){var c=b[d],f=b[d+1];a+=g.Distance(c.lat,c.lon,f.lat,f.lon)}return a};g.prototype.update=function(b){b=g.Parse(b);this.state.processed++;if(!1===
b)return this.state.errors++,!1;var a=this.state;if("RMC"===b.type||"GGA"===b.type||"GLL"===b.type||"GNS"===b.type)a.time=b.time,a.lat=b.lat,a.lon=b.lon;"ZDA"===b.type&&(a.time=b.time);"GGA"===b.type&&(a.alt=b.alt);"RMC"===b.type&&(a.speed=b.speed,a.track=b.track);"GSA"===b.type&&(a.satsActive=b.satellites,a.fix=b.fix,a.hdop=b.hdop,a.pdop=b.pdop,a.vdop=b.vdop);if("GSV"===b.type){for(var d=(new Date).getTime(),c=b.satellites,f=0;f<c.length;f++){var h=c[f].g;u[h]=d;p[h]=c[f]}c=[];for(h in p)3E3>d-u[h]&&
c.push(p[h]);a.satsVisible=c}this.emit("data",b);this.emit(b.type,b);return!0};g.prototype.partial="";g.prototype.updatePartial=function(b){for(this.partial+=b;;){b=this.partial.indexOf("\r\n");if(-1===b)break;var a=this.partial.slice(0,b);if("$"===a.charAt(0))try{this.update(a)}catch(d){throw this.partial="",Error(d);}this.partial=this.partial.slice(b+2)}};g.prototype.on=function(b,a){return void 0===this.events[b]?(this.events[b]=a,this):null};g.prototype.off=function(b){void 0!==this.events[b]&&
(this.events[b]=void 0);return this};g.prototype.emit=function(b,a){void 0!==this.events[b]&&this.events[b].call(this,a)};"object"===typeof exports?(Object.defineProperty(g,"__esModule",{value:!0}),g["default"]=g,g.GPS=g,module.exports=g):x.GPS=g})(this);
{
"name": "gps",
"title": "gps.js",
"version": "0.6.0",
"version": "0.6.1",
"homepage": "https://www.xarg.org/2016/07/using-gps-with-node-js-and-javascript/",

@@ -49,7 +49,7 @@ "bugs": "https://github.com/infusion/GPS.js/issues",

"byline": "^5.0.0",
"chai": "^4.2.0",
"express": "^4.17.1",
"mocha": "^7.1.0",
"serialport": "^8.0.7",
"socket.io": "^2.3.0",
"chai": "^4.3.4",
"express": "^4.17.2",
"mocha": "^9.1.4",
"serialport": "^9.2.8",
"socket.io": "^4.4.1",
"kalman": "0.0.2",

@@ -56,0 +56,0 @@ "sylvester": "0.0.21"

@@ -17,6 +17,6 @@

```javascript
var gps = new GPS;
const gps = new GPS;
// Add an event listener on all protocols
gps.on('data', function(parsed) {
gps.on('data', parsed => {
console.log(parsed);

@@ -38,3 +38,3 @@ });

```javascript
gps.on('data', function() {
gps.on('data', () => {
console.log(gps.state);

@@ -63,4 +63,4 @@ });

```javascript
var obs = require('octalbonescript');
obs.serial.enable('/dev/ttyS1', function() {
const obs = require('octalbonescript');
obs.serial.enable('/dev/ttyS1', () => {
console.log('serial device activated');

@@ -79,18 +79,21 @@ });

```javascript
var SerialPort = require('serialport');
var port = new SerialPort.SerialPort('/dev/tty.usbserial', { // change path
baudrate: 4800,
parser: SerialPort.parsers.readline('\r\n')
const SerialPort = require('serialport');
const GPS = require('gps');
const port = new SerialPort('/dev/tty.usbmodem11401', { // change path
baudRate: 9600,
parser: new SerialPort.parsers.Readline({
delimiter: '\r\n'
})
});
var GPS = require('gps');
var gps = new GPS;
const gps = new GPS;
gps.on('data', function(data) {
gps.on('data', data => {
console.log(data, gps.state);
});
})
port.on('data', function(data) {
port.on('data', data => {
gps.updatePartial(data);
});
})
```

@@ -106,3 +109,3 @@

After that you can open the browser and go to http://localhost:3000. The result should look like the following, which in principle is just a visualiziation of the state object `gps.state`
After that you can open the browser and go to http://localhost:3000. The result should look like the following, which in principle is just a visualization of the state object `gps.state`

@@ -334,3 +337,3 @@ ![GPS TU Dresden](https://github.com/infusion/GPS.js/blob/master/res/dashboard.png?raw=true)

```javascript
var angles = require('angles');
const angles = require('angles');
console.log(angles.compass(GPS.Heading(50, 10, 51, 9))); // will return x ∈ { N, S, E, W, NE, ... }

@@ -337,0 +340,0 @@ ```

@@ -103,2 +103,3 @@

'msgsTotal': 3,
"satsInView": 12,
'signalId': null,

@@ -180,2 +181,3 @@ 'satellites': [

'msgsTotal': 3,
"satsInView": 11,
'signalId': null,

@@ -263,2 +265,3 @@ 'raw': '$GPGSV,3,1,11,10,63,137,17,07,61,098,15,05,59,290,20,08,54,157,30*70',

'msgsTotal': 3,
"satsInView": 11,
'signalId': null,

@@ -299,2 +302,3 @@ 'raw': '$GPGSV,3,1,11,03,03,111,00,04,15,270,00,06,01,010,00,13,06,292,00*74',

'msgsTotal': 3,
"satsInView": 11,
'signalId': null,

@@ -335,2 +339,3 @@ 'raw': '$GPGSV,3,2,11,14,25,170,00,16,57,208,39,18,67,296,40,19,40,246,00*2D',

'msgsTotal': 3,
"satsInView": 11,
'signalId': null,

@@ -371,2 +376,3 @@ 'raw': '$GPGSV,3,2,11,02,39,223,16,13,28,070,17,26,23,252,,04,14,186,15*77',

'msgsTotal': 3,
"satsInView": 11,
'signalId': null,

@@ -585,2 +591,3 @@ 'raw': '$GPGSV,3,3,11,29,09,301,24,16,09,020,,36,,,*76',

],
"satsInView": 11,
"signalId": 1,

@@ -603,2 +610,3 @@ "type": "GSV",

],
"satsInView": 9,
"signalId": 7,

@@ -639,2 +647,3 @@ "type": "GSV",

],
"satsInView": 12,
"signalId": 6,

@@ -675,2 +684,3 @@ "type": "GSV",

],
"satsInView": 11,
"signalId": 7,

@@ -711,2 +721,3 @@ "type": "GSV",

],
"satsInView": 4,
"signalId": 1,

@@ -923,3 +934,3 @@ "type": "GSV",

"valid": true
},
},
'$GPGGA,034030,1227.2475,S,13050.8528,E,2,6,0.9,8.1,M,,M*72': {

@@ -939,6 +950,102 @@ "age": 72,

"valid": true
},
'$BDGSV,4,1,16,01,,,37,02,,,38,03,,,39,05,,,37,0,4*6A': {
"msgNumber": 1,
"msgsTotal": 4,
"raw": "$BDGSV,4,1,16,01,,,37,02,,,38,03,,,39,05,,,37,0,4*6A",
"satellites": [{
"azimuth": null,
"elevation": null,
"prn": 1,
"snr": 37,
"status": "tracking"
}, {
"azimuth": null,
"elevation": null,
"prn": 2,
"snr": 38,
"status": "tracking"
}, {
"azimuth": null,
"elevation": null,
"prn": 3,
"snr": 39,
"status": "tracking"
}, {
"azimuth": null,
"elevation": null,
"prn": 5,
"snr": 37,
"status": "tracking"
}],
"satsInView": 16,
"signalId": null,
"type": "GSV",
"valid": true
},
'$BDGSV,1,1,03,10,46,329,31,08,43,161,,09,40,217,*52': {
"msgNumber": 1,
"msgsTotal": 1,
"raw": "$BDGSV,1,1,03,10,46,329,31,08,43,161,,09,40,217,*52",
"satellites": [{
"azimuth": 329,
"elevation": 46,
"prn": 10,
"snr": 31,
"status": "tracking"
}, {
"azimuth": 161,
"elevation": 43,
"prn": 8,
"snr": null,
"status": "in view"
}, {
"azimuth": 217,
"elevation": 40,
"prn": 9,
"snr": null,
"status": "in view"
}],
"satsInView": 3,
"signalId": null,
"type": "GSV",
"valid": true
},
'$BDGSV,2,1,06,211,18,305,36,205,07,113,,206,04,029,,209,30,046,*67': {
"msgNumber": 1,
"msgsTotal": 2,
"raw": "$BDGSV,2,1,06,211,18,305,36,205,07,113,,206,04,029,,209,30,046,*67",
"satellites": [{
"azimuth": 305,
"elevation": 18,
"prn": 211,
"snr": 36,
"status": "tracking"
}, {
"azimuth": 113,
"elevation": 7,
"prn": 205,
"snr": null,
"status": "in view"
}, {
"azimuth": 29,
"elevation": 4,
"prn": 206,
"snr": null,
"status": "in view"
}, {
"azimuth": 46,
"elevation": 30,
"prn": 209,
"snr": null,
"status": "in view"
}],
"satsInView": 6,
"signalId": null,
"type": "GSV",
"valid": true
}
};
var collect = {};
gps.on('data', function(data) {
gps.on('data', function (data) {

@@ -954,9 +1061,9 @@ collect[data.raw] = data;

describe('NMEA syntax', function() {
describe('NMEA syntax', function () {
for (var i in collect) {
(function(i) {
(function (i) {
it('Should pass ' + i, function() {
it('Should pass ' + i, function () {
expect(collect[i]).to.deep.equal(tests[i]);

@@ -963,0 +1070,0 @@ });

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