Files
kinect-bot 9b5a0255e2
ci / Linux C++ core (cmake + ctest) (push) Canceled after 0s
ci / Python root tests (pytest, no tracker deps) (push) Canceled after 0s
ci / Python tracker (pytest, tracker/.venv) (push) Canceled after 0s
feat(windows): usbip-win runbook ([~]) + clean-room Kinect10.dll NUI shim (x86+x64 export-verified) (wave 9; todo 14 done, 12/13 blocked)
2026-11-25 06:00:12 -05:00

68 lines
2.2 KiB
PowerShell

#requires -Version 5.1
<#
.SYNOPSIS
Detach the virtual Kinect v1 busids from this Windows box's USB tree.
.DESCRIPTION
[~] BLOCKED in the kinect build environment (no Windows). RUN THIS ON THE USER'S WINDOWS BOX,
elevated. 'usbip.exe detach' takes the VHCI PORT number, not the busid, so this lists the
attached ports first and detaches each (or pass -Port to detach one, or -All).
Graceful removal: detaching while an app (DEA / a Kinect SDK sample) holds the sensor should
surface a clean device-removal to that app (sensor-unplugged), not a crash -- this is plan
todo 12's documented failure scenario to verify on Windows.
.PARAMETER UsbipExe
Path to usbip.exe. Defaults as in Attach-Kinect.ps1.
.PARAMETER Port
Detach a single VHCI port.
.PARAMETER All
Detach every attached port.
#>
[CmdletBinding()]
param(
[string]$UsbipExe,
[int]$Port = -1,
[switch]$All
)
$ErrorActionPreference = 'Stop'
function Resolve-Usbip([string]$explicit) {
if ($explicit) { return $explicit }
$onPath = Get-Command usbip.exe -ErrorAction SilentlyContinue
if ($onPath) { return $onPath.Source }
$default = Join-Path ${env:ProgramFiles} 'USBip\usbip.exe'
if (Test-Path $default) { return $default }
throw 'usbip.exe not found. Pass -UsbipExe.'
}
$usbip = Resolve-Usbip $UsbipExe
if ($Port -ge 0) {
Write-Host "Detaching VHCI port $Port ..." -ForegroundColor Green
& $usbip detach -p $Port
exit $LASTEXITCODE
}
if ($All) {
# usbip-win2 supports 'detach -all'; the legacy client needs per-port detach.
Write-Host 'Detaching all attached ports ...' -ForegroundColor Green
& $usbip detach -all
if ($LASTEXITCODE -ne 0) {
Write-Host "'detach -all' unsupported on this client; parsing 'usbip port' and detaching each ..." -ForegroundColor Yellow
$ports = (& $usbip port) | Select-String -Pattern 'Port\s+(\d+)' -AllMatches |
ForEach-Object { $_.Matches } | ForEach-Object { [int]$_.Groups[1].Value }
foreach ($p in $ports) {
Write-Host "Detaching port $p ..." -ForegroundColor Green
& $usbip detach -p $p
}
}
exit 0
}
Write-Host "Attached ports (pass -Port <N> to detach one, or -All):" -ForegroundColor Cyan
& $usbip port