├── .gitignore ├── CHANGELOG.md ├── LICENSE.txt ├── MIGRATION.md ├── README.md ├── docs ├── .nojekyll ├── assets │ ├── highlight.css │ ├── icons.js │ ├── icons.svg │ ├── main.js │ ├── navigation.js │ ├── search.js │ └── style.css ├── classes │ └── Client.html ├── functions │ ├── ADS.amsAddressToString.html │ ├── ADS.amsNetIdStrToByteArray.html │ ├── ADS.byteArrayToAmsNetIdStr.html │ ├── ADS.decodePlcStringBuffer.html │ ├── ADS.decodePlcWstringBuffer.html │ ├── ADS.encodeStringToPlcStringBuffer.html │ ├── ADS.encodeStringToPlcWstringBuffer.html │ └── ADS.trimPlcString.html ├── hierarchy.html ├── index.html ├── interfaces │ ├── ActiveAdsRequest.html │ ├── ActiveAdsRequestContainer.html │ ├── ActiveSubscription.html │ ├── ActiveSubscriptionContainer.html │ ├── AdsAddNotificationResponse.html │ ├── AdsAddNotificationResponseData.html │ ├── AdsArrayInfoEntry.html │ ├── AdsAttributeEntry.html │ ├── AdsClientConnection.html │ ├── AdsClientEvents.html │ ├── AdsClientSettings.html │ ├── AdsCommandToSend.html │ ├── AdsDataType.html │ ├── AdsDataTypeContainer.html │ ├── AdsDeleteNotificationResponse.html │ ├── AdsDeviceInfo.html │ ├── AdsEnumInfoEntry.html │ ├── AdsError.html │ ├── AdsNotification.html │ ├── AdsNotificationResponse.html │ ├── AdsNotificationSample.html │ ├── AdsNotificationStamp.html │ ├── AdsRawAddress.html │ ├── AdsReadDeviceInfoResponse.html │ ├── AdsReadResponse.html │ ├── AdsReadStateResponse.html │ ├── AdsReadWriteResponse.html │ ├── AdsRequest.html │ ├── AdsRpcMethodEntry.html │ ├── AdsRpcMethodParameterEntry.html │ ├── AdsState.html │ ├── AdsSymbol.html │ ├── AdsSymbolContainer.html │ ├── AdsTcSystemExtendedState.html │ ├── AdsUploadInfo.html │ ├── AdsWriteControlResponse.html │ ├── AdsWriteResponse.html │ ├── AmsAddress.html │ ├── AmsHeader.html │ ├── AmsRouterState.html │ ├── AmsRouterStateData.html │ ├── AmsTcpHeader.html │ ├── AmsTcpPacket.html │ ├── BaseAdsResponse.html │ ├── ConnectionMetaData.html │ ├── CreateVariableHandleMultiResult.html │ ├── DeleteVariableHandleMultiResult.html │ ├── ObjectToBufferConversionResult.html │ ├── ReadRawMultiCommand.html │ ├── ReadRawMultiResult.html │ ├── ReadValueResult.html │ ├── ReadWriteRawMultiCommand.html │ ├── ReadWriteRawMultiResult.html │ ├── RpcMethodCallResult.html │ ├── SendAdsCommandWithFallbackResult.html │ ├── SubscriptionData.html │ ├── SubscriptionSettings.html │ ├── TargetActiveSubscriptionContainer.html │ ├── TimerObject.html │ ├── UnknownAdsResponse.html │ ├── VariableHandle.html │ ├── WriteRawMultiCommand.html │ ├── WriteRawMultiResult.html │ └── WriteValueResult.html ├── modules.html ├── modules │ └── ADS.html ├── types │ ├── AdsData.html │ ├── AdsResponse.html │ ├── AdsTcSystemState.html │ ├── AmsPortRegisteredData.html │ ├── DebugLevel.html │ ├── EmptyAdsResponse.html │ ├── PlcPrimitiveType.html │ └── SubscriptionCallback.html └── variables │ ├── ADS.ADS_COMMAND.html │ ├── ADS.ADS_DATA_TYPES.html │ ├── ADS.ADS_DATA_TYPE_FLAGS.html │ ├── ADS.ADS_DEFAULT_TCP_PORT.html │ ├── ADS.ADS_ERROR.html │ ├── ADS.ADS_INDEX_GROUP_LENGTH.html │ ├── ADS.ADS_INDEX_OFFSET_LENGTH.html │ ├── ADS.ADS_INVOKE_ID_MAX_VALUE.html │ ├── ADS.ADS_RCP_METHOD_FLAGS.html │ ├── ADS.ADS_RCP_METHOD_PARAM_FLAGS.html │ ├── ADS.ADS_RESERVED_INDEX_GROUPS.html │ ├── ADS.ADS_RESERVED_PORTS.html │ ├── ADS.ADS_STATE.html │ ├── ADS.ADS_STATE_FLAGS.html │ ├── ADS.ADS_SYMBOL_FLAGS.html │ ├── ADS.ADS_SYMBOL_FLAGS_2.html │ ├── ADS.ADS_SYSTEM_SERVICE_STATE_FLAGS.html │ ├── ADS.ADS_TRANS_MODE.html │ ├── ADS.ADS_UPLOAD_INFO_FLAGS.html │ ├── ADS.AMS_HEADER_FLAG.html │ ├── ADS.AMS_HEADER_LENGTH.html │ ├── ADS.AMS_NET_ID_LENGTH.html │ ├── ADS.AMS_ROUTER_STATE.html │ ├── ADS.AMS_TCP_HEADER_LENGTH.html │ ├── ADS.BASE_DATA_TYPES.html │ └── ADS.LOOPBACK_AMS_NET_ID.html ├── img ├── connection_setup.png └── fb_rpc.png ├── package-lock.json ├── package.json ├── src ├── ads-client.ts ├── ads-commons.ts ├── client-error.ts └── types │ ├── ads-client-types.ts │ └── ads-protocol-types.ts ├── test ├── TC2 │ ├── ads-client-test-helper.js │ └── ads-client.test.js ├── TC3 │ ├── ads-client-test-helper.js │ └── ads-client.test.js └── jest.config.js ├── tsconfig.json └── typedoc.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | # Ignore files with sensitive environment variables 3 | .env 4 | .env.test 5 | # Next.js output 6 | .next/ 7 | # Parcel cache 8 | .cache/ 9 | # Ignore IDE configuration files 10 | .idea/ 11 | .vscode/ 12 | # Logs 13 | logs 14 | *.log 15 | npm-debug.log* 16 | yarn-debug.log* 17 | yarn-error.log* 18 | /dist 19 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Jussi Isotalo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /docs/assets/highlight.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --light-hl-0: #001080; 3 | --dark-hl-0: #9CDCFE; 4 | --light-hl-1: #000000; 5 | --dark-hl-1: #D4D4D4; 6 | --light-hl-2: #008000; 7 | --dark-hl-2: #6A9955; 8 | --light-hl-3: #0000FF; 9 | --dark-hl-3: #569CD6; 10 | --light-hl-4: #0070C1; 11 | --dark-hl-4: #4FC1FF; 12 | --light-hl-5: #795E26; 13 | --dark-hl-5: #DCDCAA; 14 | --light-hl-6: #A31515; 15 | --dark-hl-6: #CE9178; 16 | --light-hl-7: #AF00DB; 17 | --dark-hl-7: #C586C0; 18 | --light-hl-8: #098658; 19 | --dark-hl-8: #B5CEA8; 20 | --light-hl-9: #000000FF; 21 | --dark-hl-9: #D4D4D4; 22 | --light-hl-10: #000000; 23 | --dark-hl-10: #C8C8C8; 24 | --light-hl-11: #267F99; 25 | --dark-hl-11: #4EC9B0; 26 | --light-hl-12: #CD3131; 27 | --dark-hl-12: #F44747; 28 | --light-code-background: #FFFFFF; 29 | --dark-code-background: #1E1E1E; 30 | } 31 | 32 | @media (prefers-color-scheme: light) { :root { 33 | --hl-0: var(--light-hl-0); 34 | --hl-1: var(--light-hl-1); 35 | --hl-2: var(--light-hl-2); 36 | --hl-3: var(--light-hl-3); 37 | --hl-4: var(--light-hl-4); 38 | --hl-5: var(--light-hl-5); 39 | --hl-6: var(--light-hl-6); 40 | --hl-7: var(--light-hl-7); 41 | --hl-8: var(--light-hl-8); 42 | --hl-9: var(--light-hl-9); 43 | --hl-10: var(--light-hl-10); 44 | --hl-11: var(--light-hl-11); 45 | --hl-12: var(--light-hl-12); 46 | --code-background: var(--light-code-background); 47 | } } 48 | 49 | @media (prefers-color-scheme: dark) { :root { 50 | --hl-0: var(--dark-hl-0); 51 | --hl-1: var(--dark-hl-1); 52 | --hl-2: var(--dark-hl-2); 53 | --hl-3: var(--dark-hl-3); 54 | --hl-4: var(--dark-hl-4); 55 | --hl-5: var(--dark-hl-5); 56 | --hl-6: var(--dark-hl-6); 57 | --hl-7: var(--dark-hl-7); 58 | --hl-8: var(--dark-hl-8); 59 | --hl-9: var(--dark-hl-9); 60 | --hl-10: var(--dark-hl-10); 61 | --hl-11: var(--dark-hl-11); 62 | --hl-12: var(--dark-hl-12); 63 | --code-background: var(--dark-code-background); 64 | } } 65 | 66 | :root[data-theme='light'] { 67 | --hl-0: var(--light-hl-0); 68 | --hl-1: var(--light-hl-1); 69 | --hl-2: var(--light-hl-2); 70 | --hl-3: var(--light-hl-3); 71 | --hl-4: var(--light-hl-4); 72 | --hl-5: var(--light-hl-5); 73 | --hl-6: var(--light-hl-6); 74 | --hl-7: var(--light-hl-7); 75 | --hl-8: var(--light-hl-8); 76 | --hl-9: var(--light-hl-9); 77 | --hl-10: var(--light-hl-10); 78 | --hl-11: var(--light-hl-11); 79 | --hl-12: var(--light-hl-12); 80 | --code-background: var(--light-code-background); 81 | } 82 | 83 | :root[data-theme='dark'] { 84 | --hl-0: var(--dark-hl-0); 85 | --hl-1: var(--dark-hl-1); 86 | --hl-2: var(--dark-hl-2); 87 | --hl-3: var(--dark-hl-3); 88 | --hl-4: var(--dark-hl-4); 89 | --hl-5: var(--dark-hl-5); 90 | --hl-6: var(--dark-hl-6); 91 | --hl-7: var(--dark-hl-7); 92 | --hl-8: var(--dark-hl-8); 93 | --hl-9: var(--dark-hl-9); 94 | --hl-10: var(--dark-hl-10); 95 | --hl-11: var(--dark-hl-11); 96 | --hl-12: var(--dark-hl-12); 97 | --code-background: var(--dark-code-background); 98 | } 99 | 100 | .hl-0 { color: var(--hl-0); } 101 | .hl-1 { color: var(--hl-1); } 102 | .hl-2 { color: var(--hl-2); } 103 | .hl-3 { color: var(--hl-3); } 104 | .hl-4 { color: var(--hl-4); } 105 | .hl-5 { color: var(--hl-5); } 106 | .hl-6 { color: var(--hl-6); } 107 | .hl-7 { color: var(--hl-7); } 108 | .hl-8 { color: var(--hl-8); } 109 | .hl-9 { color: var(--hl-9); } 110 | .hl-10 { color: var(--hl-10); } 111 | .hl-11 { color: var(--hl-11); } 112 | .hl-12 { color: var(--hl-12); } 113 | pre, code { background: var(--code-background); } 114 | -------------------------------------------------------------------------------- /docs/assets/navigation.js: -------------------------------------------------------------------------------- 1 | window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAACp2YXXObOBSG/wvXme0223Z3c0ds0mRqGwZw0k4nw8hwkrAB4RVyUs9O//sOJjYIpHNEb63nPC/6tOD7f46EH9K5cGZFDlw6Z076lBeZAO5cfD81uvPIOXO2TD45F05ZZbsC6nfuPPrtSZaFc+Y85zxzLj4Yi5OZv1y6q3kneWEiZ5ujpoeoyj/Of54porkbu0n8LfCSq4X7OcKEA9RWbOckdd6Vu17ESTwLksAPY1Q6YAm1F4Z+iPkOACG5Wc29r8nn0F8HycJbfY6vMeOYttL7V1eRF1v7FZwMuPW/eMnNPFm6X5Nbd7H28IARTgSEsyBZevG1P6dX2pC1Vwdu6C4nBfQqqBgv8sJbb96fPTxFV2Ab0ixcO/uBJLRR7MbohB4AGwk9uD2MEn5bXvoLC2OPm6BMzm2lyTmpjWJvmTQjfjPzrEfCWEXExaG7ipKlP0fnrKMI3TpY+G6zDK98+qFHMCZfRsm158698IAatSpmJyROuSFISFde3JxWtFQBCWnor2MvJDbXgCOUzX+W9QCMYER+6UaexZ/yAEOEC98PLt3Zl6QbNZNUgyJiVtZulgmo67iKpMj5Y+d92PFU5hVvvWNS1X76oGpXIG+ySIq4utxLcIVge0StoRH95sjEldvVmvR6GtFnkFYZBEXa9vNy9/AARrsWtpHf1VPsCo3ogTcF7bPElWUf0KIpYVZ9wquQOCny8vRwJrsCjWT3Pd3preHNkxasrqF+1/6ulr4//0upjfdbqE0vHKnMX8DN6hD+3UHdS8i5BPHA0marDiA17vzjp/5ZNWBnFZcs5/0RRswnmo6Idps6Ffm2GU3E3cemSW2eXMujMVlzMq0qmT/kKWvKQqi3Fa9Bn2LEfy1kziSbGNSUUGHNgXXDHyqPS7E3+hWKUkop8s1OAq5UKELZbpVZxTmk5kUz5qy03gtwWePKlrHSRSBlzh8J4ZGilFVZMp7FVQQ8Mxr7ECFslkRzqJhcx3ZLDbHRNCAlhgIkTNlk5goy6iVPoVnVZvWRIFQe35XkJlIgSihEZRzTQyMh6I+HydNnJuioCfmFqeiXRKzcFlbylpyilqzcWpkbkBCH7PXtomoydgSlApZ1a40aXz1tEWEjnqCLJJNg41RAC/GdyO3ECkiKkUuS3fUoq8NtugT5VGXoRlcpW2XABCtBgrBzqzgRcpgBk/LQSAn25aYqjIZDq5WC/MMYYIQ0TqN9LaH0fkjgGWRoR7UwEbDeFhXLsD+JjiBUh9XadExUBbW6dayN3sprJTy9hutVp2ZCcg0sM032sZVQhNVOgkBmVkHsZeYL9QgjpHG6xft5AmhRwNJnMBxTPQATXbK6fS9D1sKAwXTddXoJkhlHbYyhUgFMwu3bJ6VrxrMClrtC5iHUu0Lff6IGi2svidPiiBoszt/8A6mMq/ZTw6ziLyDq9jpkSsNLsLDD3zZ7PTza26uANkHD2WqR5x5jlPSWFTsgjD2G0rVHmmX/dfCkAOK5NSyqP/6bz1hRYOoxh2mb98DuvfAul09XrCg2LH1GMqgiNLD3LcV4QAwhWyH6Qq0DMXHMxCPIqV+MyCo0Mi9BtNtbL+/aMc2aP/PqlVMH+xjDpOrpphWqCCaz3olTd6HtDpy4+w44dRoNIYsPI51HNp9vj59BBpW///3n+4/navV4Zk8Gw2zqLMd77uDKdFIp7aSvrINKyBAe81qCgEzbQx1Emeew2T0u4AWKoa5roRxeuZV7ZOCG7ZQvKNJA5GXebHT1M1nrG7ZTPuWweDtOh04do/fe/7z/H1Y6X6aNJAAA" -------------------------------------------------------------------------------- /docs/functions/ADS.amsAddressToString.html: -------------------------------------------------------------------------------- 1 | amsAddressToString | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Converts given AmsAddress as string of type amsNetId:port

2 |
  • Parameters

    Returns string

3 | -------------------------------------------------------------------------------- /docs/functions/ADS.amsNetIdStrToByteArray.html: -------------------------------------------------------------------------------- 1 | amsNetIdStrToByteArray | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Converts AmsNetId string (such as 192.168.10.1.1) to array of bytes

2 |
  • Parameters

    • str: string

      AmsNetId as string

      3 |

    Returns number[]

4 | -------------------------------------------------------------------------------- /docs/functions/ADS.byteArrayToAmsNetIdStr.html: -------------------------------------------------------------------------------- 1 | byteArrayToAmsNetIdStr | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Converts array of bytes (or Buffer) to AmsNetId string, such as 192.168.1.10.1.1

2 |
  • Parameters

    • byteArray: Buffer | number[]

      Array of bytes or Buffer object

      3 |

    Returns string

4 | -------------------------------------------------------------------------------- /docs/functions/ADS.decodePlcStringBuffer.html: -------------------------------------------------------------------------------- 1 | decodePlcStringBuffer | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Decodes provided Buffer object to plc STRING using cp1252 encoding or UTF-8. 2 | Also removes empty bytes from the end.

3 |
  • Parameters

    • data: Buffer

      Buffer data that contains plc STRING

      4 |
    • UTF8: boolean = false

      If true, the value is handled as UTF-8, otherwise as cp1252.

      5 |

    Returns string

6 | -------------------------------------------------------------------------------- /docs/functions/ADS.decodePlcWstringBuffer.html: -------------------------------------------------------------------------------- 1 | decodePlcWstringBuffer | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Decodes provided Buffer object to plc WSTRING using ucs2 encoding. 2 | Also removes empty bytes from the end.

3 |
  • Parameters

    • data: Buffer

      Buffer data that contains plc WSTRING

      4 |

    Returns string

5 | -------------------------------------------------------------------------------- /docs/functions/ADS.encodeStringToPlcStringBuffer.html: -------------------------------------------------------------------------------- 1 | encodeStringToPlcStringBuffer | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Encodes provided string to a Buffer object as plc STRING using cp1252 encoding

2 |
  • Parameters

    • str: string

      String to encode

      3 |
    • UTF8: boolean = false

      If true, the value is encoded as UTF-8, otherwise as cp1252.

      4 |

    Returns Buffer

5 | -------------------------------------------------------------------------------- /docs/functions/ADS.encodeStringToPlcWstringBuffer.html: -------------------------------------------------------------------------------- 1 | encodeStringToPlcWstringBuffer | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Encodes provided string to a Buffer object as plc WSTRING using ucs2 encoding

2 |
  • Parameters

    • str: string

      String to encode

      3 |

    Returns Buffer

4 | -------------------------------------------------------------------------------- /docs/functions/ADS.trimPlcString.html: -------------------------------------------------------------------------------- 1 | trimPlcString | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Trims the given PLC string until end mark (\0) is found (removes empty bytes from the end)

2 |
  • Parameters

    • str: string

      String to trim

      3 |

    Returns string

    Trimmed string

    4 |
5 | -------------------------------------------------------------------------------- /docs/interfaces/ActiveAdsRequestContainer.html: -------------------------------------------------------------------------------- 1 | ActiveAdsRequestContainer | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Object containing all active ADS requests that are waiting for responses

2 |

Invoke ID is used as a key

3 |

Indexable

4 | -------------------------------------------------------------------------------- /docs/interfaces/ActiveSubscriptionContainer.html: -------------------------------------------------------------------------------- 1 | ActiveSubscriptionContainer | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Object containing all active subscriptions for each target address

2 |

Target address (amsNetId:port) is used as a key

3 |

Indexable

4 | -------------------------------------------------------------------------------- /docs/interfaces/AdsAddNotificationResponseData.html: -------------------------------------------------------------------------------- 1 | AdsAddNotificationResponseData | ads-client | Beckhoff TwinCAT ADS client library for Node.js

ADS AddNotification response payload

2 |
interface AdsAddNotificationResponseData {
    notificationHandle: number;
}

Properties

Properties

notificationHandle: number

Notification handle

4 |
5 | -------------------------------------------------------------------------------- /docs/interfaces/AdsAttributeEntry.html: -------------------------------------------------------------------------------- 1 | AdsAttributeEntry | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Attribute entry for symbol, data type, RPC method etc.

2 |
interface AdsAttributeEntry {
    name: string;
    value: string;
}

Properties

name 3 | value 4 |

Properties

name: string

Attribute name

5 |
value: string

Attribute value

6 |
7 | -------------------------------------------------------------------------------- /docs/interfaces/AdsDataTypeContainer.html: -------------------------------------------------------------------------------- 1 | AdsDataTypeContainer | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Object containing PLC runtime data type objects

2 |

Indexable

3 | -------------------------------------------------------------------------------- /docs/interfaces/AdsError.html: -------------------------------------------------------------------------------- 1 | AdsError | ads-client | Beckhoff TwinCAT ADS client library for Node.js

ADS error

2 |
interface AdsError {
    errorCode: number;
    errorStr?: string;
}

Properties

Properties

errorCode: number

ADS error code (0 = no error, -1 = other than ADS error)

5 |
errorStr?: string

ADS error string

6 |
7 | -------------------------------------------------------------------------------- /docs/interfaces/AdsRequest.html: -------------------------------------------------------------------------------- 1 | AdsRequest | ads-client | Beckhoff TwinCAT ADS client library for Node.js

ADS request

2 |
interface AdsRequest {
    payload?: Buffer;
}

Properties

Properties

payload?: Buffer

Payload of the ADS request (if any)

4 |
5 | -------------------------------------------------------------------------------- /docs/interfaces/AdsSymbolContainer.html: -------------------------------------------------------------------------------- 1 | AdsSymbolContainer | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Object containing PLC runtime symbol information objects

2 |

Indexable

3 | -------------------------------------------------------------------------------- /docs/interfaces/AmsRouterState.html: -------------------------------------------------------------------------------- 1 | AmsRouterState | ads-client | Beckhoff TwinCAT ADS client library for Node.js

AMS router state

2 |
interface AmsRouterState {
    state: number;
    stateStr: string;
}

Properties

state 3 | stateStr 4 |

Properties

state: number

Router state

5 |
stateStr: string

Router state as string

6 |
7 | -------------------------------------------------------------------------------- /docs/interfaces/AmsRouterStateData.html: -------------------------------------------------------------------------------- 1 | AmsRouterStateData | ads-client | Beckhoff TwinCAT ADS client library for Node.js

AmsTcpHeader data that is received when AMS router state changes

2 |
interface AmsRouterStateData {
    routerState: number;
}

Properties

Properties

routerState: number

New router state as number

4 |
5 | -------------------------------------------------------------------------------- /docs/interfaces/TargetActiveSubscriptionContainer.html: -------------------------------------------------------------------------------- 1 | TargetActiveSubscriptionContainer | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Object containing all active subscriptions for each notification handle (for one target)

2 |

Notification handle is used as a key

3 |

Indexable

4 | -------------------------------------------------------------------------------- /docs/interfaces/TimerObject.html: -------------------------------------------------------------------------------- 1 | TimerObject | ads-client | Beckhoff TwinCAT ADS client library for Node.js

Internal timer object to keep the timer state saved

2 |
interface TimerObject {
    id: number;
    timer?: Timeout;
}

Properties

id 3 | timer? 4 |

Properties

id: number

Timer ID

5 |
timer?: Timeout

Timer handle

6 |
7 | -------------------------------------------------------------------------------- /docs/types/AdsData.html: -------------------------------------------------------------------------------- 1 | AdsData | ads-client | Beckhoff TwinCAT ADS client library for Node.js
3 | -------------------------------------------------------------------------------- /docs/types/AdsResponse.html: -------------------------------------------------------------------------------- 1 | AdsResponse | ads-client | Beckhoff TwinCAT ADS client library for Node.js
3 | -------------------------------------------------------------------------------- /docs/types/AdsTcSystemState.html: -------------------------------------------------------------------------------- 1 | AdsTcSystemState | ads-client | Beckhoff TwinCAT ADS client library for Node.js
AdsTcSystemState: AdsState & Partial<AdsTcSystemExtendedState>

TwinCAT system service state

2 |

In all cases, contains the AdsState fields. 3 | More fields are available if target supports extended state.

4 |
5 | -------------------------------------------------------------------------------- /docs/types/AmsPortRegisteredData.html: -------------------------------------------------------------------------------- 1 | AmsPortRegisteredData | ads-client | Beckhoff TwinCAT ADS client library for Node.js
AmsPortRegisteredData: AmsAddress

AmsTcpHeader data that is received when AMS port is registered from the router

2 |
3 | -------------------------------------------------------------------------------- /docs/types/DebugLevel.html: -------------------------------------------------------------------------------- 1 | DebugLevel | ads-client | Beckhoff TwinCAT ADS client library for Node.js
DebugLevel:
    | 0
    | 1
    | 2
    | 3

Possible debug levels

2 |
3 | -------------------------------------------------------------------------------- /docs/types/EmptyAdsResponse.html: -------------------------------------------------------------------------------- 1 | EmptyAdsResponse | ads-client | Beckhoff TwinCAT ADS client library for Node.js
EmptyAdsResponse: {
    [K in any]: never
}

Empty ADS response (no payload)

2 |
3 | -------------------------------------------------------------------------------- /docs/types/PlcPrimitiveType.html: -------------------------------------------------------------------------------- 1 | PlcPrimitiveType | ads-client | Beckhoff TwinCAT ADS client library for Node.js
PlcPrimitiveType:
    | string
    | boolean
    | number
    | Buffer
    | Date
    | BigInt

PLC primitive types (not structs, function blocks etc.)

2 |
3 | -------------------------------------------------------------------------------- /docs/types/SubscriptionCallback.html: -------------------------------------------------------------------------------- 1 | SubscriptionCallback | ads-client | Beckhoff TwinCAT ADS client library for Node.js
SubscriptionCallback<T>: ((data: SubscriptionData<T>, subscription: ActiveSubscription<T>) => void)

Represents a callback function used in a subscription.

2 |

Type Parameters

  • T = any

    The type of data being passed to the callback

    3 |

Type declaration

6 | -------------------------------------------------------------------------------- /docs/variables/ADS.ADS_DEFAULT_TCP_PORT.html: -------------------------------------------------------------------------------- 1 | ADS_DEFAULT_TCP_PORT | ads-client | Beckhoff TwinCAT ADS client library for Node.js
ADS_DEFAULT_TCP_PORT = 48898

Default ADS server TCP port for incoming connections

2 |
3 | -------------------------------------------------------------------------------- /docs/variables/ADS.ADS_ERROR.html: -------------------------------------------------------------------------------- 1 | ADS_ERROR | ads-client | Beckhoff TwinCAT ADS client library for Node.js
ADS_ERROR: Record<number, string> = ...

ADS error code

2 |

Source: Beckhoff InfoSys

3 |
4 | -------------------------------------------------------------------------------- /docs/variables/ADS.ADS_INDEX_GROUP_LENGTH.html: -------------------------------------------------------------------------------- 1 | ADS_INDEX_GROUP_LENGTH | ads-client | Beckhoff TwinCAT ADS client library for Node.js
ADS_INDEX_GROUP_LENGTH = 4

ADS index group length

2 |
3 | -------------------------------------------------------------------------------- /docs/variables/ADS.ADS_INDEX_OFFSET_LENGTH.html: -------------------------------------------------------------------------------- 1 | ADS_INDEX_OFFSET_LENGTH | ads-client | Beckhoff TwinCAT ADS client library for Node.js
ADS_INDEX_OFFSET_LENGTH = 4

ADS index offset length

2 |
3 | -------------------------------------------------------------------------------- /docs/variables/ADS.ADS_INVOKE_ID_MAX_VALUE.html: -------------------------------------------------------------------------------- 1 | ADS_INVOKE_ID_MAX_VALUE | ads-client | Beckhoff TwinCAT ADS client library for Node.js
ADS_INVOKE_ID_MAX_VALUE = 4294967295

ADS invoke ID maximum value (32bit unsigned integer)

2 |
3 | -------------------------------------------------------------------------------- /docs/variables/ADS.AMS_HEADER_LENGTH.html: -------------------------------------------------------------------------------- 1 | AMS_HEADER_LENGTH | ads-client | Beckhoff TwinCAT ADS client library for Node.js
AMS_HEADER_LENGTH = 32

AMS header length

2 |
3 | -------------------------------------------------------------------------------- /docs/variables/ADS.AMS_NET_ID_LENGTH.html: -------------------------------------------------------------------------------- 1 | AMS_NET_ID_LENGTH | ads-client | Beckhoff TwinCAT ADS client library for Node.js
AMS_NET_ID_LENGTH = 6

AmsNetId length

2 |
3 | -------------------------------------------------------------------------------- /docs/variables/ADS.AMS_ROUTER_STATE.html: -------------------------------------------------------------------------------- 1 | AMS_ROUTER_STATE | ads-client | Beckhoff TwinCAT ADS client library for Node.js
AMS_ROUTER_STATE: {
    REMOVED: number;
    START: number;
    STOP: number;
    toString: ((value: number) => string);
} = ...

AMS router state

2 |

Type declaration

  • REMOVED: number

    Router is remove (unavailable?)

    3 |
  • START: number

    Router is started

    4 |
  • STOP: number

    Router is stopped

    5 |
  • toString: ((value: number) => string)

    Returns the corresponding key as string by given value (number)

    6 |
      • (value): string
      • Parameters

        • value: number

        Returns string

7 | -------------------------------------------------------------------------------- /docs/variables/ADS.AMS_TCP_HEADER_LENGTH.html: -------------------------------------------------------------------------------- 1 | AMS_TCP_HEADER_LENGTH | ads-client | Beckhoff TwinCAT ADS client library for Node.js
AMS_TCP_HEADER_LENGTH = 6

AMS/TCP header length

2 |
3 | -------------------------------------------------------------------------------- /docs/variables/ADS.LOOPBACK_AMS_NET_ID.html: -------------------------------------------------------------------------------- 1 | LOOPBACK_AMS_NET_ID | ads-client | Beckhoff TwinCAT ADS client library for Node.js
LOOPBACK_AMS_NET_ID: "127.0.0.1.1.1" = '127.0.0.1.1.1'

Loopback (localhost) AmsNetId

2 |
3 | -------------------------------------------------------------------------------- /img/connection_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jisotalo/ads-client/06fb33d14a885a7ef8ef7724de4aee6c02cf7543/img/connection_setup.png -------------------------------------------------------------------------------- /img/fb_rpc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jisotalo/ads-client/06fb33d14a885a7ef8ef7724de4aee6c02cf7543/img/fb_rpc.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ads-client", 3 | "version": "2.1.0", 4 | "description": "Beckhoff TwinCAT ADS client library for Node.js (unofficial). Connect to a Beckhoff TwinCAT automation system using the ADS protocol from a Node.js app.", 5 | "main": "./dist/ads-client.js", 6 | "scripts": { 7 | "test-tc3": "jest --runInBand TC3/ads-client.test.js", 8 | "test-tc2": "jest --runInBand TC2/ads-client.test.js", 9 | "build": "tsc", 10 | "watch": "tsc -w", 11 | "create-docs": "npx typedoc" 12 | }, 13 | "keywords": [ 14 | "ads", 15 | "twincat", 16 | "beckhoff", 17 | "plc", 18 | "iec-61131-3", 19 | "61131-3", 20 | "twincat 2", 21 | "twincat 2.11", 22 | "twincat 3", 23 | "twincat 3.1", 24 | "twincat ads", 25 | "twincat-ads", 26 | "codesys", 27 | "client" 28 | ], 29 | "author": "Jussi Isotalo (https://github.com/jisotalo)", 30 | "license": "MIT", 31 | "homepage": "https://github.com/jisotalo/ads-client/", 32 | "bugs": { 33 | "url": "https://github.com/jisotalo/ads-client/issues" 34 | }, 35 | "repository": { 36 | "type": "git", 37 | "url": "https://github.com/jisotalo/ads-client.git" 38 | }, 39 | "dependencies": { 40 | "debug": "^4.4.0", 41 | "iconv-lite": "^0.6.3", 42 | "long": "^5.2.3" 43 | }, 44 | "devDependencies": { 45 | "@tsconfig/node16": "^16.1.3", 46 | "@types/debug": "^4.1.12", 47 | "@types/jest": "^29.5.14", 48 | "@types/node": "^22.10.2", 49 | "jest": "^29.7.0", 50 | "typedoc": "^0.26.5", 51 | "typescript": "^5.5.4" 52 | }, 53 | "files": [ 54 | "dist/", 55 | "CHANGELOG.md", 56 | "README.md" 57 | ], 58 | "types": "./dist/ads-client.d.ts" 59 | } 60 | -------------------------------------------------------------------------------- /src/client-error.ts: -------------------------------------------------------------------------------- 1 | import { AdsError, AmsHeader, BaseAdsResponse } from "./types/ads-protocol-types"; 2 | 3 | export default class ClientError extends Error { 4 | public adsError?: AdsError; 5 | public trace: string[] = []; 6 | 7 | constructor(message?: string, adsError?: unknown) { 8 | super(message); 9 | Object.setPrototypeOf(this, new.target.prototype); 10 | this.name = "ClientError"; 11 | message && this.trace.push(message); 12 | 13 | if (adsError !== undefined && (adsError as Error).stack) { 14 | //console.log("moro:", this.stack) 15 | //process.exit() 16 | this.stack = this.stack + "\n" + (adsError as Error).stack;//+ this.stack?.split('\n').slice(0, 2).join('\n') + '\n'; 17 | } 18 | 19 | if (adsError instanceof ClientError) { 20 | this.adsError = adsError.adsError; 21 | this.trace = this.trace.concat(adsError.trace); 22 | 23 | } else if (!(adsError instanceof Error) && adsError !== undefined) { 24 | const error = adsError as AdsError; 25 | 26 | this.adsError = { 27 | errorCode: error.errorCode, 28 | errorStr: error.errorStr 29 | }; 30 | } 31 | Object.setPrototypeOf(this, ClientError.prototype); 32 | } 33 | } -------------------------------------------------------------------------------- /test/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('jest').Config} */ 2 | const config = { 3 | // Enable worker threads for assertion failures involving BigInt 4 | // See https://github.com/jestjs/jest/issues/11617#issuecomment-1458155552 5 | //workerThreads: true, 6 | maxWorkers: 1, 7 | }; 8 | 9 | module.exports = config; -------------------------------------------------------------------------------- /typedoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://typedoc.org/schema.json", 3 | "entryPoints": ["./src/ads-client.ts"], 4 | "out": "docs", 5 | "excludeExternals": true, 6 | "disableSources": true, 7 | "navigationLeaves": [], 8 | "navigation": { 9 | "includeCategories": true 10 | }, 11 | "searchInDocuments": true, 12 | "searchInComments": true, 13 | "visibilityFilters": {}, 14 | "navigationLinks": { 15 | "Documentation": "https://jisotalo.fi/ads-client/classes/Client.html", 16 | "README": "https://jisotalo.fi/ads-client/index.html", 17 | "Discussion & Support": "https://github.com/jisotalo/ads-client/discussions", 18 | "GitHub": "https://github.com/jisotalo/ads-client/", 19 | "NPM": "https://www.npmjs.com/package/ads-client/", 20 | }, 21 | "name": "ads-client | Beckhoff TwinCAT ADS client library for Node.js" 22 | } --------------------------------------------------------------------------------