@signalk/streams 4.4.1 → 4.5.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/autodetect.js +2 -2
- package/canboatjs.js +1 -1
- package/execute.js +0 -1
- package/folderstream.js +1 -1
- package/from_json.js +2 -2
- package/gpsd.js +4 -4
- package/keys-filter.js +5 -5
- package/liner.js +1 -1
- package/log.js +1 -5
- package/logging.js +2 -2
- package/mdns-ws.js +5 -8
- package/n2k-signalk.js +10 -10
- package/n2kAnalyzer.js +3 -3
- package/nmea0183-signalk.js +1 -1
- package/nullprovider.js +2 -2
- package/package.json +1 -4
- package/replacer.js +1 -1
- package/s3.js +4 -4
- package/serialport.js +2 -2
- package/simple.js +34 -35
- package/splitting-liner.js +1 -1
- package/tcp.js +3 -3
- package/timestamp-throttle.js +1 -1
- package/udp.js +2 -2
- package/.prettierrc.json +0 -4
package/autodetect.js
CHANGED
|
@@ -50,7 +50,7 @@ function DeMultiplexer(options) {
|
|
|
50
50
|
|
|
51
51
|
this.toTimestamped = new ToTimestamped(this, options)
|
|
52
52
|
this.timestampThrottle = new TimestampThrottle({
|
|
53
|
-
getMilliseconds: (msg) => msg.timestamp
|
|
53
|
+
getMilliseconds: (msg) => msg.timestamp
|
|
54
54
|
})
|
|
55
55
|
this.splitter = new Splitter(this, options)
|
|
56
56
|
this.options = options
|
|
@@ -190,7 +190,7 @@ ToTimestamped.prototype.handleMultiplexed = function (msg, encoding, done) {
|
|
|
190
190
|
this.push({
|
|
191
191
|
timestamp: parts[0],
|
|
192
192
|
discriminator: parts[1],
|
|
193
|
-
data: parts.slice(2).join(';')
|
|
193
|
+
data: parts.slice(2).join(';')
|
|
194
194
|
})
|
|
195
195
|
done()
|
|
196
196
|
}
|
package/canboatjs.js
CHANGED
package/execute.js
CHANGED
package/folderstream.js
CHANGED
package/from_json.js
CHANGED
|
@@ -29,7 +29,7 @@ const Transform = require('stream').Transform
|
|
|
29
29
|
|
|
30
30
|
function FromJson() {
|
|
31
31
|
Transform.call(this, {
|
|
32
|
-
objectMode: true
|
|
32
|
+
objectMode: true
|
|
33
33
|
})
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -39,7 +39,7 @@ FromJson.prototype._transform = function (chunk, encoding, done) {
|
|
|
39
39
|
let parsed = null
|
|
40
40
|
try {
|
|
41
41
|
parsed = JSON.parse(chunk.toString())
|
|
42
|
-
} catch (
|
|
42
|
+
} catch (_) {
|
|
43
43
|
console.error('Could not parse JSON:' + chunk.toString())
|
|
44
44
|
}
|
|
45
45
|
if (parsed) {
|
package/gpsd.js
CHANGED
|
@@ -35,7 +35,7 @@ const GpsdClient = require('node-gpsd-client')
|
|
|
35
35
|
|
|
36
36
|
function Gpsd(options) {
|
|
37
37
|
Transform.call(this, {
|
|
38
|
-
objectMode: true
|
|
38
|
+
objectMode: true
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
const port = options.port || 2947
|
|
@@ -59,11 +59,11 @@ function Gpsd(options) {
|
|
|
59
59
|
options.providerId,
|
|
60
60
|
`${hostname}:${port}: ` + msg
|
|
61
61
|
)
|
|
62
|
-
}
|
|
62
|
+
}
|
|
63
63
|
},
|
|
64
64
|
parse: false,
|
|
65
65
|
reconnectThreshold: noDataReceivedTimeout,
|
|
66
|
-
reconnectInterval: noDataReceivedTimeout / 2
|
|
66
|
+
reconnectInterval: noDataReceivedTimeout / 2
|
|
67
67
|
})
|
|
68
68
|
|
|
69
69
|
setProviderStatus(`Connecting to ${hostname}:${port}`)
|
|
@@ -73,7 +73,7 @@ function Gpsd(options) {
|
|
|
73
73
|
this.listener.watch({
|
|
74
74
|
class: 'WATCH',
|
|
75
75
|
nmea: true,
|
|
76
|
-
json: false
|
|
76
|
+
json: false
|
|
77
77
|
})
|
|
78
78
|
})
|
|
79
79
|
|
package/keys-filter.js
CHANGED
|
@@ -4,7 +4,7 @@ const Transform = require('stream').Transform
|
|
|
4
4
|
|
|
5
5
|
function ToSignalK(options) {
|
|
6
6
|
Transform.call(this, {
|
|
7
|
-
objectMode: true
|
|
7
|
+
objectMode: true
|
|
8
8
|
})
|
|
9
9
|
|
|
10
10
|
const createDebug = options.createDebug || require('debug')
|
|
@@ -44,18 +44,18 @@ ToSignalK.prototype._transform = function (chunk, encoding, done) {
|
|
|
44
44
|
|
|
45
45
|
if (values.length > 0) {
|
|
46
46
|
const upd = {
|
|
47
|
-
values
|
|
47
|
+
values
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
if (update
|
|
50
|
+
if (update.$source) {
|
|
51
51
|
upd.$source = update.$source
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
if (update.
|
|
54
|
+
if (update.source) {
|
|
55
55
|
upd.source = update.source
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
if (update.
|
|
58
|
+
if (update.timestamp) {
|
|
59
59
|
upd.timestamp = update.timestamp
|
|
60
60
|
}
|
|
61
61
|
|
package/liner.js
CHANGED
package/log.js
CHANGED
|
@@ -34,7 +34,7 @@ const getLogger = require('./logging').getLogger
|
|
|
34
34
|
|
|
35
35
|
function Log(options) {
|
|
36
36
|
Transform.call(this, {
|
|
37
|
-
objectMode: true
|
|
37
|
+
objectMode: true
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
this.logger = getLogger(options.app, options.discriminator, options.logdir)
|
|
@@ -48,8 +48,4 @@ Log.prototype._transform = function (msg, encoding, done) {
|
|
|
48
48
|
done()
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
function pad(num) {
|
|
52
|
-
return (num > 9 ? '' : '0') + num
|
|
53
|
-
}
|
|
54
|
-
|
|
55
51
|
module.exports = Log
|
package/logging.js
CHANGED
|
@@ -20,13 +20,13 @@ let debug = require('debug')('signalk:streams:logging')
|
|
|
20
20
|
const fs = require('fs')
|
|
21
21
|
const { isUndefined } = require('lodash')
|
|
22
22
|
|
|
23
|
-
const filenamePattern = /skserver
|
|
23
|
+
const filenamePattern = /skserver-raw_\d\d\d\d-\d\d-\d\dT\d\d\.log/
|
|
24
24
|
const loggers = {}
|
|
25
25
|
|
|
26
26
|
module.exports = {
|
|
27
27
|
getLogger,
|
|
28
28
|
getFullLogDir,
|
|
29
|
-
listLogFiles
|
|
29
|
+
listLogFiles
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
class FileTimestampStreamWithDelete extends FileTimestampStream {
|
package/mdns-ws.js
CHANGED
|
@@ -18,11 +18,9 @@ const Transform = require('stream').Transform
|
|
|
18
18
|
|
|
19
19
|
const SignalK = require('@signalk/client')
|
|
20
20
|
|
|
21
|
-
const WebSocket = require('ws')
|
|
22
|
-
|
|
23
21
|
function MdnsWs(options) {
|
|
24
22
|
Transform.call(this, {
|
|
25
|
-
objectMode: true
|
|
23
|
+
objectMode: true
|
|
26
24
|
})
|
|
27
25
|
this.options = options
|
|
28
26
|
this.selfHost = options.app.config.getExternalHostname() + '.'
|
|
@@ -67,7 +65,7 @@ function MdnsWs(options) {
|
|
|
67
65
|
autoConnect: false,
|
|
68
66
|
deltaStreamBehaviour,
|
|
69
67
|
rejectUnauthorized: !(options.selfsignedcert === true),
|
|
70
|
-
wsKeepaliveInterval: 10
|
|
68
|
+
wsKeepaliveInterval: 10
|
|
71
69
|
})
|
|
72
70
|
this.connect(this.signalkClient)
|
|
73
71
|
} else {
|
|
@@ -155,9 +153,8 @@ MdnsWs.prototype.connect = function (client) {
|
|
|
155
153
|
that.dataDebug(JSON.stringify(data))
|
|
156
154
|
}
|
|
157
155
|
data.updates.forEach(function (update) {
|
|
158
|
-
update[
|
|
159
|
-
|
|
160
|
-
] = `${that.options.providerId}.${client.options.hostname}:${client.options.port}`
|
|
156
|
+
update['$source'] =
|
|
157
|
+
`${that.options.providerId}.${client.options.hostname}:${client.options.port}`
|
|
161
158
|
})
|
|
162
159
|
}
|
|
163
160
|
|
|
@@ -165,6 +162,6 @@ MdnsWs.prototype.connect = function (client) {
|
|
|
165
162
|
})
|
|
166
163
|
}
|
|
167
164
|
|
|
168
|
-
MdnsWs.prototype._transform = function (
|
|
165
|
+
MdnsWs.prototype._transform = function () {}
|
|
169
166
|
|
|
170
167
|
module.exports = MdnsWs
|
package/n2k-signalk.js
CHANGED
|
@@ -22,7 +22,7 @@ require('util').inherits(ToSignalK, Transform)
|
|
|
22
22
|
|
|
23
23
|
function ToSignalK(options) {
|
|
24
24
|
Transform.call(this, {
|
|
25
|
-
objectMode: true
|
|
25
|
+
objectMode: true
|
|
26
26
|
})
|
|
27
27
|
const n2kOutEvent = 'nmea2000JsonOut'
|
|
28
28
|
this.sourceMeta = {}
|
|
@@ -43,7 +43,7 @@ function ToSignalK(options) {
|
|
|
43
43
|
const existing = this.sourceMeta[n2k.src] || {}
|
|
44
44
|
this.sourceMeta[n2k.src] = {
|
|
45
45
|
...existing,
|
|
46
|
-
...meta
|
|
46
|
+
...meta
|
|
47
47
|
}
|
|
48
48
|
const delta = {
|
|
49
49
|
context: this.app.selfContext,
|
|
@@ -54,15 +54,15 @@ function ToSignalK(options) {
|
|
|
54
54
|
label: this.options.providerId,
|
|
55
55
|
type: 'NMEA2000',
|
|
56
56
|
pgn: Number(n2k.pgn),
|
|
57
|
-
src: n2k.src.toString()
|
|
57
|
+
src: n2k.src.toString()
|
|
58
58
|
},
|
|
59
59
|
timestamp:
|
|
60
60
|
n2k.timestamp.substring(0, 10) +
|
|
61
61
|
'T' +
|
|
62
62
|
n2k.timestamp.substring(11, n2k.timestamp.length),
|
|
63
|
-
values: []
|
|
64
|
-
}
|
|
65
|
-
]
|
|
63
|
+
values: []
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
66
|
}
|
|
67
67
|
this.app.deltaCache.setSourceDelta(
|
|
68
68
|
`${this.options.providerId}.${n2k.src}`,
|
|
@@ -164,9 +164,9 @@ ToSignalK.prototype._transform = function (chunk, encoding, done) {
|
|
|
164
164
|
updates: [
|
|
165
165
|
{
|
|
166
166
|
source: update.source,
|
|
167
|
-
values: [copy]
|
|
168
|
-
}
|
|
169
|
-
]
|
|
167
|
+
values: [copy]
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
170
|
}
|
|
171
171
|
delete this.notifications[kv.path][src]
|
|
172
172
|
clearInterval(interval)
|
|
@@ -175,7 +175,7 @@ ToSignalK.prototype._transform = function (chunk, encoding, done) {
|
|
|
175
175
|
}, 5000)
|
|
176
176
|
this.notifications[kv.path][src] = {
|
|
177
177
|
lastTime: Date.now(),
|
|
178
|
-
interval: interval
|
|
178
|
+
interval: interval
|
|
179
179
|
}
|
|
180
180
|
} else {
|
|
181
181
|
this.notifications[kv.path][src].lastTime = Date.now()
|
package/n2kAnalyzer.js
CHANGED
|
@@ -18,7 +18,7 @@ const Transform = require('stream').Transform
|
|
|
18
18
|
|
|
19
19
|
function N2KAnalyzer(options) {
|
|
20
20
|
Transform.call(this, {
|
|
21
|
-
objectMode: true
|
|
21
|
+
objectMode: true
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
this.analyzerOutEvent = options.analyzerOutEvent || 'N2KAnalyzerOut'
|
|
@@ -26,12 +26,12 @@ function N2KAnalyzer(options) {
|
|
|
26
26
|
if (process.platform === 'win32') {
|
|
27
27
|
this.analyzerProcess = require('child_process').spawn('cmd', [
|
|
28
28
|
'/c',
|
|
29
|
-
'analyzer -json -si'
|
|
29
|
+
'analyzer -json -si'
|
|
30
30
|
])
|
|
31
31
|
} else {
|
|
32
32
|
this.analyzerProcess = require('child_process').spawn('sh', [
|
|
33
33
|
'-c',
|
|
34
|
-
'analyzer -json -si'
|
|
34
|
+
'analyzer -json -si'
|
|
35
35
|
])
|
|
36
36
|
}
|
|
37
37
|
this.analyzerProcess.stderr.on('data', function (data) {
|
package/nmea0183-signalk.js
CHANGED
|
@@ -37,7 +37,7 @@ const FromPgn = require('@canboat/canboatjs').FromPgn
|
|
|
37
37
|
|
|
38
38
|
function Nmea0183ToSignalK(options) {
|
|
39
39
|
Transform.call(this, {
|
|
40
|
-
objectMode: true
|
|
40
|
+
objectMode: true
|
|
41
41
|
})
|
|
42
42
|
this.debug = (options.createDebug || require('debug'))(
|
|
43
43
|
'signalk:streams:nmea0183-signalk'
|
package/nullprovider.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signalk/streams",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Utilities for handling streams of Signal K data",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -38,8 +38,5 @@
|
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
40
|
"serialport": "^11.0.0"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"prettier": "2.5.1"
|
|
44
41
|
}
|
|
45
42
|
}
|
package/replacer.js
CHANGED
package/s3.js
CHANGED
|
@@ -27,7 +27,7 @@ const AWS = require('aws-sdk')
|
|
|
27
27
|
|
|
28
28
|
function S3Provider({ bucket, prefix }) {
|
|
29
29
|
Transform.call(this, {
|
|
30
|
-
objectMode: false
|
|
30
|
+
objectMode: false
|
|
31
31
|
})
|
|
32
32
|
this.Bucket = bucket
|
|
33
33
|
this.Prefix = prefix
|
|
@@ -41,7 +41,7 @@ S3Provider.prototype.pipe = function (pipeTo) {
|
|
|
41
41
|
const s3 = new AWS.S3()
|
|
42
42
|
const params = {
|
|
43
43
|
Bucket: this.Bucket,
|
|
44
|
-
Prefix: this.Prefix
|
|
44
|
+
Prefix: this.Prefix
|
|
45
45
|
}
|
|
46
46
|
console.log('listobjects')
|
|
47
47
|
s3.listObjects(params)
|
|
@@ -51,11 +51,11 @@ S3Provider.prototype.pipe = function (pipeTo) {
|
|
|
51
51
|
const jobs = data.Contents.map(
|
|
52
52
|
(item, i) =>
|
|
53
53
|
function () {
|
|
54
|
-
return new Promise((resolve
|
|
54
|
+
return new Promise((resolve) => {
|
|
55
55
|
console.log('Starting key ' + item.Key)
|
|
56
56
|
const objectParams = {
|
|
57
57
|
Bucket: params.Bucket,
|
|
58
|
-
Key: item.Key
|
|
58
|
+
Key: item.Key
|
|
59
59
|
}
|
|
60
60
|
const request = s3.getObject(objectParams)
|
|
61
61
|
request.on('error', (err) => {
|
package/serialport.js
CHANGED
|
@@ -107,7 +107,7 @@ SerialStream.prototype.start = function () {
|
|
|
107
107
|
|
|
108
108
|
this.serial = new SerialPort({
|
|
109
109
|
path: this.options.device,
|
|
110
|
-
baudRate: this.options.baudrate
|
|
110
|
+
baudRate: this.options.baudrate
|
|
111
111
|
})
|
|
112
112
|
|
|
113
113
|
this.serial.on(
|
|
@@ -168,7 +168,7 @@ SerialStream.prototype.start = function () {
|
|
|
168
168
|
}
|
|
169
169
|
setImmediate(() => {
|
|
170
170
|
that.options.app.emit('connectionwrite', {
|
|
171
|
-
providerId: that.options.providerId
|
|
171
|
+
providerId: that.options.providerId
|
|
172
172
|
})
|
|
173
173
|
})
|
|
174
174
|
pendingWrites++
|
package/simple.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const Transform = require('stream').Transform
|
|
2
|
-
const Writable = require('stream').Writable
|
|
3
2
|
const _ = require('lodash')
|
|
4
3
|
const N2kAnalyzer = require('./n2kAnalyzer')
|
|
5
4
|
const FromJson = require('./from_json')
|
|
@@ -34,7 +33,7 @@ function Simple(options) {
|
|
|
34
33
|
...options.subOptions,
|
|
35
34
|
emitPropertyValue,
|
|
36
35
|
onPropertyValues,
|
|
37
|
-
createDebug
|
|
36
|
+
createDebug
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
options.subOptions.providerId = options.providerId
|
|
@@ -104,7 +103,7 @@ function Simple(options) {
|
|
|
104
103
|
delta.updates.forEach((update) => (update.timestamp = now))
|
|
105
104
|
}
|
|
106
105
|
callback(null, delta)
|
|
107
|
-
}
|
|
106
|
+
}
|
|
108
107
|
})
|
|
109
108
|
)
|
|
110
109
|
}
|
|
@@ -135,8 +134,8 @@ const getLogger = (app, logging, discriminator) =>
|
|
|
135
134
|
? [
|
|
136
135
|
new Log({
|
|
137
136
|
app: app,
|
|
138
|
-
discriminator
|
|
139
|
-
})
|
|
137
|
+
discriminator
|
|
138
|
+
})
|
|
140
139
|
]
|
|
141
140
|
: []
|
|
142
141
|
|
|
@@ -147,7 +146,7 @@ const discriminatorByDataType = {
|
|
|
147
146
|
NMEA2000: 'A',
|
|
148
147
|
NMEA0183: 'N',
|
|
149
148
|
SignalK: 'I',
|
|
150
|
-
Seatalk: 'N'
|
|
149
|
+
Seatalk: 'N'
|
|
151
150
|
}
|
|
152
151
|
|
|
153
152
|
const dataTypeMapping = {
|
|
@@ -156,14 +155,14 @@ const dataTypeMapping = {
|
|
|
156
155
|
? [new FromJson(options.subOptions)]
|
|
157
156
|
: [],
|
|
158
157
|
Seatalk: (options) => [
|
|
159
|
-
new nmea0183_signalk({ ...options.subOptions, validateChecksum: false })
|
|
158
|
+
new nmea0183_signalk({ ...options.subOptions, validateChecksum: false })
|
|
160
159
|
],
|
|
161
160
|
NMEA0183: (options) => {
|
|
162
161
|
const result = [new nmea0183_signalk(options.subOptions)]
|
|
163
162
|
if (options.type === 'FileStream') {
|
|
164
163
|
result.unshift(
|
|
165
164
|
new Throttle({
|
|
166
|
-
rate: options.subOptions.throttleRate || 1000
|
|
165
|
+
rate: options.subOptions.throttleRate || 1000
|
|
167
166
|
})
|
|
168
167
|
)
|
|
169
168
|
}
|
|
@@ -190,7 +189,7 @@ const dataTypeMapping = {
|
|
|
190
189
|
new TimestampThrottle({
|
|
191
190
|
getMilliseconds: (msg) => {
|
|
192
191
|
return msg.timer * 1000
|
|
193
|
-
}
|
|
192
|
+
}
|
|
194
193
|
})
|
|
195
194
|
)
|
|
196
195
|
} // else
|
|
@@ -210,7 +209,7 @@ const dataTypeMapping = {
|
|
|
210
209
|
new Ydwg02(
|
|
211
210
|
options.subOptions,
|
|
212
211
|
options.subOptions.type === 'ydwg02-usb-canboatjs' ? 'usb' : 'network'
|
|
213
|
-
)
|
|
212
|
+
)
|
|
214
213
|
]
|
|
215
214
|
if (options.type === 'FileStream') {
|
|
216
215
|
result.push(new TimestampThrottle())
|
|
@@ -231,7 +230,7 @@ const dataTypeMapping = {
|
|
|
231
230
|
}
|
|
232
231
|
return result.concat([new N2kToSignalK(options.subOptions)])
|
|
233
232
|
},
|
|
234
|
-
Multiplexed: (options) => [new MultiplexedLog(options.subOptions)]
|
|
233
|
+
Multiplexed: (options) => [new MultiplexedLog(options.subOptions)]
|
|
235
234
|
}
|
|
236
235
|
|
|
237
236
|
const pipeStartByType = {
|
|
@@ -240,7 +239,7 @@ const pipeStartByType = {
|
|
|
240
239
|
Execute: executeInput,
|
|
241
240
|
FileStream: fileInput,
|
|
242
241
|
SignalK: signalKInput,
|
|
243
|
-
Seatalk: seatalkInput
|
|
242
|
+
Seatalk: seatalkInput
|
|
244
243
|
}
|
|
245
244
|
|
|
246
245
|
function nmea2000input(subOptions, logging) {
|
|
@@ -252,15 +251,15 @@ function nmea2000input(subOptions, logging) {
|
|
|
252
251
|
return [
|
|
253
252
|
new actisenseSerial({
|
|
254
253
|
...subOptions,
|
|
255
|
-
plainText: logging
|
|
256
|
-
})
|
|
254
|
+
plainText: logging
|
|
255
|
+
})
|
|
257
256
|
]
|
|
258
257
|
} else if (subOptions.type === 'canbus-canboatjs') {
|
|
259
258
|
return [
|
|
260
259
|
new require('./canbus')({
|
|
261
260
|
...subOptions,
|
|
262
|
-
canDevice: subOptions.interface
|
|
263
|
-
})
|
|
261
|
+
canDevice: subOptions.interface
|
|
262
|
+
})
|
|
264
263
|
]
|
|
265
264
|
} else if (subOptions.type === 'ikonvert-canboatjs') {
|
|
266
265
|
const serialport = require('./serialport')
|
|
@@ -268,49 +267,49 @@ function nmea2000input(subOptions, logging) {
|
|
|
268
267
|
new serialport({
|
|
269
268
|
...subOptions,
|
|
270
269
|
baudrate: 230400,
|
|
271
|
-
toStdout: 'ikonvertOut'
|
|
272
|
-
})
|
|
270
|
+
toStdout: 'ikonvertOut'
|
|
271
|
+
})
|
|
273
272
|
]
|
|
274
273
|
} else if (subOptions.type === 'ydwg02-canboatjs') {
|
|
275
274
|
return [
|
|
276
275
|
new Tcp({
|
|
277
276
|
...subOptions,
|
|
278
|
-
outEvent: 'ydwg02-out'
|
|
277
|
+
outEvent: 'ydwg02-out'
|
|
279
278
|
}),
|
|
280
|
-
new Liner(subOptions)
|
|
279
|
+
new Liner(subOptions)
|
|
281
280
|
]
|
|
282
281
|
} else if (subOptions.type === 'ydwg02-udp-canboatjs') {
|
|
283
282
|
return [
|
|
284
283
|
new Udp({
|
|
285
284
|
...subOptions,
|
|
286
|
-
outEvent: 'ydwg02-out'
|
|
285
|
+
outEvent: 'ydwg02-out'
|
|
287
286
|
}),
|
|
288
|
-
new Liner(subOptions)
|
|
287
|
+
new Liner(subOptions)
|
|
289
288
|
]
|
|
290
289
|
} else if (subOptions.type === 'navlink2-tcp-canboatjs') {
|
|
291
290
|
return [
|
|
292
291
|
new Tcp({
|
|
293
292
|
...subOptions,
|
|
294
|
-
outEvent: 'navlink2-out'
|
|
293
|
+
outEvent: 'navlink2-out'
|
|
295
294
|
}),
|
|
296
|
-
new Liner(subOptions)
|
|
295
|
+
new Liner(subOptions)
|
|
297
296
|
]
|
|
298
297
|
} else if (subOptions.type === 'w2k-1-n2k-ascii-canboatjs') {
|
|
299
298
|
return [
|
|
300
299
|
new Tcp({
|
|
301
300
|
...subOptions,
|
|
302
|
-
outEvent: 'w2k-1-out'
|
|
301
|
+
outEvent: 'w2k-1-out'
|
|
303
302
|
}),
|
|
304
303
|
new Liner(subOptions),
|
|
305
|
-
new W2k01(subOptions, 'ascii', 'w2k-1-out')
|
|
304
|
+
new W2k01(subOptions, 'ascii', 'w2k-1-out')
|
|
306
305
|
]
|
|
307
306
|
} else if (subOptions.type === 'w2k-1-n2k-actisense-canboatjs') {
|
|
308
307
|
return [
|
|
309
308
|
new Tcp({
|
|
310
309
|
...subOptions,
|
|
311
|
-
outEvent: 'w2k-1-out'
|
|
310
|
+
outEvent: 'w2k-1-out'
|
|
312
311
|
}),
|
|
313
|
-
new W2k01(subOptions, 'actisense', 'w2k-1-out')
|
|
312
|
+
new W2k01(subOptions, 'actisense', 'w2k-1-out')
|
|
314
313
|
]
|
|
315
314
|
} else if (subOptions.type === 'navlink2-udp-canboatjs') {
|
|
316
315
|
return [new Udp(subOptions), new Liner(subOptions)]
|
|
@@ -320,8 +319,8 @@ function nmea2000input(subOptions, logging) {
|
|
|
320
319
|
new serialport({
|
|
321
320
|
...subOptions,
|
|
322
321
|
baudrate: 38400,
|
|
323
|
-
toStdout: 'ydwg02-out'
|
|
324
|
-
})
|
|
322
|
+
toStdout: 'ydwg02-out'
|
|
323
|
+
})
|
|
325
324
|
]
|
|
326
325
|
} else {
|
|
327
326
|
let command
|
|
@@ -342,9 +341,9 @@ function nmea2000input(subOptions, logging) {
|
|
|
342
341
|
command: command,
|
|
343
342
|
toChildProcess: toChildProcess,
|
|
344
343
|
app: subOptions.app,
|
|
345
|
-
providerId: subOptions.providerId
|
|
344
|
+
providerId: subOptions.providerId
|
|
346
345
|
}),
|
|
347
|
-
new Liner(subOptions)
|
|
346
|
+
new Liner(subOptions)
|
|
348
347
|
]
|
|
349
348
|
}
|
|
350
349
|
}
|
|
@@ -369,7 +368,7 @@ function nmea0183input(subOptions) {
|
|
|
369
368
|
pipePart.push(
|
|
370
369
|
new Replacer({
|
|
371
370
|
regexp: '\u0000',
|
|
372
|
-
template: ''
|
|
371
|
+
template: ''
|
|
373
372
|
})
|
|
374
373
|
)
|
|
375
374
|
}
|
|
@@ -380,7 +379,7 @@ function nmea0183input(subOptions) {
|
|
|
380
379
|
pipePart.push(
|
|
381
380
|
new Replacer({
|
|
382
381
|
regexp: `^...${sentence}.*`,
|
|
383
|
-
template: ''
|
|
382
|
+
template: ''
|
|
384
383
|
})
|
|
385
384
|
)
|
|
386
385
|
}
|
|
@@ -388,7 +387,7 @@ function nmea0183input(subOptions) {
|
|
|
388
387
|
}
|
|
389
388
|
return pipePart
|
|
390
389
|
} else {
|
|
391
|
-
throw new Error(`Unknown networking tyoe: ${
|
|
390
|
+
throw new Error(`Unknown networking tyoe: ${subOptions.networking}`)
|
|
392
391
|
}
|
|
393
392
|
}
|
|
394
393
|
|
package/splitting-liner.js
CHANGED
package/tcp.js
CHANGED
|
@@ -55,7 +55,7 @@ TcpStream.prototype.pipe = function (pipeTo) {
|
|
|
55
55
|
that.tcpStream.write(d)
|
|
56
56
|
setImmediate(() => {
|
|
57
57
|
that.options.app.emit('connectionwrite', {
|
|
58
|
-
providerId: that.options.providerId
|
|
58
|
+
providerId: that.options.providerId
|
|
59
59
|
})
|
|
60
60
|
})
|
|
61
61
|
}
|
|
@@ -77,7 +77,7 @@ TcpStream.prototype.pipe = function (pipeTo) {
|
|
|
77
77
|
)
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
require('reconnect-core')(function () {
|
|
81
81
|
return net.connect.apply(null, arguments)
|
|
82
82
|
})({ maxDelay: 5 * 1000 }, (tcpStream) => {
|
|
83
83
|
if (!isNaN(this.noDataReceivedTimeout)) {
|
|
@@ -110,7 +110,7 @@ TcpStream.prototype.pipe = function (pipeTo) {
|
|
|
110
110
|
this.options.app.setProviderError(this.options.providerId, msg)
|
|
111
111
|
that.debug(msg)
|
|
112
112
|
})
|
|
113
|
-
.on('disconnect', (
|
|
113
|
+
.on('disconnect', () => {
|
|
114
114
|
delete this.tcpStream
|
|
115
115
|
that.debug(`Disconnected ${this.options.host} ${this.options.port}`)
|
|
116
116
|
})
|
package/timestamp-throttle.js
CHANGED
package/udp.js
CHANGED
|
@@ -37,7 +37,7 @@ const Transform = require('stream').Transform
|
|
|
37
37
|
|
|
38
38
|
function Udp(options) {
|
|
39
39
|
Transform.call(this, {
|
|
40
|
-
objectMode: false
|
|
40
|
+
objectMode: false
|
|
41
41
|
})
|
|
42
42
|
this.options = options
|
|
43
43
|
this.debug = (options.createDebug || require('debug'))('signalk:streams:udp')
|
|
@@ -62,7 +62,7 @@ Udp.prototype.pipe = function (pipeTo) {
|
|
|
62
62
|
})
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
socket.on('message', function (message
|
|
65
|
+
socket.on('message', function (message) {
|
|
66
66
|
self.debug(message.toString())
|
|
67
67
|
self.push(message)
|
|
68
68
|
})
|
package/.prettierrc.json
DELETED