@canboat/canboatjs 3.0.0 → 3.0.2

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.
@@ -16,7 +16,7 @@ jobs:
16
16
 
17
17
  strategy:
18
18
  matrix:
19
- node-version: [16.x, 18.x, 20.x]
19
+ node-version: [18.x, 20.x, 22.x]
20
20
 
21
21
  steps:
22
22
  - uses: actions/checkout@v3
package/lib/n2kDevice.js CHANGED
@@ -161,7 +161,9 @@ class N2kDevice extends EventEmitter {
161
161
  function handleISORequest(device, n2kMsg) {
162
162
  debug('handleISORequest %j', n2kMsg)
163
163
 
164
- switch (n2kMsg.fields.PGN) {
164
+ const PGN = n2kMsg.fields.PGN || n2kMsg.fields.pgn
165
+
166
+ switch (PGN) {
165
167
  case 126996: // Product Information request
166
168
  sendProductInformation(device)
167
169
  break;
@@ -177,8 +179,8 @@ function handleISORequest(device, n2kMsg) {
177
179
  break;
178
180
  default:
179
181
  if ( !device.options.disableNAKs ) {
180
- debug(`Got unsupported ISO request for PGN ${n2kMsg.fields.PGN}. Sending NAK.`)
181
- sendNAKAcknowledgement(device, n2kMsg.src, n2kMsg.fields.PGN)
182
+ debug(`Got unsupported ISO request for PGN ${PGN}. Sending NAK.`)
183
+ sendNAKAcknowledgement(device, n2kMsg.src, PGN)
182
184
  }
183
185
  }
184
186
  }
@@ -197,13 +199,16 @@ function handleGroupFunction(device, n2kMsg) {
197
199
  function handleRequestGroupFunction(device, n2kMsg) {
198
200
  if ( !device.options.disableNAKs ) {
199
201
  // We really don't support group function requests for any PGNs yet -> always respond with pgnErrorCode 1 = "PGN not supported"
200
- debug("Sending 'PGN Not Supported' Group Function response for requested PGN", n2kMsg.fields.PGN)
202
+
203
+ const PGN = n2kMsg.fields.PGN || n2kMsg.fields.pgn
204
+
205
+ debug("Sending 'PGN Not Supported' Group Function response for requested PGN", PGN)
201
206
 
202
207
  const acknowledgement = {
203
208
  pgn: 126208,
204
209
  dst: n2kMsg.src,
205
210
  "Function Code": 2,
206
- "PGN": n2kMsg.fields.PGN,
211
+ "PGN": PGN,
207
212
  "PGN error code": 4,
208
213
  "Transmission interval/Priority error code": 0,
209
214
  "# of Parameters": 0
@@ -215,13 +220,16 @@ function handleGroupFunction(device, n2kMsg) {
215
220
  function handleCommandGroupFunction(device, n2kMsg) {
216
221
  if ( !device.options.disableNAKs ) {
217
222
  // We really don't support group function commands for any PGNs yet -> always respond with pgnErrorCode 1 = "PGN not supported"
218
- debug("Sending 'PGN Not Supported' Group Function response for commanded PGN", n2kMsg.fields.PGN)
223
+
224
+ const PGN = n2kMsg.fields.PGN || n2kMsg.fields.pgn
225
+
226
+ debug("Sending 'PGN Not Supported' Group Function response for commanded PGN", PGN)
219
227
 
220
228
  const acknowledgement = {
221
229
  pgn: 126208,
222
230
  dst: n2kMsg.src,
223
231
  "Function Code": 2,
224
- "PGN": n2kMsg.fields.PGN,
232
+ "PGN": PGN,
225
233
  "PGN error code": 4,
226
234
  "Transmission interval/Priority error code": 0,
227
235
  "# of Parameters": 0
package/lib/ydgw02.js CHANGED
@@ -77,7 +77,7 @@ function Ydgw02Stream (options, type) {
77
77
  options.app.emit(this.outEvent, Buffer.from([0x30, 0x0a]))
78
78
  }
79
79
 
80
- if ( options.createDevice === true || options.createDevice === undefined ) {
80
+ if ( options.createDevice === true ) {
81
81
  this.device = new YdDevice(options)
82
82
  this.device.start()
83
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canboat/canboatjs",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Native javascript version of canboat",
5
5
  "main": "index.js",
6
6
  "scripts": {