ethercat-linux/scripts/tc-register.ps1
Tony Cao 309aaba342 EL6695 8-byte bidirectional exchange with per-byte verification
- 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
2026-07-27 19:01:05 +08:00

67 lines
2.0 KiB
PowerShell

#Requires -Version 5.1
<#
.SYNOPSIS
Register TwinCAT COM components for headless automation.
.DESCRIPTION
Registers TcSysManager and related COM DLLs so that
New-Object -ComObject TcXaeShell.DTE.17.0 works without a prior
interactive TwinCAT session.
Run once from an elevated PowerShell.
.EXAMPLE
.\tc-register.ps1
.\tc-register.ps1 -RepairPackage
#>
[CmdletBinding()]
param(
[switch]$RepairPackage
)
$tcBase = "C:\Program Files (x86)\Beckhoff\TwinCAT\3.1\Components\Base"
$dlls = @(
"TwinCAT System Manager.dll",
"TcSysManCmd.dll",
"TcSysManRM.dll"
)
Write-Host "=== Register TwinCAT COM Components ===" -ForegroundColor Cyan
foreach ($dll in $dlls) {
$path = Join-Path $tcBase $dll
if (Test-Path $path) {
Write-Host " regsvr32: $dll" -NoNewline
& regsvr32 /s $path 2>&1 | Out-Null
Write-Host " done" -ForegroundColor Green
} else {
Write-Host " skip: $dll (not found)" -ForegroundColor Yellow
}
}
# .NET regasm for Automation DLL
$autoDll = Get-ChildItem -Path "C:\Program Files\TwinCAT\3.1\x64" -Filter "TwinCAT.XAE.Automation.*.dll" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($autoDll) {
$regasm = Join-Path $env:WINDIR "Microsoft.NET\Framework64\v4.0.30319\regasm.exe"
Write-Host " regasm: $($autoDll.Name)" -NoNewline
& $regasm /silent /codebase $autoDll.FullName 2>&1 | Out-Null
Write-Host " done" -ForegroundColor Green
}
if ($RepairPackage) {
Write-Host " TcPkg repair TwinCAT.Standard.XAE..." -NoNewline
& "C:\Program Files (x86)\Beckhoff\TwinCAT\3.1\Components\Base\TcPkg.exe" repair TwinCAT.Standard.XAE 2>&1 | Out-Null
Write-Host " done" -ForegroundColor Green
}
# Test
Write-Host " Testing TcXaeShell.DTE.17.0..." -NoNewline
try {
$test = New-Object -ComObject TcXaeShell.DTE.17.0 -ErrorAction Stop
$test.Quit()
Write-Host " OK" -ForegroundColor Green
} catch {
Write-Host " FAILED: $_" -ForegroundColor Red
}
Write-Host "=== Register complete ===" -ForegroundColor Cyan