{"id":20174690,"url":"https://github.com/eelcocramer/node-gpsd","last_synced_at":"2025-05-08T23:46:36.759Z","repository":{"id":3180699,"uuid":"4212606","full_name":"eelcocramer/node-gpsd","owner":"eelcocramer","description":"Node.js gpsd client for GPS tracking device.","archived":false,"fork":false,"pushed_at":"2022-09-28T13:55:31.000Z","size":45,"stargazers_count":69,"open_issues_count":0,"forks_count":33,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-31T19:37:16.994Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eelcocramer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-03T09:49:05.000Z","updated_at":"2025-03-14T01:43:12.000Z","dependencies_parsed_at":"2023-01-11T16:15:01.367Z","dependency_job_id":null,"html_url":"https://github.com/eelcocramer/node-gpsd","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelcocramer%2Fnode-gpsd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelcocramer%2Fnode-gpsd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelcocramer%2Fnode-gpsd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eelcocramer%2Fnode-gpsd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eelcocramer","download_url":"https://codeload.github.com/eelcocramer/node-gpsd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252396666,"owners_count":21741262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T01:43:22.536Z","updated_at":"2025-05-08T23:46:36.742Z","avatar_url":"https://github.com/eelcocramer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-gpsd\n\nInterface to [gpsd](http://www.catb.org/gpsd/).\n\n## Installation\n\nWith package manager [npm](http://npmjs.org/):\n\n\tnpm install node-gpsd\n\n## Code instructions\n\nRequire `node-gpsd` by calling:\n\n```javascript\n    var gpsd = require('node-gpsd');\n```\n\n`node-gpsd` has 2 classes: `Daemon` and `Listener`.\n\nThe `Daemon` is a wrapper to start and stop `gpsd` from your program. The `Listener` interfaces with a running `gpsd` (not necessarily instantiated via the `Daemon` class).\n\n#### Deamon\n\nA `Daemon` is instantiated by calling:\n\n```javascript\nvar daemon = new gpsd.Daemon({\n    program: 'gpsd',\n    device: '/dev/ttyUSB0',\n    port: 2947,\n    pid: '/tmp/gpsd.pid',\n    readOnly: false,\n    logger: {\n        info: function() {},\n        warn: console.warn,\n        error: console.error\n    }\n});\n```\n\nThe options that are listed above are the default values so calling `new gpsd.Daemon()` will have the same effect. Change the options according your own setup.\n\nThe `Daemon` can be started and stopped by calling the appropriate methods:\n\n```javascript\ndaemon.start(function() {\n    console.log('Started');\n});\n```\n\nor:\n\n```javascript\ndaemon.stop(function() {\n    console.log('Stopped');\n});\n```\n\nThe `Daemon` can log to the console if needed. Logging can be controlled by passing a `logger` property in the options when creating the `Daemon` or by setting the logger field:\n\n```javascript\ndaemon.logger = new (winston.Logger) ({ exitOnError: false });\n```\n\nThe logger should have `info`, `warn` and `error` functions that all accept a single parameter.\n\nThe `Daemon` is an [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter) and will emit the following events:\n\n* `died`: when the `Daemon` is killed.\n\n#### Listener\n\nA `Listener` is instantiated by calling:\n\n```javascript\nvar listener = new gpsd.Listener({\n    port: 2947,\n    hostname: 'localhost',\n    logger:  {\n        info: function() {},\n        warn: console.warn,\n        error: console.error\n    },\n    parse: true\n});\n```\n\nThe options that are listed above are the default values so calling `new gpsd.Listener()` will have the same effect. Change the options according your own setup.\n\nThe `Listener` can be connected to the `gpsd` by calling:\n\n```javascript\nlistener.connect(function() {\n    console.log('Connected');\n});\n```\n\nand disconnected by calling:\n\n```javascript\nlistener.disconnect(function() {\n    console.log('Disconnected');\n});\n```\n\nThe connection state can be queries by calling:\n\n```javascript\nlistener.isConnected();\n```\n\nTo control watching gps events call the methods:\n\n```javascript\nlistener.watch(options);\nlistener.unwatch();\n```\n\nThis will put the `Listener` in and out-of watching mode. The `Listener` is an [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter) and will emit the following events:\n\n* `gpsd` events like described in the [gpsd documentation](http://www.catb.org/gpsd/gpsd_json.html). All `gpsd` events like: `TPV`, `SKY`, `INFO` and `DEVICE` can be emitted. To receive all `TPV` events just add `listener.on('TPV', function(tpvData))` to your code. When the `parse` option is set to false these events will not be emitted.\n* `raw` events contain the raw, unparsed input received from gpsd. Only emitted if `parse` option is set to false.\n* `error` when data in a bad format is received from `gpsd`.\n* `disconnected` when the connection with `gpsd` is lost.\n* `connected` when the connection with `gpsd` is established.\n* `error.connection` when the connection is refused.\n* `error.socket` on other connection errors.\n\nYou can pass options to be sent on to gpsd when issuing the watch command, the default being `{ class: 'WATCH', json: true, nmea: false }`.\n\nIf you want to receive raw nmea data from gpsd you should create the listener with `new gpsd.Listener({emitraw: true, parsejson: false})` and issue `listener.watch({class: 'WATCH', nmea: true})`.\n\nIt is possible to query the gps device by calling:\n\n```javascript\nlistener.version(); /* a INFO event will be emitted */\nlistener.devices(); /* a DEVICES event will be emitted */\nlistener.device(); /* a DEVICE event will be emitted */\n```\n\nThe `Listener` can log to the console if needed. Logging can be controlled by passing a `logger` property in the options when creating the `Listener` or by setting the logger field:\n\n```javascript\nlistener.logger = new (winston.Logger) ({ exitOnError: false });;\n```\n\n## Shout outs\n\nShout outs go to [Pascal Deschenes](http://github.com/pdeschen) for creating the [Bancroft](http://github.com/pdeschen/bancroft) project that formed the basis for `node-gpsd`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feelcocramer%2Fnode-gpsd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feelcocramer%2Fnode-gpsd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feelcocramer%2Fnode-gpsd/lists"}