ethercat-linux/scripts/tc-ads-verify-800b.ps1
Tony Cao f0163d8d70 800B PDO variant + long-term stability evidence + analysis docs
- twin_layout_blob_sized generalized: multi-entry TwinCAT line format
  (1 real @240bit + N continuation + remainder entry); 1024B path kept
  byte-identical; 800B = 27 entries verified on hardware
- 800B constants (PAYLOAD/SM 800), deployed as el6695_rt_800b
- 10-min + 5h stability runs: 18M cycles, zero errors, zero mismatches,
  PLC nMismatch frozen over the whole run (monitor_5h.csv evidence)
- docs: 800B plan/design/verification/test-report chapters,
  jitter analysis (NFS rootfs stall primary cause), D2000 dev plan
- scripts: 800B deploy/relink/verify, mismatch-delta, 5h monitor
2026-08-06 01:10:50 +08:00

49 lines
1.9 KiB
PowerShell

#Requires -RunAsAdministrator
#Requires -Version 5.1
$ErrorActionPreference = 'Continue'
$adsDll = 'C:\Program Files (x86)\Beckhoff\TwinCAT\3.1\Components\Base\v170\TwinCAT.Ads.dll'
Add-Type -Path $adsDll -ErrorAction Stop
$c = New-Object TwinCAT.Ads.TcAdsClient
$c.Connect('169.254.176.217.1.1', 851)
function ReadSym($name, $type) {
$h = $c.CreateVariableHandle($name)
$v = $c.ReadAny($h, $type)
$c.DeleteVariableHandle($h)
return $v
}
function ReadBytes($name, $len) {
$h = $c.CreateVariableHandle($name)
$arr = $c.ReadAny($h, [byte[]], @($len))
$c.DeleteVariableHandle($h)
return $arr
}
$nc = ReadSym 'GVL_Sync.nCycles' ([uint64])
$bs = ReadSym 'GVL_Sync.bSync' ([bool])
$nrs = ReadSym 'GVL_Sync.nReturnedSeq' ([uint64])
$nm = ReadSym 'GVL_Sync.nMismatch' ([int])
$in = ReadBytes 'GVL_Sync.aIn1' 800
$out = ReadBytes 'GVL_Sync.aOut1' 800
$nzIn = ($in | Where-Object { $_ -ne 0 }).Count
$nzOut = ($out | Where-Object { $_ -ne 0 }).Count
Write-Host ("nCycles={0} bSync={1} nReturnedSeq={2} lag={3} nMismatch={4}" -f $nc, $bs, $nrs, ($nc - $nrs), $nm)
Write-Host ("aIn1 nonzero = {0}/800" -f $nzIn)
Write-Host ("aOut1 nonzero = {0}/800" -f $nzOut)
# per-byte pattern check against nReturnedSeq: expected[i] = (nReturnedSeq + i) mod 256, pattern region
$bad = 0
$badIdx = @()
for ($i = 16; $i -lt 800; $i++) {
if ($i -ge 264 -and $i -le 279) { continue }
$exp = [byte](($nrs + $i) % 256)
if ($in[$i] -ne $exp) { $bad++; if ($badIdx.Count -lt 8) { $badIdx += $i } }
}
Write-Host ("pattern[16..799 excl 264..279] mismatches = {0} {1}" -f $bad, $(if ($badIdx.Count) { 'at ' + ($badIdx -join ',') } else { '' }))
# show window samples at several offsets
foreach ($off in @(0, 16, 128, 256, 288, 512, 768)) {
$seg = [BitConverter]::ToString($in[$off..($off + 7)])
Write-Host ("aIn1[{0,3}..{1,3}] = {2}" -f $off, ($off + 7), $seg)
}
$c.Dispose()