I didn't find anything on InfoSys on how to check this. You can pin/fix the project version, but this only changes things on the XAE side, not on the runtime.
I want to check the XAR version, because of a feature that was introduced in 4024.40. I want to make sure that this feature is available.
But now I'm wondering if it is necessary to have the runtime at a newer version as well. According to this question, a later XAE version compared to the XAR is ok. So in that case I can just upgrade the XAE version.
There are multiple ways. The first two need a local access to the Windows. The last one uses ADS and can be used remotely.
TwinCAT 4024 and newer has TcVersion
registry entry that contains the version. 4022 seems not to have it.
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Beckhoff\TwinCAT3\System
The version is displayed in about dialog. So right click TwinCAT tray icon (in the PLC - not on your PC!) and select About TwinCAT...
You can remotely read the full version number using ADS:
Response data example: 01 00 03 00 1b 00 b6 0f
01 00
-> 103 00
-> 31b 00
-> 27b6 0f
-> 4022Version number: 3.1.4022.27
Create a struct ST_TwincatVersion
:
{attribute 'pack_mode' := '1'}
TYPE ST_TwincatVersion :
STRUCT
num1 : UINT;
num2 : UINT;
num3 : UINT;
num4 : UINT;
END_STRUCT
END_TYPE
Code:
VAR
ReadVersionReq : BOOL;
AdsReader : ADSREADEX;
Version : ST_TwincatVersion;
END_VAR
//Set ReadVersionReq to TRUE to read version
AdsReader(
NETID := '192.168.1.50.1.1', //Change to correct address
PORT := 10000,
IDXGRP := 160,
IDXOFFS := 0,
LEN := SIZEOF(version),
DESTADDR:= ADR(Version),
READ := ReadVersionReq
);
//Note: No error handling
IF ReadVersionReq AND NOT AdsReader.BUSY THEN
ReadVersionReq := FALSE;
END_IF
Result:
const ads = require('ads-client');
const client = new ads.Client({
targetAmsNetId: '192.168.1.50.1.1', //Change to correct address
targetAdsPort: 10000,
bareClient: true
});
client.connect()
.then(async res => {
const data = await client.readRaw(160, 0, 8);
const versionNumbers = [
data.readInt16LE(2),
data.readInt16LE(0),
data.readInt16LE(6),
data.readInt16LE(4)
];
const versionStr = versionNumbers.join(".");
console.log(data); //<Buffer 01 00 03 00 1b 00 b6 0f>
console.log(versionNumbers); //[ 3, 1, 4022, 27 ]
console.log(versionStr); //3.1.4022.27
await client.disconnect();
})
.then(() => {
console.log('Disconnected');
})
.catch(err => {
console.log('Something failed:', err);
})