@signalk/streams 3.0.0 → 3.2.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 CHANGED
@@ -31,7 +31,7 @@
31
31
  */
32
32
 
33
33
  const Transform = require('stream').Transform
34
- const gpsd = require('node-gpsd')
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 gpsd.Listener({
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.connect(function () {
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.watch({
78
- class: 'WATCH',
79
- nmea: true,
80
- })
85
+ this.listener.connect()
81
86
  }
82
87
 
83
88
  require('util').inherits(Gpsd, Transform)
package/logging.js CHANGED
@@ -18,6 +18,7 @@ const { FileTimestampStream } = require('file-timestamp-stream')
18
18
  const path = require('path')
19
19
  let debug = require('debug')('signalk:streams:logging')
20
20
  const fs = require('fs')
21
+ const { isUndefined } = require('lodash')
21
22
 
22
23
  const filenamePattern = /skserver\-raw\_\d\d\d\d\-\d\d\-\d\dT\d\d\.log/
23
24
  const loggers = {}
@@ -85,7 +86,10 @@ function getLogger(app, discriminator = '', logdir) {
85
86
  debug(`logging to ${fileName}`)
86
87
 
87
88
  let fileTimestampStream
88
- if (app.config.settings.keepMostRecentLogsOnly) {
89
+ if (
90
+ isUndefined(app.config.settings.keepMostRecentLogsOnly) ||
91
+ app.config.settings.keepMostRecentLogsOnly
92
+ ) {
89
93
  // Delete old logs
90
94
  fileTimestampStream = new FileTimestampStreamWithDelete(
91
95
  app,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalk/streams",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "description": "Utilities for handling streams of Signal K data",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -32,7 +32,7 @@
32
32
  "file-timestamp-stream": "^2.1.2",
33
33
  "lodash": "^4.17.4",
34
34
  "moment": "^2.24.0",
35
- "node-gpsd": "^0.3.0",
35
+ "node-gpsd-client": "^1.4.1",
36
36
  "reconnect-core": "^1.3.0",
37
37
  "stream-throttle": "^0.1.3"
38
38
  },
package/serialport.js CHANGED
@@ -166,6 +166,11 @@ SerialStream.prototype.start = function () {
166
166
  } else {
167
167
  that.serial.write(d + '\r\n')
168
168
  }
169
+ setImmediate(() => {
170
+ that.options.app.emit('connectionwrite', {
171
+ providerId: that.options.providerId,
172
+ })
173
+ })
169
174
  pendingWrites++
170
175
  that.serial.drain(onDrain)
171
176
  })
package/simple.js CHANGED
@@ -76,6 +76,16 @@ function Simple(options) {
76
76
  ) {
77
77
  mappingType = 'NMEA2000YD'
78
78
  }
79
+ options.app.on('nmea2000out', () => {
80
+ setImmediate(() =>
81
+ options.app.emit('connectionwrite', { providerId: options.providerId })
82
+ )
83
+ })
84
+ options.app.on('nmea2000JsonOut', () => {
85
+ setImmediate(() =>
86
+ options.app.emit('connectionwrite', { providerId: options.providerId })
87
+ )
88
+ })
79
89
  }
80
90
 
81
91
  const pipeline = [].concat(
package/tcp.js CHANGED
@@ -53,6 +53,11 @@ TcpStream.prototype.pipe = function (pipeTo) {
53
53
  if (that.tcpStream) {
54
54
  that.debug('sending %s', d)
55
55
  that.tcpStream.write(d)
56
+ setImmediate(() => {
57
+ that.options.app.emit('connectionwrite', {
58
+ providerId: that.options.providerId,
59
+ })
60
+ })
56
61
  }
57
62
  })
58
63
  }