@signalk/streams 5.1.3 → 6.0.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/dist/actisense-serial.d.ts +3 -0
- package/dist/actisense-serial.d.ts.map +1 -0
- package/dist/actisense-serial.js +4 -0
- package/dist/autodetect.d.ts +54 -0
- package/dist/autodetect.d.ts.map +1 -0
- package/dist/autodetect.js +186 -0
- package/dist/canboatjs.d.ts +25 -0
- package/dist/canboatjs.d.ts.map +1 -0
- package/dist/canboatjs.js +57 -0
- package/dist/canbus.d.ts +3 -0
- package/dist/canbus.d.ts.map +1 -0
- package/dist/canbus.js +4 -0
- package/dist/execute.d.ts +34 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +101 -0
- package/dist/filestream.d.ts +24 -0
- package/dist/filestream.d.ts.map +1 -0
- package/dist/filestream.js +58 -0
- package/dist/folderstream.d.ts +12 -0
- package/dist/folderstream.d.ts.map +1 -0
- package/dist/folderstream.js +36 -0
- package/dist/from_json.d.ts +6 -0
- package/dist/from_json.d.ts.map +1 -0
- package/dist/from_json.js +22 -0
- package/dist/gpiod-seatalk.d.ts +19 -0
- package/dist/gpiod-seatalk.d.ts.map +1 -0
- package/{gpiod-seatalk.js → dist/gpiod-seatalk.js} +18 -16
- package/dist/gpsd.d.ts +23 -0
- package/dist/gpsd.d.ts.map +1 -0
- package/dist/gpsd.js +55 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/keys-filter.d.ts +27 -0
- package/dist/keys-filter.d.ts.map +1 -0
- package/dist/keys-filter.js +59 -0
- package/dist/liner.d.ts +14 -0
- package/dist/liner.d.ts.map +1 -0
- package/dist/liner.js +35 -0
- package/dist/log.d.ts +15 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +17 -0
- package/dist/logging.d.ts +14 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +125 -0
- package/dist/mdns-ws.d.ts +37 -0
- package/dist/mdns-ws.d.ts.map +1 -0
- package/dist/mdns-ws.js +144 -0
- package/dist/multiplexedlog.d.ts +3 -0
- package/dist/multiplexedlog.d.ts.map +1 -0
- package/dist/multiplexedlog.js +7 -0
- package/dist/n2k-signalk.d.ts +39 -0
- package/dist/n2k-signalk.d.ts.map +1 -0
- package/dist/n2k-signalk.js +180 -0
- package/dist/n2kAnalyzer.d.ts +19 -0
- package/dist/n2kAnalyzer.d.ts.map +1 -0
- package/dist/n2kAnalyzer.js +61 -0
- package/dist/nmea0183-signalk.d.ts +33 -0
- package/dist/nmea0183-signalk.d.ts.map +1 -0
- package/dist/nmea0183-signalk.js +105 -0
- package/dist/nullprovider.d.ts +5 -0
- package/dist/nullprovider.d.ts.map +1 -0
- package/dist/nullprovider.js +9 -0
- package/dist/pigpio-seatalk.d.ts +19 -0
- package/dist/pigpio-seatalk.d.ts.map +1 -0
- package/{pigpio-seatalk.js → dist/pigpio-seatalk.js} +21 -18
- package/dist/replacer.d.ts +13 -0
- package/dist/replacer.d.ts.map +1 -0
- package/dist/replacer.js +20 -0
- package/dist/s3.d.ts +13 -0
- package/dist/s3.d.ts.map +1 -0
- package/dist/s3.js +82 -0
- package/dist/serialport.d.ts +35 -0
- package/dist/serialport.d.ts.map +1 -0
- package/dist/serialport.js +125 -0
- package/dist/simple.d.ts +78 -0
- package/dist/simple.d.ts.map +1 -0
- package/dist/simple.js +446 -0
- package/dist/splitting-liner.d.ts +12 -0
- package/dist/splitting-liner.d.ts.map +1 -0
- package/dist/splitting-liner.js +19 -0
- package/dist/tcp.d.ts +32 -0
- package/dist/tcp.d.ts.map +1 -0
- package/dist/tcp.js +113 -0
- package/dist/tcpserver.d.ts +14 -0
- package/dist/tcpserver.d.ts.map +1 -0
- package/dist/tcpserver.js +18 -0
- package/dist/test-helpers.d.ts +52 -0
- package/dist/test-helpers.d.ts.map +1 -0
- package/dist/test-helpers.js +73 -0
- package/dist/throttle.d.ts +3 -0
- package/dist/throttle.d.ts.map +1 -0
- package/dist/throttle.js +4 -0
- package/dist/timestamp-throttle.d.ts +17 -0
- package/dist/timestamp-throttle.d.ts.map +1 -0
- package/dist/timestamp-throttle.js +41 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/udp.d.ts +26 -0
- package/dist/udp.d.ts.map +1 -0
- package/dist/udp.js +53 -0
- package/package.json +46 -4
- package/actisense-serial.js +0 -1
- package/autodetect.js +0 -198
- package/canboatjs.js +0 -71
- package/canbus.js +0 -17
- package/execute.js +0 -137
- package/filestream.js +0 -90
- package/folderstream.js +0 -36
- package/from_json.js +0 -51
- package/gpsd.js +0 -94
- package/keys-filter.js +0 -81
- package/liner.js +0 -68
- package/log.js +0 -51
- package/logging.js +0 -149
- package/mdns-ws.js +0 -167
- package/multiplexedlog.js +0 -3
- package/n2k-signalk.js +0 -195
- package/n2kAnalyzer.js +0 -82
- package/nmea0183-signalk.js +0 -119
- package/nullprovider.js +0 -31
- package/replacer.js +0 -57
- package/s3.js +0 -87
- package/serialport.js +0 -209
- package/simple.js +0 -446
- package/splitting-liner.js +0 -46
- package/tcp.js +0 -138
- package/tcpserver.js +0 -40
- package/throttle.js +0 -31
- package/timestamp-throttle.js +0 -63
- package/udp.js +0 -95
package/execute.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
*
|
|
3
|
-
* prototype-server: An implementation of a Signal K server for boats.
|
|
4
|
-
* Copyright (C) 2014 Fabian Tollenaar <fabian@starting-point.nl>,
|
|
5
|
-
* Teppo Kurki <teppo.kurki@iki.fi> *et al*.
|
|
6
|
-
*
|
|
7
|
-
* This program is free software: you can redistribute it and/or modify
|
|
8
|
-
* it under the terms of the GNU General Public License as published by
|
|
9
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version.
|
|
11
|
-
*
|
|
12
|
-
* This program is distributed in the hope that it will be useful,
|
|
13
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
* GNU General Public License for more details.
|
|
16
|
-
*
|
|
17
|
-
* You should have received a copy of the GNU General Public License
|
|
18
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/* Usage:
|
|
23
|
-
* As part of a PipedProvider in a settings file. Lets you pass a command to the server, as set in the options.
|
|
24
|
-
* Also allows writing to stdout, for example with actisense-serial N2K data
|
|
25
|
-
* see https://github.com/tkurki/cassiopeia-settings/blob/master/signalk-server-settings.json
|
|
26
|
-
* Example from https://github.com/SignalK/signalk-server-node/blob/master/settings/actisense-serial-settings.json#L12
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
"type": "providers/execute",
|
|
30
|
-
"options": {
|
|
31
|
-
"command": "actisense-serial /dev/tty.usbserial-1FD34"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
* It may also be other commands such as "./aisdeco --gain 33.8 --freq-correction 60 --freq 161975000 --freq 162025000 --net 30007 --udp 5.9.207.224:5351" for starting an AID reception with a USB SRD dongle
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
const Transform = require('stream').Transform
|
|
40
|
-
const { pgnToActisenseSerialFormat } = require('@canboat/canboatjs')
|
|
41
|
-
|
|
42
|
-
function Execute(options) {
|
|
43
|
-
Transform.call(this, {})
|
|
44
|
-
this.options = options
|
|
45
|
-
const createDebug = options.createDebug || require('debug')
|
|
46
|
-
this.debug = options.debug || createDebug('signalk:streams:execute')
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
require('util').inherits(Execute, Transform)
|
|
50
|
-
|
|
51
|
-
Execute.prototype._transform = function (chunk, encoding, done) {
|
|
52
|
-
this.analyzerProcess.stdin.write(chunk.toString())
|
|
53
|
-
done()
|
|
54
|
-
}
|
|
55
|
-
function start(command, that) {
|
|
56
|
-
that.debug(`starting |${command}|`)
|
|
57
|
-
if (process.platform === 'win32') {
|
|
58
|
-
that.childProcess = require('child_process').spawn('cmd', ['/c', command])
|
|
59
|
-
} else {
|
|
60
|
-
that.childProcess = require('child_process').spawn('sh', ['-c', command])
|
|
61
|
-
}
|
|
62
|
-
that.lastStartupTime = new Date().getTime()
|
|
63
|
-
that.options.app.setProviderStatus(that.options.providerId, 'Started')
|
|
64
|
-
|
|
65
|
-
that.childProcess.stderr.on('data', function (data) {
|
|
66
|
-
const msg = data.toString()
|
|
67
|
-
that.options.app.setProviderError(that.options.providerId, msg)
|
|
68
|
-
console.error(msg)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
that.childProcess.stdout.on('data', function (data) {
|
|
72
|
-
if (that.debug.enabled) {
|
|
73
|
-
that.debug(data.toString())
|
|
74
|
-
}
|
|
75
|
-
that.push(data)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
that.childProcess.on('close', (code) => {
|
|
79
|
-
const msg = `|${command}| exited with ${code}`
|
|
80
|
-
// that.options.app.setProviderError(that.options.providerId, msg)
|
|
81
|
-
console.error(msg)
|
|
82
|
-
if (
|
|
83
|
-
typeof that.options.restartOnClose === 'undefined' ||
|
|
84
|
-
that.options.restartOnClose
|
|
85
|
-
) {
|
|
86
|
-
const throttleTime = (that.options.restartThrottleTime || 60) * 1000
|
|
87
|
-
|
|
88
|
-
const sinceLast = new Date().getTime() - that.lastStartupTime
|
|
89
|
-
if (sinceLast > throttleTime) {
|
|
90
|
-
start(command, that)
|
|
91
|
-
} else {
|
|
92
|
-
const nextStart = throttleTime - sinceLast
|
|
93
|
-
const msg = `Waiting ${nextStart / 1000} seconds to restart`
|
|
94
|
-
that.options.app.setProviderStatus(that.options.providerId, msg)
|
|
95
|
-
that.debug(msg)
|
|
96
|
-
setTimeout(function () {
|
|
97
|
-
start(command, that)
|
|
98
|
-
}, nextStart)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
Execute.prototype.pipe = function (pipeTo) {
|
|
105
|
-
this.pipeTo = pipeTo
|
|
106
|
-
start(this.options.command, this)
|
|
107
|
-
|
|
108
|
-
const stdOutEvent = this.options.toChildProcess || 'toChildProcess'
|
|
109
|
-
this.debug(
|
|
110
|
-
'Using event ' + stdOutEvent + " for output to child process's stdin"
|
|
111
|
-
)
|
|
112
|
-
const that = this
|
|
113
|
-
that.options.app.on(stdOutEvent, function (d) {
|
|
114
|
-
try {
|
|
115
|
-
that.childProcess.stdin.write(d + '\n')
|
|
116
|
-
} catch (err) {
|
|
117
|
-
console.log('execute:' + err.message)
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
if (stdOutEvent === 'nmea2000out') {
|
|
122
|
-
that.options.app.on('nmea2000JsonOut', (pgn) => {
|
|
123
|
-
that.childProcess.stdin.write(pgnToActisenseSerialFormat(pgn) + '\r\n')
|
|
124
|
-
})
|
|
125
|
-
that.options.app.emit('nmea2000OutAvailable')
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
Execute.super_.prototype.pipe.call(this, pipeTo)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
Execute.prototype.end = function () {
|
|
132
|
-
this.debug('end, killing child process')
|
|
133
|
-
this.childProcess.kill()
|
|
134
|
-
this.pipeTo.end()
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
module.exports = Execute
|
package/filestream.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2014-2015 Fabian Tollenaar <fabian@starting-point.nl>
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/* Usage:
|
|
18
|
-
* As part of a PipedProvider in a settings file. Lets the server read from a file, as set in the options:
|
|
19
|
-
* Example from https://github.com/SignalK/signalk-server-node/blob/master/settings/volare-file-settings.json#L23-L34
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
"type": "providers/filestream",
|
|
23
|
-
"options": {
|
|
24
|
-
"filename": "samples/plaka.log"
|
|
25
|
-
},
|
|
26
|
-
"optionMappings": [
|
|
27
|
-
{
|
|
28
|
-
"fromAppProperty": "argv.nmeafilename",
|
|
29
|
-
"toOption": "filename"
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
const path = require('path')
|
|
37
|
-
const PassThrough = require('stream').PassThrough
|
|
38
|
-
const fs = require('fs')
|
|
39
|
-
|
|
40
|
-
function EndIgnoringPassThrough() {
|
|
41
|
-
PassThrough.call(this)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
require('util').inherits(EndIgnoringPassThrough, PassThrough)
|
|
45
|
-
EndIgnoringPassThrough.prototype.end = function () {}
|
|
46
|
-
|
|
47
|
-
const FileStream = function (options) {
|
|
48
|
-
this.options = options
|
|
49
|
-
this.keepRunning =
|
|
50
|
-
typeof options.keepRunning === 'undefined' ? true : options.keepRunning
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
FileStream.prototype.pipe = function (pipeTo) {
|
|
54
|
-
this.pipeTo = pipeTo
|
|
55
|
-
this.endIgnoringPassThrough = new EndIgnoringPassThrough()
|
|
56
|
-
this.endIgnoringPassThrough.pipe(pipeTo)
|
|
57
|
-
this.startStream()
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
FileStream.prototype.startStream = function () {
|
|
61
|
-
let filename
|
|
62
|
-
if (path.isAbsolute(this.options.filename)) {
|
|
63
|
-
filename = this.options.filename
|
|
64
|
-
} else {
|
|
65
|
-
filename = path.join(
|
|
66
|
-
this.options.app.config.configPath,
|
|
67
|
-
this.options.filename
|
|
68
|
-
)
|
|
69
|
-
if (!fs.existsSync(filename)) {
|
|
70
|
-
filename = path.join(__dirname, '..', this.options.filename)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
this.filestream = require('fs').createReadStream(filename)
|
|
75
|
-
this.filestream.on('error', (err) => {
|
|
76
|
-
console.error(err.message)
|
|
77
|
-
this.keepRunning = false
|
|
78
|
-
})
|
|
79
|
-
if (this.keepRunning) {
|
|
80
|
-
this.filestream.on('end', this.startStream.bind(this))
|
|
81
|
-
}
|
|
82
|
-
this.filestream.pipe(this.endIgnoringPassThrough)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
FileStream.prototype.end = function () {
|
|
86
|
-
this.pipeTo.end()
|
|
87
|
-
this.filestream.close()
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
module.exports = FileStream
|
package/folderstream.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const Transform = require('stream').Transform
|
|
2
|
-
const fs = require('fs')
|
|
3
|
-
|
|
4
|
-
function FolderStreamProvider(folder) {
|
|
5
|
-
Transform.call(this, {
|
|
6
|
-
objectMode: false
|
|
7
|
-
})
|
|
8
|
-
this.folder = folder
|
|
9
|
-
this.fileIndex = 0
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
require('util').inherits(FolderStreamProvider, Transform)
|
|
13
|
-
|
|
14
|
-
FolderStreamProvider.prototype.pipe = function (pipeTo) {
|
|
15
|
-
const files = fs.readdirSync(this.folder)
|
|
16
|
-
pipeNextFile.bind(this)()
|
|
17
|
-
|
|
18
|
-
function pipeNextFile() {
|
|
19
|
-
const fileStream = fs.createReadStream(
|
|
20
|
-
this.folder + '/' + files[this.fileIndex]
|
|
21
|
-
)
|
|
22
|
-
fileStream.pipe(pipeTo, { end: false })
|
|
23
|
-
fileStream.on('end', () => {
|
|
24
|
-
this.fileIndex++
|
|
25
|
-
if (this.fileIndex === files.length) {
|
|
26
|
-
pipeTo.end()
|
|
27
|
-
} else {
|
|
28
|
-
pipeNextFile.bind(this)()
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return pipeTo
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
module.exports = FolderStreamProvider
|
package/from_json.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2014-2015 Fabian Tollenaar <fabian@starting-point.nl>
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/* Usage:
|
|
18
|
-
* As part of a PipedProvider in a settings file. Lets you pass json strings such as Signal K deltas coming from other sources such as TCP, UDP, Serial etc. Usually last in the list of providers for this pipe
|
|
19
|
-
* Takes no options:
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
"type": "providers/from_json"
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
const Transform = require('stream').Transform
|
|
29
|
-
|
|
30
|
-
function FromJson() {
|
|
31
|
-
Transform.call(this, {
|
|
32
|
-
objectMode: true
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
require('util').inherits(FromJson, Transform)
|
|
37
|
-
|
|
38
|
-
FromJson.prototype._transform = function (chunk, encoding, done) {
|
|
39
|
-
let parsed = null
|
|
40
|
-
try {
|
|
41
|
-
parsed = JSON.parse(chunk.toString())
|
|
42
|
-
} catch (_) {
|
|
43
|
-
console.error('Could not parse JSON:' + chunk.toString())
|
|
44
|
-
}
|
|
45
|
-
if (parsed) {
|
|
46
|
-
this.push(parsed)
|
|
47
|
-
}
|
|
48
|
-
done()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
module.exports = FromJson
|
package/gpsd.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2014-2015 Teppo Kurki <teppo.kurki@iki.fi>
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/* Usage:
|
|
18
|
-
* As part of a PipedProvider in a settings file. Lets you pass gpsd to Signal K. GPSD is a service daemon that monitors one or more GPSes or AIS receivers attached to a host computer through serial or USB ports,
|
|
19
|
-
* making all data on the location/course/velocity of the sensors available to be queried on TCP port 2947 of the host computer.
|
|
20
|
-
* For examples of use, see https://github.com/SignalK/signalk-server-node/blob/master/settings/volare-gpsd-settings.json
|
|
21
|
-
* Takes the options "port" (default 2947) and "hostname" (default 'localhost')
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
"type": "providers/gpsd",
|
|
25
|
-
"options": {
|
|
26
|
-
"port": 2947,
|
|
27
|
-
"hostname": "localhost"
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
const Transform = require('stream').Transform
|
|
34
|
-
const GpsdClient = require('node-gpsd-client')
|
|
35
|
-
|
|
36
|
-
function Gpsd(options) {
|
|
37
|
-
Transform.call(this, {
|
|
38
|
-
objectMode: true
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const port = options.port || 2947
|
|
42
|
-
const hostname = options.hostname || options.host || 'localhost'
|
|
43
|
-
const noDataReceivedTimeout = options.noDataReceivedTimeout || 0
|
|
44
|
-
|
|
45
|
-
function setProviderStatus(msg) {
|
|
46
|
-
options.app.setProviderStatus(options.providerId, msg)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const createDebug = options.createDebug || require('debug')
|
|
50
|
-
|
|
51
|
-
this.listener = new GpsdClient({
|
|
52
|
-
port: port,
|
|
53
|
-
hostname: hostname,
|
|
54
|
-
logger: {
|
|
55
|
-
info: createDebug('signalk:streams:gpsd'),
|
|
56
|
-
warn: console.warn,
|
|
57
|
-
error: (msg) => {
|
|
58
|
-
options.app.setProviderError(
|
|
59
|
-
options.providerId,
|
|
60
|
-
`${hostname}:${port}: ` + msg
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
parse: false,
|
|
65
|
-
reconnectThreshold: noDataReceivedTimeout,
|
|
66
|
-
reconnectInterval: noDataReceivedTimeout / 2
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
setProviderStatus(`Connecting to ${hostname}:${port}`)
|
|
70
|
-
|
|
71
|
-
this.listener.on('connected', () => {
|
|
72
|
-
setProviderStatus(`Connected to ${hostname}:${port}`)
|
|
73
|
-
this.listener.watch({
|
|
74
|
-
class: 'WATCH',
|
|
75
|
-
nmea: true,
|
|
76
|
-
json: false
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
const self = this
|
|
81
|
-
this.listener.on('raw', function (data) {
|
|
82
|
-
self.push(data)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
this.listener.connect()
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
require('util').inherits(Gpsd, Transform)
|
|
89
|
-
|
|
90
|
-
Gpsd.prototype._transform = function (chunk, encoding, done) {
|
|
91
|
-
done()
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
module.exports = Gpsd
|
package/keys-filter.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const Transform = require('stream').Transform
|
|
4
|
-
|
|
5
|
-
function ToSignalK(options) {
|
|
6
|
-
Transform.call(this, {
|
|
7
|
-
objectMode: true
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
const createDebug = options.createDebug || require('debug')
|
|
11
|
-
this.debug = createDebug('signalk:streams:keys-filter')
|
|
12
|
-
this.exclude = options.excludeMatchingPaths
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
require('util').inherits(ToSignalK, Transform)
|
|
16
|
-
|
|
17
|
-
ToSignalK.prototype._transform = function (chunk, encoding, done) {
|
|
18
|
-
// Chunck is a delta. Check options if any of the paths need to be filtered...
|
|
19
|
-
let delta = null
|
|
20
|
-
let string = false
|
|
21
|
-
|
|
22
|
-
if (typeof chunk === 'object' && chunk !== null) {
|
|
23
|
-
delta = chunk
|
|
24
|
-
} else if (typeof chunk === 'string') {
|
|
25
|
-
try {
|
|
26
|
-
delta = JSON.parse(chunk)
|
|
27
|
-
string = true
|
|
28
|
-
} catch (e) {
|
|
29
|
-
this.debug(`Error parsing chunk: ${e.message}`)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (Array.isArray(delta.updates)) {
|
|
34
|
-
const updates = []
|
|
35
|
-
delta.updates.forEach((update) => {
|
|
36
|
-
if (Array.isArray(update.values)) {
|
|
37
|
-
const values = []
|
|
38
|
-
|
|
39
|
-
update.values.forEach((value) => {
|
|
40
|
-
if (this.exclude.includes(value.path) !== true) {
|
|
41
|
-
values.push(value)
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
if (values.length > 0) {
|
|
46
|
-
const upd = {
|
|
47
|
-
values
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (update.$source) {
|
|
51
|
-
upd.$source = update.$source
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (update.source) {
|
|
55
|
-
upd.source = update.source
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (update.timestamp) {
|
|
59
|
-
upd.timestamp = update.timestamp
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
updates.push(upd)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
if (updates.length > 0) {
|
|
68
|
-
delta.updates = updates
|
|
69
|
-
|
|
70
|
-
if (string === true) {
|
|
71
|
-
delta = JSON.stringify(delta)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
this.push(delta)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
done()
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
module.exports = ToSignalK
|
package/liner.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2014-2015 Fabian Tollenaar <fabian@starting-point.nl>
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/* Usage:
|
|
18
|
-
* This is part of a PipedProvider that splits the input into separate lines and passes one line at a time to the next provider.
|
|
19
|
-
* You can specify the line separator with the option lineSeparator.
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
"type": "providers/liner"
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
const Transform = require('stream').Transform
|
|
28
|
-
|
|
29
|
-
require('util').inherits(Liner, Transform)
|
|
30
|
-
|
|
31
|
-
function Liner(options) {
|
|
32
|
-
Transform.call(this, {
|
|
33
|
-
objectMode: true
|
|
34
|
-
})
|
|
35
|
-
this.doPush = this.push.bind(this)
|
|
36
|
-
this.lineSeparator = options.lineSeparator || '\n'
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
Liner.prototype._transform = function (chunk, encoding, done) {
|
|
40
|
-
let data = chunk.toString()
|
|
41
|
-
if (this._lastLineData) {
|
|
42
|
-
data = this._lastLineData + data
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const lines = data.split(this.lineSeparator)
|
|
46
|
-
this._lastLineData = lines.splice(lines.length - 1, 1)[0]
|
|
47
|
-
if (this._lastLineData.length > 2048) {
|
|
48
|
-
console.error(
|
|
49
|
-
'Are you sure you are using the correct line terminator? Not going to handle lines longer than 2048 chars.'
|
|
50
|
-
)
|
|
51
|
-
this._lastLineData = ''
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
lines.forEach(this.doPush)
|
|
55
|
-
|
|
56
|
-
done()
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
Liner.prototype._flush = function (done) {
|
|
60
|
-
if (this._lastLineData) {
|
|
61
|
-
this.push(this._lastLineData)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
this._lastLineData = null
|
|
65
|
-
done()
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
module.exports = Liner
|
package/log.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2016 Teppo Kurki <teppo.kurki@ıki.fi>
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/* Usage: This pipeElement logs the output of the previous pipeElement. If placed in the end of the pipe, it will log Signal K deltas
|
|
18
|
-
* Takes the options "logdir" and "discriminator". The log files are named from date and hour, and a new file is created every hour
|
|
19
|
-
* Please note the standard discriminators used for playback with providers/multiplexedlog.js
|
|
20
|
-
* Example:
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
"type": "providers/log",
|
|
24
|
-
"options": {
|
|
25
|
-
"logdir": "logs",
|
|
26
|
-
"discriminator": "I"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
const Transform = require('stream').Transform
|
|
33
|
-
const getLogger = require('./logging').getLogger
|
|
34
|
-
|
|
35
|
-
function Log(options) {
|
|
36
|
-
Transform.call(this, {
|
|
37
|
-
objectMode: true
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
this.logger = getLogger(options.app, options.discriminator, options.logdir)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
require('util').inherits(Log, Transform)
|
|
44
|
-
|
|
45
|
-
Log.prototype._transform = function (msg, encoding, done) {
|
|
46
|
-
this.push(msg)
|
|
47
|
-
this.logger(msg)
|
|
48
|
-
done()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
module.exports = Log
|