|
@@ -65,8 +65,8 @@ $assumeManualSramProgrammedBool = Convert-ToBooleanParameter $AssumeManualSramPr
|
|
|
# HostPort carries allowlisted 1-based real FAN/PTC control commands and SENS/DIMM/STAT/PWM/PID reports.
|
|
# HostPort carries allowlisted 1-based real FAN/PTC control commands and SENS/DIMM/STAT/PWM/PID reports.
|
|
|
# DebugPort is read-only and carries J6CMD/J6RAW/J6EVT/J6PWM/J6MOD/J6STAT/J6MAP/J6TEMP evidence.
|
|
# DebugPort is read-only and carries J6CMD/J6RAW/J6EVT/J6PWM/J6MOD/J6STAT/J6MAP/J6TEMP evidence.
|
|
|
# Strict HostPort ACK example: OK seq=00000001 cmd=PTCCH.
|
|
# Strict HostPort ACK example: OK seq=00000001 cmd=PTCCH.
|
|
|
-# Startup sync records READY/J6READY and non-formal preflight GET STATUS into startup-preflight.json.
|
|
|
|
|
-# Preflight stale/late ACK evidence can identify blocked_host_startup_ack_shift without contaminating formal commands.
|
|
|
|
|
|
|
+# Startup sync waits for post-PROGRAM_SRAM READY/J6READY before any formal HostPort command is sent.
|
|
|
|
|
+# Pre-SRAM stale ACK/noise is recorded in startup-preflight.json and must not contaminate formal commands.
|
|
|
|
|
|
|
|
if (-not $SelfTest -and [string]::IsNullOrWhiteSpace($HostPort)) {
|
|
if (-not $SelfTest -and [string]::IsNullOrWhiteSpace($HostPort)) {
|
|
|
throw "HostPort is required unless -SelfTest is used"
|
|
throw "HostPort is required unless -SelfTest is used"
|
|
@@ -513,6 +513,91 @@ function Clear-HostAckQueue([System.Collections.Generic.Queue[object]]$AckQueue)
|
|
|
return ,$discarded.ToArray()
|
|
return ,$discarded.ToArray()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function New-StartupPreflightRecord {
|
|
|
|
|
+ return [ordered]@{
|
|
|
|
|
+ schema = "j6-host-sensor-real-fan-ptc-startup-preflight-v2"
|
|
|
|
|
+ status = "blocked_waiting_for_ready_epoch"
|
|
|
|
|
+ started_at = (Get-Date).ToUniversalTime().ToString("o")
|
|
|
|
|
+ ready_seen = $false
|
|
|
|
|
+ ready_line = ""
|
|
|
|
|
+ j6ready_seen = $false
|
|
|
|
|
+ j6ready_line = ""
|
|
|
|
|
+ epoch_locked = $false
|
|
|
|
|
+ epoch_locked_at_host_offset = $null
|
|
|
|
|
+ epoch_locked_at_debug_offset = $null
|
|
|
|
|
+ sync_command = "none"
|
|
|
|
|
+ sync_ack_seen = $false
|
|
|
|
|
+ preflight_ack = ""
|
|
|
|
|
+ attempts = @()
|
|
|
|
|
+ stale_acks = @()
|
|
|
|
|
+ pre_sram_noise = @()
|
|
|
|
|
+ pre_sram_noise_count = 0
|
|
|
|
|
+ counts_as_formal_command = $false
|
|
|
|
|
+ formal_sequence_base = 0
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function Add-PreSramNoise($Preflight, [string]$NoiseType, $Item) {
|
|
|
|
|
+ if ($null -eq $Item) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ while ($Item -is [array] -and $Item.Count -eq 1) {
|
|
|
|
|
+ $Item = $Item[0]
|
|
|
|
|
+ }
|
|
|
|
|
+ $record = [ordered]@{
|
|
|
|
|
+ type = $NoiseType
|
|
|
|
|
+ timestamp = (Get-Date).ToUniversalTime().ToString("o")
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($Item -is [System.Collections.IDictionary]) {
|
|
|
|
|
+ foreach ($key in @("ack_line", "raw", "class", "seq", "cmd", "ack_offset", "response_offset", "delimiter", "kind", "offset", "parse_status")) {
|
|
|
|
|
+ if ($Item.Contains($key)) {
|
|
|
|
|
+ $record[$key] = $Item[$key]
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } elseif ($null -ne $Item.PSObject) {
|
|
|
|
|
+ foreach ($key in @("ack_line", "raw", "class", "seq", "cmd", "ack_offset", "response_offset", "delimiter", "kind", "offset", "parse_status")) {
|
|
|
|
|
+ $property = $Item.PSObject.Properties[$key]
|
|
|
|
|
+ if ($null -ne $property) {
|
|
|
|
|
+ $record[$key] = $property.Value
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $record["raw"] = [string]$Item
|
|
|
|
|
+ }
|
|
|
|
|
+ $Preflight.pre_sram_noise = @($Preflight.pre_sram_noise) + $record
|
|
|
|
|
+ $Preflight.pre_sram_noise_count = @($Preflight.pre_sram_noise).Count
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function Update-PreflightEpochReady($Preflight, $Event, [int]$HostOffset, [int]$DebugOffset) {
|
|
|
|
|
+ if ($null -eq $Event -or -not ($Event -is [System.Collections.IDictionary]) -or -not $Event.Contains("kind")) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($Event.kind -eq "ready") {
|
|
|
|
|
+ $Preflight.ready_seen = $true
|
|
|
|
|
+ $Preflight.ready_line = [string]$Event.raw
|
|
|
|
|
+ if ($null -eq $Preflight.epoch_locked_at_host_offset) {
|
|
|
|
|
+ $Preflight.epoch_locked_at_host_offset = $HostOffset
|
|
|
|
|
+ }
|
|
|
|
|
+ } elseif ($Event.kind -eq "j6ready") {
|
|
|
|
|
+ $Preflight.j6ready_seen = $true
|
|
|
|
|
+ $Preflight.j6ready_line = [string]$Event.raw
|
|
|
|
|
+ if ($null -eq $Preflight.epoch_locked_at_debug_offset) {
|
|
|
|
|
+ $Preflight.epoch_locked_at_debug_offset = $DebugOffset
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function Complete-StartupPreflightRecord($Preflight) {
|
|
|
|
|
+ $Preflight.completed_at = (Get-Date).ToUniversalTime().ToString("o")
|
|
|
|
|
+ $Preflight.epoch_locked = ([bool]$Preflight.ready_seen -and [bool]$Preflight.j6ready_seen)
|
|
|
|
|
+ if ($Preflight.epoch_locked) {
|
|
|
|
|
+ $Preflight.status = "pass"
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $Preflight.status = "blocked_waiting_for_ready_epoch"
|
|
|
|
|
+ }
|
|
|
|
|
+ $Preflight.pre_sram_noise_count = @($Preflight.pre_sram_noise).Count
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function Read-HostAckLine($Serial, [System.Collections.Generic.List[byte]]$HostRaw, [System.Text.StringBuilder]$HostAsciiWindow, [System.Collections.Generic.List[object]]$HostReports, [System.Collections.Generic.Queue[object]]$AckQueue, [int]$StartIndex, [int]$TimeoutMs, [int]$ExpectedSeq, [string]$ExpectedCmd, [object[]]$ExtraPrefixes = @()) {
|
|
function Read-HostAckLine($Serial, [System.Collections.Generic.List[byte]]$HostRaw, [System.Text.StringBuilder]$HostAsciiWindow, [System.Collections.Generic.List[object]]$HostReports, [System.Collections.Generic.Queue[object]]$AckQueue, [int]$StartIndex, [int]$TimeoutMs, [int]$ExpectedSeq, [string]$ExpectedCmd, [object[]]$ExtraPrefixes = @()) {
|
|
|
$deadline = (Get-Date).ToUniversalTime().AddMilliseconds($TimeoutMs)
|
|
$deadline = (Get-Date).ToUniversalTime().AddMilliseconds($TimeoutMs)
|
|
|
$late = $false
|
|
$late = $false
|
|
@@ -547,105 +632,89 @@ function Read-HostAckLine($Serial, [System.Collections.Generic.List[byte]]$HostR
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function Invoke-StartupPreflight($HostSerial, $DebugSerial, [System.Collections.Generic.List[byte]]$HostRaw, [System.Text.StringBuilder]$HostAsciiWindow, [System.Collections.Generic.List[object]]$HostReports, [System.Collections.Generic.Queue[object]]$AckQueue, [System.Collections.Generic.List[byte]]$DebugRaw, [System.Text.StringBuilder]$DebugAsciiWindow, [System.Collections.Generic.List[object]]$DebugEvents) {
|
|
function Invoke-StartupPreflight($HostSerial, $DebugSerial, [System.Collections.Generic.List[byte]]$HostRaw, [System.Text.StringBuilder]$HostAsciiWindow, [System.Collections.Generic.List[object]]$HostReports, [System.Collections.Generic.Queue[object]]$AckQueue, [System.Collections.Generic.List[byte]]$DebugRaw, [System.Text.StringBuilder]$DebugAsciiWindow, [System.Collections.Generic.List[object]]$DebugEvents) {
|
|
|
- $preflight = [ordered]@{
|
|
|
|
|
- schema = "j6-host-sensor-real-fan-ptc-startup-preflight-v1"
|
|
|
|
|
- status = "blocked_host_startup_sync"
|
|
|
|
|
- started_at = (Get-Date).ToUniversalTime().ToString("o")
|
|
|
|
|
- ready_seen = $false
|
|
|
|
|
- ready_line = ""
|
|
|
|
|
- j6ready_seen = $false
|
|
|
|
|
- j6ready_line = ""
|
|
|
|
|
- sync_command = "GET STATUS"
|
|
|
|
|
- sync_ack_seen = $false
|
|
|
|
|
- preflight_ack = ""
|
|
|
|
|
- attempts = @()
|
|
|
|
|
- stale_acks = @()
|
|
|
|
|
- counts_as_formal_command = $false
|
|
|
|
|
- formal_sequence_base = 0
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $preflight = New-StartupPreflightRecord
|
|
|
|
|
+ $hostEventIndex = $HostReports.Count
|
|
|
|
|
+ $debugEventIndex = $DebugEvents.Count
|
|
|
|
|
+ $deadline = (Get-Date).ToUniversalTime().AddSeconds(45)
|
|
|
|
|
+ Write-Host "Waiting for post-PROGRAM_SRAM READY/J6READY on COM8/COM7. Start PROGRAM_SRAM now if it is not already running."
|
|
|
|
|
|
|
|
- $settleDeadline = (Get-Date).ToUniversalTime().AddMilliseconds(900)
|
|
|
|
|
- while ((Get-Date).ToUniversalTime() -lt $settleDeadline) {
|
|
|
|
|
|
|
+ while ((Get-Date).ToUniversalTime() -lt $deadline -and (-not ([bool]$preflight.ready_seen -and [bool]$preflight.j6ready_seen))) {
|
|
|
Read-HostPortAvailableLines $HostSerial $HostRaw $HostAsciiWindow $HostReports $AckQueue @("READY", "SENS", "DIMM", "STAT", "PWM", "PID")
|
|
Read-HostPortAvailableLines $HostSerial $HostRaw $HostAsciiWindow $HostReports $AckQueue @("READY", "SENS", "DIMM", "STAT", "PWM", "PID")
|
|
|
Read-PortAvailableBytes $DebugSerial $DebugRaw $DebugAsciiWindow $DebugEvents @("J6READY", "J6CMD", "J6RAW", "J6EVT", "J6PWM", "J6MOD", "J6STAT", "J6MAP", "J6TEMP")
|
|
Read-PortAvailableBytes $DebugSerial $DebugRaw $DebugAsciiWindow $DebugEvents @("J6READY", "J6CMD", "J6RAW", "J6EVT", "J6PWM", "J6MOD", "J6STAT", "J6MAP", "J6TEMP")
|
|
|
- Start-Sleep -Milliseconds 20
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- foreach ($event in $HostReports) {
|
|
|
|
|
- if ($event.kind -eq "ready") {
|
|
|
|
|
- $preflight.ready_seen = $true
|
|
|
|
|
- $preflight.ready_line = [string]$event.raw
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- foreach ($event in $DebugEvents) {
|
|
|
|
|
- if ($event.kind -eq "j6ready") {
|
|
|
|
|
- $preflight.j6ready_seen = $true
|
|
|
|
|
- $preflight.j6ready_line = [string]$event.raw
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- $preflight.stale_acks = @(Clear-HostAckQueue $AckQueue)
|
|
|
|
|
-
|
|
|
|
|
- for ($attempt = 1; $attempt -le 3 -and -not $preflight.sync_ack_seen; $attempt++) {
|
|
|
|
|
- $line = "GET STATUS`r"
|
|
|
|
|
- $bytes = [System.Text.Encoding]::ASCII.GetBytes($line)
|
|
|
|
|
- $responseStart = $HostRaw.Count
|
|
|
|
|
- $HostSerial.Write($bytes, 0, $bytes.Length)
|
|
|
|
|
- $ack = Read-HostAckLine $HostSerial $HostRaw $HostAsciiWindow $HostReports $AckQueue $responseStart 1800 1 "STATUS" @("READY")
|
|
|
|
|
- $attemptRecord = [ordered]@{
|
|
|
|
|
- attempt = $attempt
|
|
|
|
|
- command = "GET STATUS"
|
|
|
|
|
- counts_as_formal_command = $false
|
|
|
|
|
- ack_line = [string]$ack.ack_line
|
|
|
|
|
- response_class = [string]$ack.class
|
|
|
|
|
- response_seq = $ack.seq
|
|
|
|
|
- response_cmd = [string]$ack.cmd
|
|
|
|
|
- seq_match = [bool]$ack.seq_match
|
|
|
|
|
- cmd_match = [bool]$ack.cmd_match
|
|
|
|
|
- stale = [bool]$ack.stale
|
|
|
|
|
- discarded_acks = @($ack.discarded_acks)
|
|
|
|
|
- }
|
|
|
|
|
- $preflight.attempts += $attemptRecord
|
|
|
|
|
- if ([string]$ack.class -eq "ok" -and [string]$ack.cmd -eq "STATUS") {
|
|
|
|
|
- $preflight.sync_ack_seen = $true
|
|
|
|
|
- $preflight.preflight_ack = [string]$ack.ack_line
|
|
|
|
|
|
|
+ while ($AckQueue.Count -gt 0) {
|
|
|
|
|
+ $ack = $AckQueue.Dequeue()
|
|
|
|
|
+ $ack["pre_sram_noise"] = $true
|
|
|
|
|
+ Add-PreSramNoise $preflight "ack" $ack
|
|
|
|
|
+ $preflight.stale_acks = @($preflight.stale_acks) + $ack
|
|
|
}
|
|
}
|
|
|
- foreach ($event in $HostReports) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ while ($hostEventIndex -lt $HostReports.Count) {
|
|
|
|
|
+ $event = $HostReports[$hostEventIndex]
|
|
|
|
|
+ $hostEventIndex += 1
|
|
|
if ($event.kind -eq "ready") {
|
|
if ($event.kind -eq "ready") {
|
|
|
- $preflight.ready_seen = $true
|
|
|
|
|
- $preflight.ready_line = [string]$event.raw
|
|
|
|
|
|
|
+ Update-PreflightEpochReady $preflight $event $HostRaw.Count $DebugRaw.Count
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Add-PreSramNoise $preflight ([string]$event.kind) $event
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- foreach ($event in $DebugEvents) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ while ($debugEventIndex -lt $DebugEvents.Count) {
|
|
|
|
|
+ $event = $DebugEvents[$debugEventIndex]
|
|
|
|
|
+ $debugEventIndex += 1
|
|
|
if ($event.kind -eq "j6ready") {
|
|
if ($event.kind -eq "j6ready") {
|
|
|
- $preflight.j6ready_seen = $true
|
|
|
|
|
- $preflight.j6ready_line = [string]$event.raw
|
|
|
|
|
|
|
+ Update-PreflightEpochReady $preflight $event $HostRaw.Count $DebugRaw.Count
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ Start-Sleep -Milliseconds 20
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$moreStale = @(Clear-HostAckQueue $AckQueue)
|
|
$moreStale = @(Clear-HostAckQueue $AckQueue)
|
|
|
|
|
+ foreach ($ack in $moreStale) {
|
|
|
|
|
+ $ack["pre_sram_noise"] = $true
|
|
|
|
|
+ Add-PreSramNoise $preflight "ack" $ack
|
|
|
|
|
+ }
|
|
|
if ($moreStale.Count -gt 0) {
|
|
if ($moreStale.Count -gt 0) {
|
|
|
$preflight.stale_acks = @($preflight.stale_acks) + $moreStale
|
|
$preflight.stale_acks = @($preflight.stale_acks) + $moreStale
|
|
|
}
|
|
}
|
|
|
- $preflight.completed_at = (Get-Date).ToUniversalTime().ToString("o")
|
|
|
|
|
- if ($preflight.ready_seen -and $preflight.sync_ack_seen -and $preflight.j6ready_seen) {
|
|
|
|
|
- $preflight.status = "pass"
|
|
|
|
|
|
|
+ Complete-StartupPreflightRecord $preflight
|
|
|
|
|
+ if ($preflight.epoch_locked) {
|
|
|
|
|
+ Clear-HostAckQueue $AckQueue | Out-Null
|
|
|
}
|
|
}
|
|
|
return $preflight
|
|
return $preflight
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function Invoke-CollectorSelfTest {
|
|
function Invoke-CollectorSelfTest {
|
|
|
$ready = Convert-FrameLine "READY profile=temp-uart-ptc-remap seq=00000000" @("READY")
|
|
$ready = Convert-FrameLine "READY profile=temp-uart-ptc-remap seq=00000000" @("READY")
|
|
|
- $preflightAck = Mark-AckForExpectation ([ordered]@{ ack_line = "OK seq=00000001 cmd=STATUS"; raw = "OK seq=00000001 cmd=STATUS"; token = "OK seq=00000001 cmd=STATUS"; class = "ok"; seq = 1; cmd = "STATUS"; ack_offset = 1; response_offset = 1; delimiter = "CR"; timestamp = (Get-Date).ToUniversalTime().ToString("o") }) 1 "STATUS" $false $false
|
|
|
|
|
|
|
+ $j6ready = Convert-FrameLine "J6READY profile=temp-uart-ptc-remap" @("J6READY")
|
|
|
|
|
+ $preflight = New-StartupPreflightRecord
|
|
|
|
|
+ $oldAck = [ordered]@{ ack_line = "OK seq=0000000D cmd=STATUS"; raw = "OK seq=0000000D cmd=STATUS"; token = "OK seq=0000000D cmd=STATUS"; class = "ok"; seq = 13; cmd = "STATUS"; ack_offset = 1; response_offset = 1; delimiter = "CR"; timestamp = (Get-Date).ToUniversalTime().ToString("o") }
|
|
|
|
|
+ Add-PreSramNoise $preflight "ack" $oldAck
|
|
|
|
|
+ Update-PreflightEpochReady $preflight $ready 10 20
|
|
|
|
|
+ Update-PreflightEpochReady $preflight $j6ready 30 40
|
|
|
|
|
+ Complete-StartupPreflightRecord $preflight
|
|
|
$delayed = Mark-AckForExpectation ([ordered]@{ ack_line = "OK seq=00000001 cmd=PTCCH"; raw = "OK seq=00000001 cmd=PTCCH"; token = "OK seq=00000001 cmd=PTCCH"; class = "ok"; seq = 1; cmd = "PTCCH"; ack_offset = 2; response_offset = 2; delimiter = "CR"; timestamp = (Get-Date).ToUniversalTime().ToString("o") }) 2 "PTCCH" $false $false
|
|
$delayed = Mark-AckForExpectation ([ordered]@{ ack_line = "OK seq=00000001 cmd=PTCCH"; raw = "OK seq=00000001 cmd=PTCCH"; token = "OK seq=00000001 cmd=PTCCH"; class = "ok"; seq = 1; cmd = "PTCCH"; ack_offset = 2; response_offset = 2; delimiter = "CR"; timestamp = (Get-Date).ToUniversalTime().ToString("o") }) 2 "PTCCH" $false $false
|
|
|
$formal = Mark-AckForExpectation ([ordered]@{ ack_line = "OK seq=00000001 cmd=PTCCH"; raw = "OK seq=00000001 cmd=PTCCH"; token = "OK seq=00000001 cmd=PTCCH"; class = "ok"; seq = 1; cmd = "PTCCH"; ack_offset = 3; response_offset = 3; delimiter = "CR"; timestamp = (Get-Date).ToUniversalTime().ToString("o") }) 1 "PTCCH" $false $false
|
|
$formal = Mark-AckForExpectation ([ordered]@{ ack_line = "OK seq=00000001 cmd=PTCCH"; raw = "OK seq=00000001 cmd=PTCCH"; token = "OK seq=00000001 cmd=PTCCH"; class = "ok"; seq = 1; cmd = "PTCCH"; ack_offset = 3; response_offset = 3; delimiter = "CR"; timestamp = (Get-Date).ToUniversalTime().ToString("o") }) 1 "PTCCH" $false $false
|
|
|
if ($null -eq $ready -or $ready.kind -ne "ready") { throw "ready_line_parsing failed" }
|
|
if ($null -eq $ready -or $ready.kind -ne "ready") { throw "ready_line_parsing failed" }
|
|
|
- if (-not ([bool]$preflightAck.seq_match) -or -not ([bool]$preflightAck.cmd_match)) { throw "preflight_ack failed" }
|
|
|
|
|
|
|
+ if ($null -eq $j6ready -or $j6ready.kind -ne "j6ready") { throw "j6ready_line_parsing failed" }
|
|
|
|
|
+ if (-not [bool]$preflight.epoch_locked -or [string]$preflight.status -ne "pass") { throw "epoch_lock failed" }
|
|
|
|
|
+ if ([bool]$preflight.sync_ack_seen) { throw "sync_ack_should_not_be_used" }
|
|
|
|
|
+ if ([int]$preflight.pre_sram_noise_count -ne 1) { throw "pre_sram_noise failed" }
|
|
|
if ([bool]$delayed.seq_match -or [string]$delayed.cmd -ne "PTCCH") { throw "delayed_ack_isolation failed" }
|
|
if ([bool]$delayed.seq_match -or [string]$delayed.cmd -ne "PTCCH") { throw "delayed_ack_isolation failed" }
|
|
|
if (-not ([bool]$formal.seq_match) -or -not ([bool]$formal.cmd_match)) { throw "formal_ack failed" }
|
|
if (-not ([bool]$formal.seq_match) -or -not ([bool]$formal.cmd_match)) { throw "formal_ack failed" }
|
|
|
|
|
+ $rawEvents = New-Object System.Collections.Generic.List[object]
|
|
|
|
|
+ $rawEvents.Add((Convert-FrameLine "J6RAW s=00FE o=00100000 l=02 u=00FF d=AA55" @("J6READY", "J6RAW"))) | Out-Null
|
|
|
|
|
+ $rawEvents.Add((Convert-FrameLine "J6READY profile=temp-uart-ptc-remap" @("J6READY", "J6RAW"))) | Out-Null
|
|
|
|
|
+ $rawEvents.Add((Convert-FrameLine "J6RAW s=0001 o=00000000 l=04 u=000A d=01020304" @("J6READY", "J6RAW"))) | Out-Null
|
|
|
|
|
+ $rawReplay = New-BmcRawReplay $rawEvents
|
|
|
|
|
+ if ($rawReplay.Length -ne 4 -or $rawReplay[0] -ne 1 -or $rawReplay[3] -ne 4) { throw "post_j6ready_raw_replay failed" }
|
|
|
Write-Host "selftest=pass"
|
|
Write-Host "selftest=pass"
|
|
|
Write-Host "ready_line=READY profile=temp-uart-ptc-remap seq=00000000"
|
|
Write-Host "ready_line=READY profile=temp-uart-ptc-remap seq=00000000"
|
|
|
- Write-Host "preflight_ack=OK seq=00000001 cmd=STATUS"
|
|
|
|
|
|
|
+ Write-Host "j6ready_line=J6READY profile=temp-uart-ptc-remap"
|
|
|
|
|
+ Write-Host "epoch_locked=pass"
|
|
|
|
|
+ Write-Host "pre_sram_noise=OK seq=0000000D cmd=STATUS"
|
|
|
|
|
+ Write-Host "post_j6ready_raw_replay=pass"
|
|
|
Write-Host "formal_ack=OK seq=00000001 cmd=PTCCH"
|
|
Write-Host "formal_ack=OK seq=00000001 cmd=PTCCH"
|
|
|
Write-Host "stale_ack_isolated=pass"
|
|
Write-Host "stale_ack_isolated=pass"
|
|
|
}
|
|
}
|
|
@@ -672,11 +741,6 @@ function Wait-HostSensorSample($Serial, [System.Collections.Generic.List[byte]]$
|
|
|
return $false
|
|
return $false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-if ($SelfTest) {
|
|
|
|
|
- Invoke-CollectorSelfTest
|
|
|
|
|
- exit 0
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
function Convert-HexToBytes([string]$Hex) {
|
|
function Convert-HexToBytes([string]$Hex) {
|
|
|
if ([string]::IsNullOrWhiteSpace($Hex) -or ($Hex.Length % 2) -ne 0) {
|
|
if ([string]::IsNullOrWhiteSpace($Hex) -or ($Hex.Length % 2) -ne 0) {
|
|
|
return ,(New-Object byte[] 0)
|
|
return ,(New-Object byte[] 0)
|
|
@@ -690,7 +754,14 @@ function Convert-HexToBytes([string]$Hex) {
|
|
|
|
|
|
|
|
function New-BmcRawReplay([System.Collections.Generic.List[object]]$Events) {
|
|
function New-BmcRawReplay([System.Collections.Generic.List[object]]$Events) {
|
|
|
$outBytes = New-Object System.Collections.Generic.List[byte]
|
|
$outBytes = New-Object System.Collections.Generic.List[byte]
|
|
|
- foreach ($event in $Events) {
|
|
|
|
|
|
|
+ $startIndex = 0
|
|
|
|
|
+ for ($i = 0; $i -lt $Events.Count; $i++) {
|
|
|
|
|
+ if ($Events[$i].kind -eq "j6ready") {
|
|
|
|
|
+ $startIndex = $i + 1
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for ($eventIndex = $startIndex; $eventIndex -lt $Events.Count; $eventIndex++) {
|
|
|
|
|
+ $event = $Events[$eventIndex]
|
|
|
if ($event.kind -ne "j6raw") {
|
|
if ($event.kind -ne "j6raw") {
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
@@ -721,6 +792,11 @@ function New-BmcRawReplay([System.Collections.Generic.List[object]]$Events) {
|
|
|
return ,$outBytes.ToArray()
|
|
return ,$outBytes.ToArray()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+if ($SelfTest) {
|
|
|
|
|
+ Invoke-CollectorSelfTest
|
|
|
|
|
+ exit 0
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function Get-LastFieldOrDefault([System.Collections.Generic.List[object]]$Events, [string]$Kind, [string]$Field, [int64]$Default) {
|
|
function Get-LastFieldOrDefault([System.Collections.Generic.List[object]]$Events, [string]$Kind, [string]$Field, [int64]$Default) {
|
|
|
for ($i = $Events.Count - 1; $i -ge 0; $i--) {
|
|
for ($i = $Events.Count - 1; $i -ge 0; $i--) {
|
|
|
$event = $Events[$i]
|
|
$event = $Events[$i]
|
|
@@ -836,46 +912,50 @@ try {
|
|
|
|
|
|
|
|
$startupPreflight = Invoke-StartupPreflight $hostSerial $debugSerial $hostRaw $hostAsciiWindow $hostReportEvents $hostAckQueue $debugRaw $debugAsciiWindow $debugEvents
|
|
$startupPreflight = Invoke-StartupPreflight $hostSerial $debugSerial $hostRaw $hostAsciiWindow $hostReportEvents $hostAckQueue $debugRaw $debugAsciiWindow $debugEvents
|
|
|
|
|
|
|
|
- $seq = 0
|
|
|
|
|
- foreach ($command in $Commands) {
|
|
|
|
|
- $seq += 1
|
|
|
|
|
- $line = $command + "`r"
|
|
|
|
|
- $bytes = [System.Text.Encoding]::ASCII.GetBytes($line)
|
|
|
|
|
- $writtenAt = (Get-Date).ToUniversalTime()
|
|
|
|
|
- $responseStart = $hostRaw.Count
|
|
|
|
|
- $hostSerial.Write($bytes, 0, $bytes.Length)
|
|
|
|
|
- $expectedAckCmd = Get-ExpectedAckCmd $command
|
|
|
|
|
- $sensBefore = Get-SensEventCount $hostReportEvents
|
|
|
|
|
- $ack = Read-HostAckLine $hostSerial $hostRaw $hostAsciiWindow $hostReportEvents $hostAckQueue $responseStart 3000 $seq $expectedAckCmd
|
|
|
|
|
- $sensor_sample_seen = $null
|
|
|
|
|
- if ($command -eq "GET SENSOR" -and [string]$ack.class -eq "ok" -and [bool]$ack.seq_match -and [bool]$ack.cmd_match) {
|
|
|
|
|
- $sensor_sample_seen = Wait-HostSensorSample $hostSerial $hostRaw $hostAsciiWindow $hostReportEvents $hostAckQueue $sensBefore 4000
|
|
|
|
|
|
|
+ if ([bool]$startupPreflight.epoch_locked) {
|
|
|
|
|
+ $seq = 0
|
|
|
|
|
+ foreach ($command in $Commands) {
|
|
|
|
|
+ $seq += 1
|
|
|
|
|
+ $line = $command + "`r"
|
|
|
|
|
+ $bytes = [System.Text.Encoding]::ASCII.GetBytes($line)
|
|
|
|
|
+ $writtenAt = (Get-Date).ToUniversalTime()
|
|
|
|
|
+ $responseStart = $hostRaw.Count
|
|
|
|
|
+ $hostSerial.Write($bytes, 0, $bytes.Length)
|
|
|
|
|
+ $expectedAckCmd = Get-ExpectedAckCmd $command
|
|
|
|
|
+ $sensBefore = Get-SensEventCount $hostReportEvents
|
|
|
|
|
+ $ack = Read-HostAckLine $hostSerial $hostRaw $hostAsciiWindow $hostReportEvents $hostAckQueue $responseStart 3000 $seq $expectedAckCmd
|
|
|
|
|
+ $sensor_sample_seen = $null
|
|
|
|
|
+ if ($command -eq "GET SENSOR" -and [string]$ack.class -eq "ok" -and [bool]$ack.seq_match -and [bool]$ack.cmd_match) {
|
|
|
|
|
+ $sensor_sample_seen = Wait-HostSensorSample $hostSerial $hostRaw $hostAsciiWindow $hostReportEvents $hostAckQueue $sensBefore 4000
|
|
|
|
|
+ }
|
|
|
|
|
+ Read-PortAvailableBytes $debugSerial $debugRaw $debugAsciiWindow $debugEvents @("J6READY", "J6CMD", "J6RAW", "J6EVT", "J6PWM", "J6MOD", "J6STAT", "J6MAP", "J6TEMP")
|
|
|
|
|
+ $hostCommandEvents.Add([ordered]@{
|
|
|
|
|
+ seq = $seq
|
|
|
|
|
+ timestamp = $writtenAt.ToString("o")
|
|
|
|
|
+ port = $HostPort
|
|
|
|
|
+ port_role = "HostPort"
|
|
|
|
|
+ command = $command
|
|
|
|
|
+ expected_ack_cmd = $expectedAckCmd
|
|
|
|
|
+ allowed = $true
|
|
|
|
|
+ bytes_written = $bytes.Length
|
|
|
|
|
+ ack_line = [string]$ack.ack_line
|
|
|
|
|
+ ack_offset = $ack.ack_offset
|
|
|
|
|
+ response_offset = $ack.response_offset
|
|
|
|
|
+ response_raw = [string]$ack.raw
|
|
|
|
|
+ response_token = [string]$ack.token
|
|
|
|
|
+ response_class = [string]$ack.class
|
|
|
|
|
+ response_late = [bool]$ack.response_late
|
|
|
|
|
+ stale = [bool]$ack.stale
|
|
|
|
|
+ response_seq = $ack.seq
|
|
|
|
|
+ response_cmd = [string]$ack.cmd
|
|
|
|
|
+ seq_match = [bool]$ack.seq_match
|
|
|
|
|
+ cmd_match = [bool]$ack.cmd_match
|
|
|
|
|
+ sensor_sample_seen = $sensor_sample_seen
|
|
|
|
|
+ accepted = ([string]$ack.class -eq "ok" -and [bool]$ack.seq_match -and [bool]$ack.cmd_match)
|
|
|
|
|
+ }) | Out-Null
|
|
|
}
|
|
}
|
|
|
- Read-PortAvailableBytes $debugSerial $debugRaw $debugAsciiWindow $debugEvents @("J6READY", "J6CMD", "J6RAW", "J6EVT", "J6PWM", "J6MOD", "J6STAT", "J6MAP", "J6TEMP")
|
|
|
|
|
- $hostCommandEvents.Add([ordered]@{
|
|
|
|
|
- seq = $seq
|
|
|
|
|
- timestamp = $writtenAt.ToString("o")
|
|
|
|
|
- port = $HostPort
|
|
|
|
|
- port_role = "HostPort"
|
|
|
|
|
- command = $command
|
|
|
|
|
- expected_ack_cmd = $expectedAckCmd
|
|
|
|
|
- allowed = $true
|
|
|
|
|
- bytes_written = $bytes.Length
|
|
|
|
|
- ack_line = [string]$ack.ack_line
|
|
|
|
|
- ack_offset = $ack.ack_offset
|
|
|
|
|
- response_offset = $ack.response_offset
|
|
|
|
|
- response_raw = [string]$ack.raw
|
|
|
|
|
- response_token = [string]$ack.token
|
|
|
|
|
- response_class = [string]$ack.class
|
|
|
|
|
- response_late = [bool]$ack.response_late
|
|
|
|
|
- stale = [bool]$ack.stale
|
|
|
|
|
- response_seq = $ack.seq
|
|
|
|
|
- response_cmd = [string]$ack.cmd
|
|
|
|
|
- seq_match = [bool]$ack.seq_match
|
|
|
|
|
- cmd_match = [bool]$ack.cmd_match
|
|
|
|
|
- sensor_sample_seen = $sensor_sample_seen
|
|
|
|
|
- accepted = ([string]$ack.class -eq "ok" -and [bool]$ack.seq_match -and [bool]$ack.cmd_match)
|
|
|
|
|
- }) | Out-Null
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Write-Host "Blocked: post-PROGRAM_SRAM READY/J6READY was not observed; formal HostPort commands were not sent."
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
while ((Get-Date).ToUniversalTime() -lt $deadline) {
|
|
while ((Get-Date).ToUniversalTime() -lt $deadline) {
|
|
@@ -939,7 +1019,9 @@ $pidRequested = [int64](Get-LastFieldOrDefault $debugEvents "j6mod" "pid_request
|
|
|
$pidRequestedEver = (Get-PidRequestedEver $debugEvents) -or (Get-PidRequestedEver $hostReportEvents) -or ($Commands -contains "SET PID ENABLE")
|
|
$pidRequestedEver = (Get-PidRequestedEver $debugEvents) -or (Get-PidRequestedEver $hostReportEvents) -or ($Commands -contains "SET PID ENABLE")
|
|
|
$bmcTimeout = ($sampleCount -lt 3 -and $rawReplayArray.Length -eq 0)
|
|
$bmcTimeout = ($sampleCount -lt 3 -and $rawReplayArray.Length -eq 0)
|
|
|
|
|
|
|
|
-$captureStatus = if (-not $allAckOk) {
|
|
|
|
|
|
|
+$captureStatus = if (-not [bool]$startupPreflight.epoch_locked) {
|
|
|
|
|
+ "blocked_waiting_for_ready_epoch"
|
|
|
|
|
+} elseif (-not $allAckOk) {
|
|
|
"blocked_host_ack"
|
|
"blocked_host_ack"
|
|
|
} elseif ($bmcBerr -ne 0 -or $hostErr -ne 0) {
|
|
} elseif ($bmcBerr -ne 0 -or $hostErr -ne 0) {
|
|
|
"blocked_uart_error"
|
|
"blocked_uart_error"
|
|
@@ -988,7 +1070,7 @@ Write-JsonFile $debugFrameStream $debugFrameStreamPath
|
|
|
|
|
|
|
|
$hostTranscript = [ordered]@{
|
|
$hostTranscript = [ordered]@{
|
|
|
schema = "j6-host-sensor-real-fan-ptc-host-command-transcript-v1"
|
|
schema = "j6-host-sensor-real-fan-ptc-host-command-transcript-v1"
|
|
|
- status = if ($allAckOk) { "pass" } else { "blocked_host_ack" }
|
|
|
|
|
|
|
+ status = if (-not [bool]$startupPreflight.epoch_locked) { "blocked_waiting_for_ready_epoch" } elseif ($allAckOk) { "pass" } else { "blocked_host_ack" }
|
|
|
host_port = $HostPort
|
|
host_port = $HostPort
|
|
|
baud = 115200
|
|
baud = 115200
|
|
|
format = "8N1"
|
|
format = "8N1"
|