ads-client 1.14.3 → 1.14.4

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,6 +4,15 @@ 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.4] - 03.10.2023
8
+ ### Changed
9
+ - Bug fix: Changed RPC method flags from 16-bit to 32-bit
10
+ - Bug fix: Fix RPC method parsing in TwinCAT 4026
11
+
12
+ See [PR #127](https://github.com/jisotalo/ads-client/pull/127) for details.
13
+
14
+ Thank you [icon-bobk](https://github.com/icon-bobk) for contribution!
15
+
7
16
  ## [1.14.3] - 23.09.2023
8
17
  ### Changed
9
18
  - Bug fix: Some TwinCAT 2 devices (such as BK9050) do not send data length if answering with error code
package/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
 
4
4
  [![npm version](https://img.shields.io/npm/v/ads-client)](https://www.npmjs.org/package/ads-client)
5
- [![Donate](https://img.shields.io/badge/Support-PayPal-yellow)](https://www.paypal.com/donate/?business=KUWBXXCVGZZME&no_recurring=0&currency_code=EUR)
6
5
  [![GitHub](https://img.shields.io/badge/View%20on-GitHub-brightgreen)](https://github.com/jisotalo/ads-client)
7
6
  [![License](https://img.shields.io/github/license/jisotalo/ads-client)](https://choosealicense.com/licenses/mit/)
8
7
 
@@ -12,17 +11,23 @@ Coded from scratch using [TwinCAT ADS specification](https://infosys.beckhoff.co
12
11
 
13
12
  There is automatically created documentation available at https://jisotalo.fi/ads-client/
14
13
 
15
- # Project status
16
- This project is currently "ready". It's maintained actively and used in projects by the author and others (also lot's of commercial projects)
14
+ # Version 2 will be released soon
17
15
 
18
- Bugs are fixed if found and new features can be added. Please let me know if you have any ideas!
16
+ The 1.4.4 is the the last version for v1, unless some bugs need fixing.
19
17
 
20
- If you want to support my work, you can do it using PayPal. I can provide you support in exchange.
18
+ <span style="color:red; font-weight:bold;">It might be a good idea to use the version 2 beta for new projects. It will no longer have breaking changes and it's basically ready!</span>
21
19
 
22
- [![Donate](https://img.shields.io/badge/Support%20my%20work!-PayPal-yellow)](https://www.paypal.com/donate/?business=KUWBXXCVGZZME&no_recurring=0&currency_code=EUR)
20
+ See [`v2-dev`](https://github.com/jisotalo/ads-client/tree/v2-dev) branch for more info. It's a full rewrite in in TypeScript and it can be installed from npm (`npm i ads-client@beta`).
23
21
 
24
- ## Version 2
25
- Version 2 is under development in [`v2-dev`](https://github.com/jisotalo/ads-client/tree/v2-dev) branch. It's written in TypeScript (including all types!) and will also be more optimized. At the moment basic functions *might* work but it's not ready for production use.
22
+ # Supporting
23
+
24
+ If you want to support my work, you can buy me a coffee!
25
+
26
+ <a href="https://www.buymeacoffee.com/jisotalo" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
27
+
28
+ [![Donate](https://img.shields.io/badge/Donate-PayPal-yellow)](https://www.paypal.com/donate/?business=KUWBXXCVGZZME&no_recurring=0&currency_code=EUR)
29
+
30
+ If you need help with integrating the ads-client, I'm available for coding work with invoicing. Please send me email!
26
31
 
27
32
 
28
33
  # Using Node-RED?
@@ -30,68 +35,94 @@ Check out the [node-red-contrib-ads-client](https://www.npmjs.com/package/node-r
30
35
 
31
36
 
32
37
  # Table of contents
38
+ - [ads-client](#ads-client)
39
+ - [Version 2 will be released soon](#version-2-will-be-released-soon)
40
+ - [Supporting](#supporting)
41
+ - [Using Node-RED?](#using-node-red)
42
+ - [Table of contents](#table-of-contents)
33
43
  - [Installation](#installation)
34
44
  - [Features](#features)
35
45
  - [Supported and tested platforms](#supported-and-tested-platforms)
36
46
  - [Connection setups and possibilities](#connection-setups-and-possibilities)
47
+ - [Setup 1 - Connect from Windows PC to the PLC](#setup-1---connect-from-windows-pc-to-the-plc)
48
+ - [Setup 2 - Connecting from Unix/Windows/etc. system to the PLC](#setup-2---connecting-from-unixwindowsetc-system-to-the-plc)
49
+ - [Setup 3 - Connecting from any Node.js supported system to the PLC](#setup-3---connecting-from-any-nodejs-supported-system-to-the-plc)
50
+ - [Setup 4 - Connect to the localhost (PLC and client on the same machine)](#setup-4---connect-to-the-localhost-plc-and-client-on-the-same-machine)
37
51
  - [Enabling localhost support on TwinCAT 3](#enabling-localhost-support-on-twincat-3)
38
52
  - [IMPORTANT: Writing STRUCT variables](#important-writing-struct-variables)
39
53
  - [IMPORTANT: Things to know when using with TwinCAT 2](#important-things-to-know-when-using-with-twincat-2)
54
+ - [TwinCAT 2 first PLC runtime ADS port is 801 instead of 851](#twincat-2-first-plc-runtime-ads-port-is-801-instead-of-851)
55
+ - [Variable names are returned in UPPERCASE on TC2 systems](#variable-names-are-returned-in-uppercase-on-tc2-systems)
56
+ - [Global variable paths are given different on TC2](#global-variable-paths-are-given-different-on-tc2)
57
+ - [InvokeRpcMethod is not possible on TC2](#invokerpcmethod-is-not-possible-on-tc2)
40
58
  - [Connecting to systems without PLC runtime](#connecting-to-systems-without-plc-runtime)
41
59
  - [Getting started](#getting-started)
42
- * [Data types used in getting started](#data-types-used-in-getting-started)
43
- * [Creating a new Client instance](#creating-a-new-client-instance)
44
- * [Available settings](#available-settings)
45
- * [Connecting and disconnecting](#connecting-and-disconnecting)
46
- * [Reading any type PLC variable](#reading-any-type-plc-variable)
47
- + [Example: Reading `INT` type variable](#example-reading-int-type-variable)
48
- + [Example: Reading `STRING` type variable](#example-reading-string-type-variable)
49
- + [Example: Reading `ENUM` type variable](#example-reading-enum-type-variable)
50
- + [Example: Reading `STRUCT` type variable](#example-reading-struct-type-variable)
51
- + [Example: Reading `ARRAY OF INT` type variable](#example-reading-array-of-int-type-variable)
52
- + [Example: Reading `ARRAY OF STRUCT` type variable](#example-reading-array-of-struct-type-variable)
53
- + [Example: Reading `FUNCTION BLOCK` type variable](#example-reading-function-block-type-variable)
54
- * [Writing any type PLC variable](#writing-any-type-plc-variable)
55
- + [Example: Writing `INT` type variable](#example-writing-int-type-variable)
56
- + [Example: Writing `STRING` type variable](#example-writing-string-type-variable)
57
- + [Example: Writing `ENUM` type variable](#example-writing-enum-type-variable)
58
- + [Example: Writing `STRUCT` type variable](#example-writing-struct-type-variable)
59
- + [Example: Writing `STRUCT` type variable (with autoFill parameter)](#example-writing-struct-type-variable-with-autofill-parameter-)
60
- + [Example: Writing `ARRAY OF INT` type variable](#example-writing-array-of-int-type-variable)
61
- + [Example: Writing `ARRAY of STRUCT` type variable](#example-writing-array-of-struct-type-variable)
62
- + [Example: Writing `FUNCTION BLOCK` type variable](#example-writing-function-block-type-variable)
63
- * [Subscribing to PLC variables (device notifications)](#subscribing-to-plc-variables-device-notifications-)
64
- + [Subcribe to variable value (on-change)](#subcribe-to-variable-value-on-change-)
65
- + [Subcribe to variable value (cyclic)](#subcribe-to-variable-value-cyclic-)
66
- * [Reading and writing raw data](#reading-and-writing-raw-data)
67
- + [Getting symbol index group, offset and size](#getting-symbol-index-group-offset-and-size)
68
- + [Reading a single raw value](#reading-a-single-raw-value)
69
- + [Writing a single raw value](#writing-a-single-raw-value)
70
- + [Reading multiple raw values](#reading-multiple-raw-values)
71
- + [Writing multiple raw values](#writing-multiple-raw-values)
72
- + [Creating a variable handle and reading a raw value](#creating-a-variable-handle-and-reading-a-raw-value)
73
- + [Creating a variable handle and writing a raw value](#creating-a-variable-handle-and-writing-a-raw-value)
74
- + [Creating and deleting multiple variable handles](#creating-and-deleting-multiple-variable-handles)
75
- + [Converting a raw value to Javascript object](#converting-a-raw-value-to-javascript-object)
76
- + [Converting a Javascript object to raw value](#converting-a-javascript-object-to-raw-value)
77
- * [Reading and writing `POINTER TO` and `REFERENCE TO` variables](#reading-and-writing-pointer-to-and-reference-to-variables)
78
- + [Reading a `REFERENCE TO` value](#reading-a-reference-to-value)
79
- + [Writing a `REFERENCE TO` value](#writing-a-reference-to-value)
80
- + [Reading a `POINTER TO` value](#reading-a-pointer-to-value)
81
- + [Writing a `POINTER TO` value](#writing-a-pointer-to-value)
82
- * [Calling a function block method with parameters using RPC (remote procedure call)](#calling-a-function-block-method-with-parameters-using-rpc-remote-procedure-call-)
83
- + [Calling a simple RPC method](#calling-a-simple-rpc-method)
84
- + [Using structs with RPC methods](#using-structs-with-rpc-methods)
85
- * [Starting and stopping the PLC](#starting-and-stopping-the-plc)
86
- * [Starting and stopping the TwinCAT system](#starting-and-stopping-the-twincat-system)
87
- * [Sending custom ADS commands](#sending-custom-ads-commands)
60
+ - [Data types used in getting started](#data-types-used-in-getting-started)
61
+ - [Creating a new Client instance](#creating-a-new-client-instance)
62
+ - [Available settings](#available-settings)
63
+ - [Connecting and disconnecting](#connecting-and-disconnecting)
64
+ - [Reading any type PLC variable](#reading-any-type-plc-variable)
65
+ - [Example: Reading `INT` type variable](#example-reading-int-type-variable)
66
+ - [Example: Reading `STRING` type variable](#example-reading-string-type-variable)
67
+ - [Example: Reading `ENUM` type variable](#example-reading-enum-type-variable)
68
+ - [Example: Reading `STRUCT` type variable](#example-reading-struct-type-variable)
69
+ - [Example: Reading `ARRAY OF INT` type variable](#example-reading-array-of-int-type-variable)
70
+ - [Example: Reading `ARRAY OF STRUCT` type variable](#example-reading-array-of-struct-type-variable)
71
+ - [Example: Reading `FUNCTION BLOCK` type variable](#example-reading-function-block-type-variable)
72
+ - [Writing any type PLC variable](#writing-any-type-plc-variable)
73
+ - [Example: Writing `INT` type variable](#example-writing-int-type-variable)
74
+ - [Example: Writing `STRING` type variable](#example-writing-string-type-variable)
75
+ - [Example: Writing `ENUM` type variable](#example-writing-enum-type-variable)
76
+ - [Example: Writing `STRUCT` type variable](#example-writing-struct-type-variable)
77
+ - [Example: Writing `STRUCT` type variable (with autoFill parameter)](#example-writing-struct-type-variable-with-autofill-parameter)
78
+ - [Example: Writing `ARRAY OF INT` type variable](#example-writing-array-of-int-type-variable)
79
+ - [Example: Writing `ARRAY of STRUCT` type variable](#example-writing-array-of-struct-type-variable)
80
+ - [Example: Writing `FUNCTION BLOCK` type variable](#example-writing-function-block-type-variable)
81
+ - [Subscribing to PLC variables (device notifications)](#subscribing-to-plc-variables-device-notifications)
82
+ - [Subcribe to variable value (on-change)](#subcribe-to-variable-value-on-change)
83
+ - [Subcribe to variable value (cyclic)](#subcribe-to-variable-value-cyclic)
84
+ - [Reading and writing raw data](#reading-and-writing-raw-data)
85
+ - [Getting symbol index group, offset and size](#getting-symbol-index-group-offset-and-size)
86
+ - [Reading a single raw value](#reading-a-single-raw-value)
87
+ - [Writing a single raw value](#writing-a-single-raw-value)
88
+ - [Reading multiple raw values](#reading-multiple-raw-values)
89
+ - [Writing multiple raw values](#writing-multiple-raw-values)
90
+ - [Creating a variable handle and reading a raw value](#creating-a-variable-handle-and-reading-a-raw-value)
91
+ - [Creating a variable handle and writing a raw value](#creating-a-variable-handle-and-writing-a-raw-value)
92
+ - [Creating and deleting multiple variable handles](#creating-and-deleting-multiple-variable-handles)
93
+ - [Converting a raw value to Javascript object](#converting-a-raw-value-to-javascript-object)
94
+ - [Converting a Javascript object to raw value](#converting-a-javascript-object-to-raw-value)
95
+ - [Reading and writing `POINTER TO` and `REFERENCE TO` variables](#reading-and-writing-pointer-to-and-reference-to-variables)
96
+ - [Reading a `REFERENCE TO` value](#reading-a-reference-to-value)
97
+ - [Writing a `REFERENCE TO` value](#writing-a-reference-to-value)
98
+ - [Reading a `POINTER TO` value](#reading-a-pointer-to-value)
99
+ - [Writing a `POINTER TO` value](#writing-a-pointer-to-value)
100
+ - [Calling a function block method with parameters using RPC (remote procedure call)](#calling-a-function-block-method-with-parameters-using-rpc-remote-procedure-call)
101
+ - [Calling a simple RPC method](#calling-a-simple-rpc-method)
102
+ - [Using structs with RPC methods](#using-structs-with-rpc-methods)
103
+ - [Starting and stopping the PLC](#starting-and-stopping-the-plc)
104
+ - [Starting and stopping the TwinCAT system](#starting-and-stopping-the-twincat-system)
105
+ - [Sending custom ADS commands](#sending-custom-ads-commands)
88
106
  - [Available ads-client events](#available-ads-client-events)
89
- * [Example: Printing to console when PLC runtime state changes:](#example-printing-to-console-when-plc-runtime-state-changes-)
90
- * [Example: Catching an error that is not directly from a method call](#example-catching-an-error-that-is-not-directly-from-a-method-call)
107
+ - [Example: Printing to console when PLC runtime state changes:](#example-printing-to-console-when-plc-runtime-state-changes)
108
+ - [Example: Catching an error that is not directly from a method call](#example-catching-an-error-that-is-not-directly-from-a-method-call)
91
109
  - [Debugging](#debugging)
92
- * [Enabling debug from code](#enabling-debug-from-code)
93
- * [Enabling debugging from terminal](#enabling-debugging-from-terminal)
110
+ - [Enabling debug from code](#enabling-debug-from-code)
111
+ - [Enabling debugging from terminal](#enabling-debugging-from-terminal)
94
112
  - [FAQ](#faq)
113
+ - [Connection is working very badly and lot's of timeouts](#connection-is-working-very-badly-and-lots-of-timeouts)
114
+ - [When using JSON.stringify or similar I'm getting a `TypeError: Do not know how to serialize a BigInt`](#when-using-jsonstringify-or-similar-im-getting-a-typeerror-do-not-know-how-to-serialize-a-bigint)
115
+ - [Can I connect from Raspberry Pi to TwinCAT?](#can-i-connect-from-raspberry-pi-to-twincat)
116
+ - [Receiving ADS error 1808 `Symbol not found` even when it should be found](#receiving-ads-error-1808-symbol-not-found-even-when-it-should-be-found)
117
+ - [Having timeouts and/or 'mailbox is full' errors when sending lot's of ADS commands](#having-timeouts-andor-mailbox-is-full-errors-when-sending-lots-of-ads-commands)
118
+ - [Having problems to connect from OSX or Raspberry Pi to target PLC](#having-problems-to-connect-from-osx-or-raspberry-pi-to-target-plc)
119
+ - [A data type is not found even when it should be](#a-data-type-is-not-found-even-when-it-should-be)
120
+ - [ClientException: Connection failed: Device system manager state read failed](#clientexception-connection-failed-device-system-manager-state-read-failed)
121
+ - [Connection failed (error EADDRNOTAVAIL)](#connection-failed-error-eaddrnotavail)
122
+ - [Problems running ads-client with docker](#problems-running-ads-client-with-docker)
123
+ - [How to connect to PLC that is in CONFIG mode?](#how-to-connect-to-plc-that-is-in-config-mode)
124
+ - [Getting a message `Ads notification received but it has unknown notificationHandle (**). Use unsubscribe() to save resources.`](#getting-a-message-ads-notification-received-but-it-has-unknown-notificationhandle--use-unsubscribe-to-save-resources)
125
+ - [Issues with TwinCAT 2 low-end devices (BK9050, BC9050 etc.)](#issues-with-twincat-2-low-end-devices-bk9050-bc9050-etc)
95
126
  - [Automatic testing](#automatic-testing)
96
127
  - [Documentation](#documentation)
97
128
  - [License](#license)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ads-client",
3
- "version": "1.14.3",
3
+ "version": "1.14.4",
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
@@ -4819,6 +4819,7 @@ async function _parseDataType(data) {
4819
4819
 
4820
4820
  //Get method length
4821
4821
  let len = data.readUInt32LE(pos)
4822
+ const methodFinalPos = pos + len;
4822
4823
  pos += 4
4823
4824
 
4824
4825
  //4..7 Version
@@ -4841,33 +4842,33 @@ async function _parseDataType(data) {
4841
4842
  method.reserved = data.readUInt32LE(pos)
4842
4843
  pos += 4
4843
4844
 
4844
- //24..27 Return type GUID
4845
+ //24..39 Return type GUID
4845
4846
  method.returnTypeGuid = data.slice(pos, pos + 16).toString('hex')
4846
4847
  pos += 16
4847
4848
 
4848
- //28..31 Return data type
4849
+ //40..43 Return data type
4849
4850
  method.retunAdsDataType = data.readUInt32LE(pos)
4850
4851
  method.retunAdsDataTypeStr = ADS.ADS_DATA_TYPES.toString(method.retunAdsDataType)
4851
4852
  pos += 4
4852
4853
 
4853
- //27..30 Flags (AdsDataTypeFlags)
4854
- method.flags = data.readUInt16LE(pos)
4854
+ //44..47 Flags
4855
+ method.flags = data.readUInt32LE(pos)
4855
4856
  method.flagsStr = ADS.ADS_DATA_TYPE_FLAGS.toStringArray(method.flags)
4856
4857
  pos += 4
4857
4858
 
4858
- //31..32 Name length
4859
+ //48..49 Name length
4859
4860
  method.nameLength = data.readUInt16LE(pos)
4860
4861
  pos += 2
4861
4862
 
4862
- //33..34 Return type length
4863
+ //50..51 Return type length
4863
4864
  method.returnTypeLength = data.readUInt16LE(pos)
4864
4865
  pos += 2
4865
4866
 
4866
- //35..36 Comment length
4867
+ //52..53 Comment length
4867
4868
  method.commentLength = data.readUInt16LE(pos)
4868
4869
  pos += 2
4869
4870
 
4870
- //37..38 Parameter count
4871
+ //54..55 Parameter count
4871
4872
  method.parameterCount = data.readUInt16LE(pos)
4872
4873
  pos += 2
4873
4874
 
@@ -4955,6 +4956,7 @@ async function _parseDataType(data) {
4955
4956
  method.parameters.push(param)
4956
4957
  }
4957
4958
 
4959
+ pos = methodFinalPos;
4958
4960
  dataType.rpcMethods.push(method)
4959
4961
  }
4960
4962
  }