node-nan
v1.0.2
Published
The GPS library
Downloads
11
Readme
GPS library
The GPS library
Build it
$ npm install
Use it
This project is mainly created for Raspberry ARM boards.
const gps = require('./bindings')
The library mainly exposes few methods
Start(port)
- Initialize the communicationGetData
- Expose data from GPS (latitude, longitude, speed, course, altitude)Stop
- Turn off the GPS device
This project abstracts all datas and replies in:
- Decimal Degrees for latitudes and logitudes (46.235325, 7.12521)
- Not degrees (42° 53' 23.25'' North - 4° 22' 46.3'' West)
- Knots for speeds
- Degrees for angles (course)
- Meters for altitude
Example - Position logging
Create a simple positionLogger.js
const gps = require('./bindings')
gps.Start('/dev/ttyS2')
while(1)
console.log(gps.GetData())
Run it
$ node positionLogger.js
You will see your data directly in console:
{ latitude: 00.00000, longitude: 00.00000, speed: 10.0, altitude: 50, course: 152.093 }
{ latitude: 00.00000, longitude: 00.00000, speed: 12.0, altitude: 51, course: 152.099 }
{ latitude: 00.00000, longitude: 00.00000, speed: 13.0, altitude: 52, course: 152.092 }
{ latitude: 00.00000, longitude: 00.00000, speed: 11.0, altitude: 53, course: 152.096 }
{ latitude: 00.00000, longitude: 00.00000, speed: 16.0, altitude: 52, course: 152.095 }
Example - Position logging + callback
Create a simple positionLogger.js
const gps = require('./bindings')
gps.Start('/dev/ttyS2', (err) => {
if (err) throw err
})
while(1)
gps.GetData((err, data) => {
if (err) throw err
console.log(data)
})
Run it
$ node positionLogger.js
You will see your data directly in console:
{ latitude: 00.00000, longitude: 00.00000, speed: 10.0, altitude: 50, course: 152.093 }
{ latitude: 00.00000, longitude: 00.00000, speed: 12.0, altitude: 51, course: 152.099 }
{ latitude: 00.00000, longitude: 00.00000, speed: 13.0, altitude: 52, course: 152.092 }
{ latitude: 00.00000, longitude: 00.00000, speed: 11.0, altitude: 53, course: 152.096 }
{ latitude: 00.00000, longitude: 00.00000, speed: 16.0, altitude: 52, course: 152.095 }