This commit is contained in:
Eric Ratliff
2026-02-18 20:15:46 -06:00
parent 833ea44748
commit 60ba7c7bed
11 changed files with 559 additions and 81 deletions

View File

@@ -0,0 +1,29 @@
# _detect_port.ps1 -- Detect the best serial port via arduino-cli
#
# Called by upload.bat and monitor.bat. Outputs a single port name
# (e.g. COM3) or nothing if no port is found.
# Prefers USB serial ports over legacy motherboard COM ports.
$ErrorActionPreference = 'SilentlyContinue'
$raw = arduino-cli board list --format json 2>$null
if (-not $raw) { exit }
$data = $raw | ConvertFrom-Json
if (-not $data.detected_ports) { exit }
$serial = $data.detected_ports | Where-Object { $_.port.protocol -eq 'serial' }
if (-not $serial) { exit }
# Prefer USB serial ports (skip legacy COM1-style ports)
$usb = $serial | Where-Object { $_.port.protocol_label -like '*USB*' } | Select-Object -First 1
if ($usb) {
Write-Output $usb.port.address
exit
}
# Fall back to any serial port
$any = $serial | Select-Object -First 1
if ($any) {
Write-Output $any.port.address
}