@signalk/streams 2.3.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gpsd.js +14 -9
- package/package.json +3 -3
- package/serialport.js +5 -3
package/gpsd.js
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
const Transform = require('stream').Transform
|
|
34
|
-
const
|
|
34
|
+
const GpsdClient = require('node-gpsd-client')
|
|
35
35
|
|
|
36
36
|
function Gpsd(options) {
|
|
37
37
|
Transform.call(this, {
|
|
@@ -40,6 +40,7 @@ function Gpsd(options) {
|
|
|
40
40
|
|
|
41
41
|
const port = options.port || 2947
|
|
42
42
|
const hostname = options.hostname || options.host || 'localhost'
|
|
43
|
+
const noDataReceivedTimeout = options.noDataReceivedTimeout || 0
|
|
43
44
|
|
|
44
45
|
function setProviderStatus(msg) {
|
|
45
46
|
options.app.setProviderStatus(options.providerId, msg)
|
|
@@ -47,9 +48,9 @@ function Gpsd(options) {
|
|
|
47
48
|
|
|
48
49
|
const createDebug = options.createDebug || require('debug')
|
|
49
50
|
|
|
50
|
-
this.listener = new
|
|
51
|
-
port,
|
|
52
|
-
hostname,
|
|
51
|
+
this.listener = new GpsdClient({
|
|
52
|
+
port: port,
|
|
53
|
+
hostname: hostname,
|
|
53
54
|
logger: {
|
|
54
55
|
info: createDebug('signalk:streams:gpsd'),
|
|
55
56
|
warn: console.warn,
|
|
@@ -61,12 +62,19 @@ function Gpsd(options) {
|
|
|
61
62
|
},
|
|
62
63
|
},
|
|
63
64
|
parse: false,
|
|
65
|
+
reconnectThreshold: noDataReceivedTimeout,
|
|
66
|
+
reconnectInterval: noDataReceivedTimeout / 2,
|
|
64
67
|
})
|
|
65
68
|
|
|
66
69
|
setProviderStatus(`Connecting to ${hostname}:${port}`)
|
|
67
70
|
|
|
68
|
-
this.listener.
|
|
71
|
+
this.listener.on('connected', () => {
|
|
69
72
|
setProviderStatus(`Connected to ${hostname}:${port}`)
|
|
73
|
+
this.listener.watch({
|
|
74
|
+
class: 'WATCH',
|
|
75
|
+
nmea: true,
|
|
76
|
+
json: false,
|
|
77
|
+
})
|
|
70
78
|
})
|
|
71
79
|
|
|
72
80
|
const self = this
|
|
@@ -74,10 +82,7 @@ function Gpsd(options) {
|
|
|
74
82
|
self.push(data)
|
|
75
83
|
})
|
|
76
84
|
|
|
77
|
-
this.listener.
|
|
78
|
-
class: 'WATCH',
|
|
79
|
-
nmea: true,
|
|
80
|
-
})
|
|
85
|
+
this.listener.connect()
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
require('util').inherits(Gpsd, Transform)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signalk/streams",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Utilities for handling streams of Signal K data",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"file-timestamp-stream": "^2.1.2",
|
|
33
33
|
"lodash": "^4.17.4",
|
|
34
34
|
"moment": "^2.24.0",
|
|
35
|
-
"node-gpsd": "^
|
|
35
|
+
"node-gpsd-client": "^1.4.1",
|
|
36
36
|
"reconnect-core": "^1.3.0",
|
|
37
37
|
"stream-throttle": "^0.1.3"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
|
-
"serialport": "^
|
|
40
|
+
"serialport": "^11.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"prettier": "2.5.1"
|
package/serialport.js
CHANGED
|
@@ -60,7 +60,8 @@
|
|
|
60
60
|
const Transform = require('stream').Transform
|
|
61
61
|
const child_process = require('child_process')
|
|
62
62
|
const shellescape = require('any-shell-escape')
|
|
63
|
-
const SerialPort = require('serialport')
|
|
63
|
+
const { SerialPort } = require('serialport')
|
|
64
|
+
const { ReadlineParser } = require('@serialport/parser-readline')
|
|
64
65
|
const isArray = require('lodash').isArray
|
|
65
66
|
const isBuffer = require('lodash').isBuffer
|
|
66
67
|
|
|
@@ -104,7 +105,8 @@ SerialStream.prototype.start = function () {
|
|
|
104
105
|
)
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
this.serial = new SerialPort(
|
|
108
|
+
this.serial = new SerialPort({
|
|
109
|
+
path: this.options.device,
|
|
108
110
|
baudRate: this.options.baudrate,
|
|
109
111
|
})
|
|
110
112
|
|
|
@@ -117,7 +119,7 @@ SerialStream.prototype.start = function () {
|
|
|
117
119
|
`Connected to ${this.options.device}`
|
|
118
120
|
)
|
|
119
121
|
this.isFirstError = true
|
|
120
|
-
const parser = new
|
|
122
|
+
const parser = new ReadlineParser()
|
|
121
123
|
this.serial.pipe(parser).pipe(this)
|
|
122
124
|
}.bind(this)
|
|
123
125
|
)
|