- 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
51 lines
1.9 KiB
PowerShell
51 lines
1.9 KiB
PowerShell
#Requires -Version 5.1
|
|
#Requires -RunAsAdministrator
|
|
$ErrorActionPreference = 'Continue'
|
|
|
|
$LogFile = "C:\Users\tonycao\work\twincat3-auto-cli\TwinCAT_EL6695_Secondary\Logs\dte-restart-system.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 "=== Restart TwinCAT System via DTE ==="
|
|
$dte = New-Object -ComObject TcXaeShell.DTE.17.0
|
|
$dte.MainWindow.Visible = $true
|
|
$dte.Solution.Open('C:\Users\tonycao\work\twincat3-auto-cli\TwinCAT_EL6695_Secondary\TwinCAT_EL6695_Secondary.sln')
|
|
for ($i=1; $i -le 120; $i++) { Start-Sleep -Seconds 1; if ($dte.Solution.IsOpen) { break } }
|
|
Write-Log "Solution open: $($dte.Solution.IsOpen)"
|
|
|
|
$cmdName = 'TwinCAT.重启TwinCAT系统'
|
|
try {
|
|
$cmd = $dte.Commands.Item($cmdName)
|
|
Write-Log "Command found: avail=$($cmd.IsAvailable) enabled=$($cmd.Enabled)"
|
|
if ($cmd.IsAvailable) {
|
|
$dte.ExecuteCommand($cmdName)
|
|
Write-Log "ExecuteCommand($cmdName) OK"
|
|
} else {
|
|
Write-Log "Command not available/enabled"
|
|
}
|
|
} catch { Write-Log "ERR: $($_.Exception.Message)" }
|
|
|
|
Start-Sleep -Seconds 10
|
|
|
|
# ADS diagnostics
|
|
$adsDll = 'C:\Program Files (x86)\Beckhoff\TwinCAT\3.1\Components\Base\v170\TwinCAT.Ads.dll'
|
|
Add-Type -Path $adsDll
|
|
function Read-State($NetId, $Port, $Label) {
|
|
$c = New-Object TwinCAT.Ads.TcAdsClient
|
|
try {
|
|
$c.Connect($NetId, $Port)
|
|
$s = $c.ReadState()
|
|
Write-Log "$Label state = $($s.AdsState) / deviceState = $($s.DeviceState)"
|
|
} catch { Write-Log "$Label ERR: $($_.Exception.Message)" } finally { $c.Dispose() }
|
|
}
|
|
Read-State '169.254.176.217.1.1' 10000 'System'
|
|
Read-State '169.254.176.217.1.1' 851 'PLC'
|
|
Read-State '169.254.176.217.2.1' 65535 'ECAT1'
|
|
|
|
try { $dte.Quit() } catch {}
|
|
Write-Log "=== done ==="
|