- 8B PDO config: ULINT-sized payload, no 0x1A01 diag PDO on SM3 (device rejected SM3=8 with diag assigned: 'size not allowed, min/max 0xa') - twin_layout_blob_sized(): single 64-bit mapping entry for 8B payloads - Ticker: per-byte XOR 0x5A transform in 8B mode so TwinCAT can verify every byte individually (1KB path unchanged, const-guarded) - TwinCAT automation scripts: deploy with RPC retry, LinkVariables-based whole-array relink (element links only carry 1 byte), ADS watch, diag - Docs: 8B design, verification methodology, test report
43 lines
1.7 KiB
PowerShell
43 lines
1.7 KiB
PowerShell
#Requires -Version 5.1
|
|
#Requires -RunAsAdministrator
|
|
$ErrorActionPreference = 'Continue'
|
|
|
|
$LogFile = "C:\Users\tonycao\work\twincat3-auto-cli\TwinCAT_EL6695_Secondary\Logs\ads-probe.log"
|
|
New-Item -ItemType Directory -Force -Path (Split-Path $LogFile) | Out-Null
|
|
|
|
function Write-Log($Message) {
|
|
$line = "[{0}] {1}" -f (Get-Date -Format 'HH:mm:ss'), $Message
|
|
Write-Host $line
|
|
Add-Content -Path $LogFile -Value $line -Encoding UTF8
|
|
}
|
|
|
|
Write-Log "=== ADS probe ==="
|
|
|
|
$adsDll = 'C:\Program Files (x86)\Beckhoff\TwinCAT\3.1\Components\Base\v170\TwinCAT.Ads.dll'
|
|
try { Add-Type -Path $adsDll -ErrorAction Stop; Write-Log "TwinCAT.Ads loaded" } catch { Write-Log "FATAL: cannot load ADS dll: $_"; exit 1 }
|
|
|
|
function Read-Ads($NetId, $Port, $IGrp, $IOff, $Len, $Label) {
|
|
$c = New-Object TwinCAT.Ads.TcAdsClient
|
|
try {
|
|
$c.Connect($NetId, $Port)
|
|
$buf = New-Object byte[] $Len
|
|
$n = $c.Read([uint32]$IGrp, [uint32]$IOff, $buf, 0, $Len)
|
|
$hex = [BitConverter]::ToString($buf, 0, $n)
|
|
Write-Log "$Label OK n=$n : $hex"
|
|
} catch {
|
|
Write-Log "$Label ERR: $($_.Exception.Message)"
|
|
} finally { $c.Dispose() }
|
|
}
|
|
|
|
# Try various system/EtherCAT ports and index groups based on project history
|
|
Read-Ads '169.254.176.217.1.1' 10000 0 0 4 'SystemState(1.1,10000,0,0,4)'
|
|
Read-Ads '169.254.176.217.1.1' 65535 0 0 4 'SystemState(1.1,65535,0,0,4)'
|
|
Read-Ads '169.254.176.217.2.1' 65535 0x9 0 32 'ECATMaster(2.1,65535,0x9,0,32)'
|
|
Read-Ads '169.254.176.217.2.1' 2 0x9 0 32 'ECATMaster(2.1,2,0x9,0,32)'
|
|
Read-Ads '169.254.176.217.2.1' 10000 0x9 0 32 'ECATMaster(2.1,10000,0x9,0,32)'
|
|
|
|
# Try PLC port 851 (if PLC runtime is up)
|
|
Read-Ads '169.254.176.217.1.1' 851 0 0 4 'PLC(1.1,851,0,0,4)'
|
|
|
|
Write-Log "=== ADS probe complete ==="
|