ads-client 1.13.2 → 1.14.1
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 +21 -0
- package/README.md +16 -2
- package/package.json +3 -2
- package/src/ads-client.js +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,27 @@ 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.1] - 13.09.2022
|
|
8
|
+
### Changed
|
|
9
|
+
- Bug fix: Connecting to local router failed with ECONNREFUSED error on Node.js version 17 and newer
|
|
10
|
+
- See [https://github.com/nodejs/node/issues/40702](https://github.com/nodejs/node/issues/40702)
|
|
11
|
+
- Fixed by using `127.0.0.1` instead of `localhost`
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.14.0] - 23.07.2022
|
|
15
|
+
### Added
|
|
16
|
+
- Created end-to-end testing for the library using Jest
|
|
17
|
+
- Separate PLC project required for testing: https://github.com/jisotalo/ads-client-test-plc-project
|
|
18
|
+
- Test is started using command `npm test`
|
|
19
|
+
- First version tests
|
|
20
|
+
- Connecting
|
|
21
|
+
- Reading
|
|
22
|
+
- Writing
|
|
23
|
+
- RPC methods
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
- Bug fix: Value converted to Javascript variable incorrectly in some edge cases [See issue #94](https://github.com/jisotalo/ads-client/issues/94)
|
|
27
|
+
|
|
7
28
|
## [1.13.2] - 17.05.2022
|
|
8
29
|
### Changed
|
|
9
30
|
- Bug fix: Incorrect parsing of ARRAY OF ARRAY, now works as should [See issue #91](https://github.com/jisotalo/ads-client/issues/91)
|
package/README.md
CHANGED
|
@@ -89,6 +89,7 @@ Check out the [node-red-contrib-ads-client](https://www.npmjs.com/package/node-r
|
|
|
89
89
|
* [Enabling debug from code](#enabling-debug-from-code)
|
|
90
90
|
* [Enabling debugging from terminal](#enabling-debugging-from-terminal)
|
|
91
91
|
- [FAQ](#faq)
|
|
92
|
+
- [Automatic testing](#automatic-testing)
|
|
92
93
|
- [Documentation](#documentation)
|
|
93
94
|
- [License](#license)
|
|
94
95
|
|
|
@@ -1712,8 +1713,6 @@ Solution:
|
|
|
1712
1713
|
Solution:
|
|
1713
1714
|
- See [this issue comment](https://github.com/jisotalo/ads-client/issues/51#issuecomment-758016428) by hansipete how to do it.
|
|
1714
1715
|
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
1716
|
### A data type is not found even when it should be
|
|
1718
1717
|
|
|
1719
1718
|
If you use methods like `convertFromRaw()` and `getDataType()` but receive an error similar to `ClientException: Finding data type *data type* failed`, make sure you have really written the data type correctly.
|
|
@@ -1755,7 +1754,22 @@ Another option is to use setting `bareClient: true` (since v.1.13.0). However, w
|
|
|
1755
1754
|
|
|
1756
1755
|
I would suggest to use ads-client normally without any special settings. If the target is at config mode, use separate client instance to start it, and the again the normal instance to connect to a running system. This way the client works the best.
|
|
1757
1756
|
|
|
1757
|
+
### Getting a message `Ads notification received but it has unknown notificationHandle (**). Use unsubscribe() to save resources.`
|
|
1758
|
+
|
|
1759
|
+
Possible reasons:
|
|
1760
|
+
* You have created notifications (subscriptions) using `subscribe()` and then closed the Node.js application without unsubscribing them first (TwinCAT still sends the data)
|
|
1761
|
+
* You are connecting without router (providing directly the target IP as router address) and you have other connections too like TwinCAT XAE running. See issue: https://github.com/jisotalo/ads-client/issues/85
|
|
1762
|
+
|
|
1763
|
+
Solution:
|
|
1764
|
+
* When closing application, first unsubscribe from all notifications using `unsubscribeAll()`
|
|
1765
|
+
* Use router instead of direct connection, see https://github.com/jisotalo/ads-client/issues/85#issuecomment-1193098519
|
|
1766
|
+
|
|
1767
|
+
# Automatic testing
|
|
1768
|
+
Since version 1.14.0 the library has automatic testing using Jest. Idea is to run the tests before updates to make sure everything works OK (this should have been done much earlier...)
|
|
1769
|
+
|
|
1770
|
+
Separate PLC project is required for testing, see https://github.com/jisotalo/ads-client-test-plc-project for more project and more info.
|
|
1758
1771
|
|
|
1772
|
+
Tests are run with command `npm test` (not in npm version, please clone this repository).
|
|
1759
1773
|
|
|
1760
1774
|
# Documentation
|
|
1761
1775
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ads-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.1",
|
|
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": {
|
|
7
|
-
"test": "
|
|
7
|
+
"test": "jest --runInBand",
|
|
8
8
|
"generate-docs": "jsdoc ./src/ads-client.js ./README.md -c ./jsdoc-conf.json -d ./docs/ -t ./node_modules/docdash/"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"docdash": "^1.2.0",
|
|
42
|
+
"jest": "^28.1.3",
|
|
42
43
|
"jsdoc": "^3.6.7"
|
|
43
44
|
},
|
|
44
45
|
"files": [
|
package/src/ads-client.js
CHANGED
|
@@ -61,7 +61,7 @@ class Client extends EventEmitter {
|
|
|
61
61
|
* @property {boolean} [readAndCacheDataTypes=false] - If true, all PLC data types are cached during connecting. Otherwise they are read and cached only when needed - Optional (**default**: false)
|
|
62
62
|
* @property {boolean} [disableSymbolVersionMonitoring=false] - If true, PLC symbol version changes aren't monitored and cached symbols and datatypes won't be updated after PLC program download - Optional - Optional (**default**: false)
|
|
63
63
|
* @property {number} [routerTcpPort=48898] - Target ADS router TCP port - Optional (**default**: 48898)
|
|
64
|
-
* @property {string} [routerAddress=
|
|
64
|
+
* @property {string} [routerAddress=127.0.0.1] - Target ADS router IP address/hostname - Optional (**default**: 127.0.0.1)
|
|
65
65
|
* @property {string} [localAddress='(system default)'] - Local IP address to use, use this to change used network interface if required - Optional (**default**: System default)
|
|
66
66
|
* @property {number} [localTcpPort='(system default)'] - Local TCP port to use for outgoing connections - Optional (**default**: System default)
|
|
67
67
|
* @property {string} [localAmsNetId='(from AMS router)'] - Local AmsNetId to use - Optional (**default**: From AMS router)
|
|
@@ -91,7 +91,7 @@ class Client extends EventEmitter {
|
|
|
91
91
|
readAndCacheDataTypes: false,
|
|
92
92
|
disableSymbolVersionMonitoring: false,
|
|
93
93
|
routerTcpPort: 48898,
|
|
94
|
-
routerAddress: '
|
|
94
|
+
routerAddress: '127.0.0.1',
|
|
95
95
|
localAddress: null,
|
|
96
96
|
localTcpPort: null,
|
|
97
97
|
localAmsNetId: null,
|
|
@@ -145,6 +145,12 @@ class Client extends EventEmitter {
|
|
|
145
145
|
this.settings.targetAmsNetId = '127.0.0.1.1.1'
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
//Checking that router address is 127.0.0.1 instead of localhost
|
|
149
|
+
//to prevent problem like https://github.com/nodejs/node/issues/40702
|
|
150
|
+
if (this.settings.routerAddress.toLowerCase() === 'localhost') {
|
|
151
|
+
this.settings.routerAddress = '127.0.0.1'
|
|
152
|
+
}
|
|
153
|
+
|
|
148
154
|
/**
|
|
149
155
|
* Internal variables - Not intended for external use
|
|
150
156
|
*
|
|
@@ -5230,8 +5236,8 @@ function _parseJsObjectToBuffer(value, dataType, objectPathStr = '', isArraySubI
|
|
|
5230
5236
|
|
|
5231
5237
|
//Struct or array subitem - Go through each subitem
|
|
5232
5238
|
if ((dataType.arrayData.length === 0 || isArraySubItem) && dataType.subItems.length > 0) {
|
|
5233
|
-
buffer = Buffer.alloc(dataType.
|
|
5234
|
-
|
|
5239
|
+
buffer = Buffer.alloc(dataType.size)
|
|
5240
|
+
|
|
5235
5241
|
for (const subItem of dataType.subItems) {
|
|
5236
5242
|
//Try the find the subitem from javascript object
|
|
5237
5243
|
let key = null
|