ads-client 1.14.1 → 1.14.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.
package/CHANGELOG.md CHANGED
@@ -4,13 +4,28 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.14.2] - 02.05.2023
8
+ ### Changed
9
+ - Bug fix: `ADS_DATA_TYPE_FLAGS` (`dataType.flags`) were parsed incorrectly.
10
+ - See [issue #109](https://github.com/jisotalo/ads-client/issues/109)
11
+ - Thank you [Michael Croes](https://github.com/mycroes) for contribution!
12
+ - Bug fix: If calling `unsubcribeAll()` when client is already unsubcribing and disconnecting, an error might be thrown
13
+ - See [issue #103](https://github.com/jisotalo/ads-client/issues/103#issuecomment-1450640160)
14
+ - Bug fix: Check that subscription callback exists before calling it
15
+ - Fixes unecessary error if receiving notification data (for subscription) but it's being unsubscribed at the same time
16
+ - Bump json5 from 2.2.1 to 2.2.3
17
+ - See [pull request 101](https://github.com/jisotalo/ads-client/pull/101)
18
+ - Not used in production code, only when running tests
19
+
20
+ ### Added
21
+ - New test for [issue #103](https://github.com/jisotalo/ads-client/issues/103)
22
+
7
23
  ## [1.14.1] - 13.09.2022
8
24
  ### Changed
9
25
  - Bug fix: Connecting to local router failed with ECONNREFUSED error on Node.js version 17 and newer
10
26
  - See [https://github.com/nodejs/node/issues/40702](https://github.com/nodejs/node/issues/40702)
11
27
  - Fixed by using `127.0.0.1` instead of `localhost`
12
28
 
13
-
14
29
  ## [1.14.0] - 23.07.2022
15
30
  ### Added
16
31
  - Created end-to-end testing for the library using Jest
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ads-client",
3
- "version": "1.14.1",
3
+ "version": "1.14.2",
4
4
  "description": "Beckhoff TwinCAT ADS client library for Node.js (unofficial). Connects to Beckhoff TwinCAT automation systems using ADS protocol.",
5
5
  "main": "./src/ads-client.js",
6
6
  "scripts": {
package/src/ads-client.js CHANGED
@@ -1224,7 +1224,11 @@ class Client extends EventEmitter {
1224
1224
  unSubCount++
1225
1225
 
1226
1226
  } catch (err) {
1227
- debug(`unsubscribeAll(): Unsubscribing from notification ${JSON.stringify(this._internals.activeSubscriptions[sub].target)} failed`)
1227
+ if (this._internals.activeSubscriptions[sub] && this._internals.activeSubscriptions[sub].target !== undefined) {
1228
+ debug(`unsubscribeAll(): Unsubscribing from notification ${JSON.stringify(this._internals.activeSubscriptions[sub].target)} failed`)
1229
+ } else {
1230
+ debug(`unsubscribeAll(): Unsubscribing from notification with handle ${sub} failed`)
1231
+ }
1228
1232
 
1229
1233
  firstError = new ClientException(this, 'unsubscribeAll()', err)
1230
1234
  }
@@ -4722,32 +4726,32 @@ async function _parseDataType(data) {
4722
4726
  dataType.adsDataTypeStr = ADS.ADS_DATA_TYPES.toString(dataType.adsDataType)
4723
4727
  pos += 4
4724
4728
 
4725
- //27..30 Flags (AdsDataTypeFlags)
4726
- dataType.flags = data.readUInt16LE(pos)
4729
+ //28..31 Flags (AdsDataTypeFlags)
4730
+ dataType.flags = data.readUInt32LE(pos)
4727
4731
  dataType.flagsStr = ADS.ADS_DATA_TYPE_FLAGS.toStringArray(dataType.flags)
4728
4732
  pos += 4
4729
4733
 
4730
- //31..32 Name length
4734
+ //32..33 Name length
4731
4735
  dataType.nameLength = data.readUInt16LE(pos)
4732
4736
  pos += 2
4733
4737
 
4734
- //33..34 Type length
4738
+ //34..35 Type length
4735
4739
  dataType.typeLength = data.readUInt16LE(pos)
4736
4740
  pos += 2
4737
4741
 
4738
- //35..36 Comment length
4742
+ //36..37 Comment length
4739
4743
  dataType.commentLength = data.readUInt16LE(pos)
4740
4744
  pos += 2
4741
4745
 
4742
- //37..40 Array dimension
4746
+ //38..39 Array dimension
4743
4747
  dataType.arrayDimension = data.readUInt16LE(pos)
4744
4748
  pos += 2
4745
4749
 
4746
- //41..42 Subitem count
4750
+ //40..41 Subitem count
4747
4751
  dataType.subItemCount = data.readUInt16LE(pos)
4748
4752
  pos += 2
4749
4753
 
4750
- //43.... Name
4754
+ //42.... Name
4751
4755
  dataType.name = _trimPlcString(iconv.decode(data.slice(pos, pos + dataType.nameLength + 1), 'cp1252'))
4752
4756
  pos += dataType.nameLength + 1
4753
4757
 
@@ -6327,7 +6331,7 @@ async function _onAdsCommandReceived(packet) {
6327
6331
  parsedValue.timeStamp = stamp.timeStamp
6328
6332
 
6329
6333
  //Then lets call the users callback
6330
- sub.callback(
6334
+ sub.callback && sub.callback(
6331
6335
  parsedValue,
6332
6336
  sub
6333
6337
  )