@canboat/canboatjs 3.0.0-beta.5 → 3.0.0-beta.6

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/lib/canbus.js CHANGED
@@ -73,7 +73,7 @@ function CanbusStream (options) {
73
73
  this.socketcan = require('socketcan')
74
74
  } catch ( err ) {
75
75
  console.error(err)
76
- var msg = 'WARNING unable to load native socketcan interface'
76
+ var msg = 'unable to load native socketcan interface'
77
77
  console.error(msg)
78
78
  }
79
79
 
@@ -90,7 +90,9 @@ function CanbusStream (options) {
90
90
 
91
91
  var canDevice = options.canDevice || 'can0'
92
92
 
93
- this.connect()
93
+ if ( this.connect() == false ) {
94
+ return
95
+ }
94
96
 
95
97
  const noDataReceivedTimeout = typeof options.noDataReceivedTimeout !== 'undefined' ? options.noDataReceivedTimeout : -1
96
98
  if ( noDataReceivedTimeout > 0 ) {
@@ -114,6 +116,11 @@ function CanbusStream (options) {
114
116
 
115
117
  CanbusStream.prototype.connect = function() {
116
118
  try {
119
+ if ( this.socketcan === undefined ) {
120
+ this.setProviderError('unable to load native socketcan interface')
121
+ return false
122
+ }
123
+
117
124
  var that = this
118
125
  var canDevice = this.options.canDevice || 'can0'
119
126
  this.channel = this.socketcan.createRawChannelWithOptions(canDevice, { non_block_send: true} );
@@ -153,10 +160,12 @@ CanbusStream.prototype.connect = function() {
153
160
  this.setProviderStatus('Connected to socketcan')
154
161
  this.candevice = new CanDevice(this, this.options)
155
162
  this.candevice.start()
163
+ return true
156
164
  } catch (e) {
157
165
  console.error(`unable to open canbus ${canDevice}: ${e}`)
158
166
  console.error(e.stack)
159
167
  this.setProviderError(e.message)
168
+ return false
160
169
  }
161
170
  }
162
171
 
package/lib/n2kDevice.js CHANGED
@@ -358,7 +358,7 @@ function sendNAKAcknowledgement(device, src, requestedPGN) {
358
358
  "Group Function": 255,
359
359
  PGN: requestedPGN
360
360
  }
361
- device.sendPGN(device, acknowledgement)
361
+ device.sendPGN(acknowledgement)
362
362
  }
363
363
 
364
364
  function sendPGNList(device, src) {
package/lib/ydgw02.js CHANGED
@@ -131,7 +131,7 @@ Ydgw02Stream.prototype.sendYdgwPGN = function (msg) {
131
131
  msgs = actisenseToYdgwRawFormat(msg)
132
132
  }
133
133
 
134
- msg.forEach(raw => {
134
+ msgs.forEach(raw => {
135
135
  this.sendString(raw + '\r\n')
136
136
  })
137
137
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canboat/canboatjs",
3
- "version": "3.0.0-beta.5",
3
+ "version": "3.0.0-beta.6",
4
4
  "description": "Native javascript version of canboat",
5
5
  "main": "index.js",
6
6
  "scripts": {