- 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
42 lines
1.5 KiB
PowerShell
42 lines
1.5 KiB
PowerShell
#Requires -Version 5.1
|
|
#Requires -RunAsAdministrator
|
|
$ErrorActionPreference = 'Continue'
|
|
|
|
$LogFile = "C:\Users\tonycao\work\twincat3-auto-cli\TwinCAT_EL6695_Secondary\Logs\tc-start-runtime.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 "=== Attempt to start TwinCAT runtime via ADS WriteControl ==="
|
|
|
|
$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 }
|
|
|
|
$netId = '169.254.176.217.1.1'
|
|
$port = 10000
|
|
|
|
$c = New-Object TwinCAT.Ads.TcAdsClient
|
|
try {
|
|
$c.Connect($netId, $port)
|
|
Write-Log "Connected to $netId : $port"
|
|
|
|
$before = $c.ReadState()
|
|
Write-Log "Before: AdsState = $($before.AdsState), DeviceState = $($before.DeviceState)"
|
|
|
|
Write-Log "Writing AdsState.Run..."
|
|
$stateInfo = New-Object TwinCAT.Ads.StateInfo([TwinCAT.Ads.AdsState]::Run, 0)
|
|
$c.WriteControl($stateInfo)
|
|
Write-Log "WriteControl Run OK"
|
|
|
|
Start-Sleep -Seconds 10
|
|
$after = $c.ReadState()
|
|
Write-Log "After: AdsState = $($after.AdsState), DeviceState = $($after.DeviceState)"
|
|
} catch {
|
|
Write-Log "ERR: $($_.Exception.Message)"
|
|
} finally { $c.Dispose() }
|
|
|
|
Write-Log "=== done ==="
|