Skip to content

Instantly share code, notes, and snippets.

@joestrong
Created January 28, 2016 19:07
Show Gist options
  • Save joestrong/b96de35bdc3ae5c4b701 to your computer and use it in GitHub Desktop.
Save joestrong/b96de35bdc3ae5c4b701 to your computer and use it in GitHub Desktop.
Node get GPS data from GPSD
var gpsd = require('node-gpsd');
var gpsData = null;
var gpsListener = new gpsd.Listener({
port: 2947,
hostname: 'localhost'
});
function startGPS () {
gpsListener.connect();
gpsListener.watch();
gpsListener.on('TPV', function (tpvData) {
gpsData = tpvData;
console.log(gpsData.lat + " " + gpsData.lon);
});
}
function stopGPS () {
gpsListener.unwatch();
gpsListener.disconnect();
}
startGPS();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment