@signalk/streams 5.0.4 → 5.0.5

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.
Files changed (4) hide show
  1. package/canboatjs.js +4 -0
  2. package/package.json +1 -1
  3. package/tcp.js +10 -2
  4. package/udp.js +13 -1
package/canboatjs.js CHANGED
@@ -56,6 +56,9 @@ CanboatJs.prototype._transform = function (chunk, encoding, done) {
56
56
  } else {
57
57
  this.app.emit('canboatjs:unparsed:object', chunk)
58
58
  }
59
+ if (chunk.fromFile) {
60
+ this.app.emit('canboatjs:rawoutput', chunk.data)
61
+ }
59
62
  } else {
60
63
  const pgnData = this.fromPgn.parse(chunk)
61
64
  if (pgnData) {
@@ -64,6 +67,7 @@ CanboatJs.prototype._transform = function (chunk, encoding, done) {
64
67
  } else {
65
68
  this.app.emit('canboatjs:unparsed:data', chunk)
66
69
  }
70
+ this.app.emit('canboatjs:rawoutput', chunk)
67
71
  }
68
72
  done()
69
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalk/streams",
3
- "version": "5.0.4",
3
+ "version": "5.0.5",
4
4
  "description": "Utilities for handling streams of Signal K data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/tcp.js CHANGED
@@ -115,8 +115,16 @@ TcpStream.prototype.pipe = function (pipeTo) {
115
115
  that.debug(`Disconnected ${this.options.host} ${this.options.port}`)
116
116
  })
117
117
  .on('error', (err) => {
118
- this.options.app.setProviderError(this.options.providerId, err.message)
119
- console.error('TcpProvider:' + err.message)
118
+ let msg = err
119
+ if (err.message && err.message.length > 0) {
120
+ msg = err.message
121
+ } else if (err.errors) {
122
+ msg = err.errors.toString()
123
+ } else {
124
+ msg = err.toString()
125
+ }
126
+ this.options.app.setProviderError(this.options.providerId, msg)
127
+ console.error('TcpProvider:' + msg)
120
128
  })
121
129
  .connect(this.options)
122
130
 
package/udp.js CHANGED
@@ -58,7 +58,13 @@ Udp.prototype.pipe = function (pipeTo) {
58
58
  if (this.options.outEvent && this.options.port !== undefined) {
59
59
  this.options.app.on(this.options.outEvent, function (d) {
60
60
  self.debug('sending over udp: %s', d)
61
- socket.send(d, 0, d.length, self.options.port, '255.255.255.255')
61
+ socket.send(
62
+ d,
63
+ 0,
64
+ d.length,
65
+ self.options.port,
66
+ self.options.host || '255.255.255.255'
67
+ )
62
68
  })
63
69
  }
64
70
 
@@ -66,6 +72,12 @@ Udp.prototype.pipe = function (pipeTo) {
66
72
  self.debug(message.toString())
67
73
  self.push(message)
68
74
  })
75
+
76
+ socket.on('error', (err) => {
77
+ this.options.app.setProviderError(this.options.providerId, err.message)
78
+ console.error('UdpProvider:' + err)
79
+ })
80
+
69
81
  socket.bind(this.options.port, function () {
70
82
  socket.setBroadcast(true)
71
83
  })