Skip to content

Instantly share code, notes, and snippets.

@CIPop
Created November 6, 2018 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CIPop/7bce468630953d6aa86867fff63deaa9 to your computer and use it in GitHub Desktop.
Save CIPop/7bce468630953d6aa86867fff63deaa9 to your computer and use it in GitHub Desktop.
Powershell Baud Detector
Write-Output "Available COM ports: "
[System.IO.Ports.SerialPort]::getportnames()
$Global:portName = "COM5"
Function TryBaud($rate)
{
$port= new-Object System.IO.Ports.SerialPort $Global:portName,$rate,None,8,one
$port.open()
$port.ReadTimeout = 1000
$port.WriteLine("help")
try
{
$s = $port.ReadLine()
Write-Output "String read: <<$s>>"
}
catch {}
$port.Close()
}
$baudRates = (110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200, 128000, 256000, 460800)
foreach ($r in $baudRates)
{
Write-Output "Trying: $r"
TryBaud $r
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment