enet-validator/scripts/session/cold2_order.ps1

25 lines
1.8 KiB
PowerShell
Raw Permalink Normal View History

[Console]::OutputEncoding = [Text.Encoding]::UTF8
$f = "$env:TEMP\opencode\cold2.tsv"
$lines = [IO.File]::ReadAllLines($f)
function H2B($hex) { $n = $hex.Length / 2; $b = New-Object byte[] $n; for ($i = 0; $i -lt $n; $i++) { $b[$i] = [Convert]::ToByte($hex.Substring(2*$i, 2), 16) }; return $b }
$firstAECH = $null; $firstDMX = $null; $first42 = $null; $firstRDMreq = $null; $firstRDMresp = $null; $firstTele = $null
foreach ($l in $lines) {
$p = $l -split "`t"; if ($p.Count -lt 5) { continue }
$b = H2B $p[4]; $t = [double]$p[0]
$from113 = $p[1] -eq "192.168.123.113"
$from1 = $p[1] -eq "192.168.123.1"
if ($from113 -and $b.Length -eq 552 -and -not $firstAECH) { $firstAECH = $t; Write-Host ("first AECH challenge t=$t") }
if ($from113 -and $b.Length -eq 1084) {
$isRDM = ($b[0x3C] -eq 1 -and $b[0x30] -eq 0)
$isDMX = ($b[0x30] -eq 0 -and $b[0x2A] -eq 0) # 0x2A=00 => DMX data frame? from earlier: type4 flag=00 0x2A=00
if ($isRDM -and -not $firstRDMreq) { $firstRDMreq = $t; Write-Host ("first RDM req(flag00) t=$t") }
if (-not $isRDM -and -not $firstDMX) { $firstDMX = $t; Write-Host ("first DMX frame t=$t (0x2A=$($b[0x2A].ToString('x2')) flag=$($b[0x30].ToString('x2')))") }
}
if ($from1 -and $b.Length -eq 42 -and -not $first42) { $first42 = $t; Write-Host ("first 42B telemetry t=$t") }
if ($from1 -and $b.Length -ge 0x2E -and $b.Length -lt 200 -and ($b[0x2A] -eq 0xCC -or $b[0x2A] -eq 0xAA) -and -not $firstRDMresp) { $firstRDMresp = $t; Write-Host ("first RDM response t=$t len=$($b.Length)") }
if ($firstAECH -and $firstDMX -and $first42 -and $firstRDMreq -and $firstRDMresp) { break }
}
Write-Host ""
Write-Host ("order: AECH=$firstAECH RDMreq=$firstRDMreq DMX=$firstDMX 42B=$first42 RDMresp=$firstRDMresp")