@serialpilot/driver-gps
v0.1.0
Published
NMEA 0183 GPS receiver driver for serialpilot — parses GGA/RMC/GSA/GSV, emits typed fix events.
Maintainers
Readme
@serialpilot/driver-gps
NMEA 0183 GPS receiver driver for SerialPilot.
Parses GGA, RMC, GSA, and GSV sentences. Emits a typed 'fix' event composed from GGA + RMC arriving within a 1-second window. Surfaces bad sentences as 'parse-error' events instead of throwing. Talker-ID agnostic — $GP, $GN, $GL, $GA are all accepted.
Install
npm install serialpilot @serialpilot/driver-gpsQuick start
import { SerialPilot } from 'serialpilot'
import { Gps } from '@serialpilot/driver-gps'
const port = new SerialPilot({ path: '/dev/ttyUSB0', baudRate: 9600 })
const gps = new Gps({ transport: port })
gps.on('fix', fix => {
console.log(fix.lat, fix.lon, fix.altMeters, fix.speedKnots, fix.sats)
})
gps.on('parse-error', err => console.warn('bad sentence:', err.reason))
await gps.open()
await gps.start()
// later: await gps.stop(); await gps.close()Events
| Event | Payload | Notes |
| --- | --- | --- |
| 'fix' | Fix | Emitted when both GGA and RMC have arrived within 1000 ms |
| 'gsa' | Gsa | Per-sentence parse — DOPs and active satellites |
| 'gsv' | Gsv | Satellites in view |
| 'parse-error' | {reason, sentence} | Bad checksum, unknown sentence type, malformed field |
| Inherited | 'open' \| 'close' \| 'state' \| 'error' \| 'data' | From Device |
Limitations (v0.1)
- Read-only. No PMTK / UBX configuration writes.
- No
'fix'if only GGA arrives without an RMC inside the window (waits for both). - 1000 ms aggregation window default; configurable via
GpsOptions.fixWindowMs. stop()discards any buffered partial line so a subsequentstart()begins fresh.
License
MIT
