1.0.2 • Published 6 years ago

node-nan v1.0.2

Weekly downloads
15
License
-
Repository
-
Last release
6 years ago

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 communication
  • GetData - 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 }
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago