This commit is contained in:
Mysteo91
2023-08-17 16:19:53 +03:00
parent c6211b1db1
commit 275752357a
13 changed files with 104 additions and 29 deletions

View File

@@ -3,10 +3,20 @@ $dir=$PSScriptRoot
$MyCommand="$dir"+"\stlink\st-info.exe --probe --hot-plug"
Invoke-Expression -Command $MyCommand | Out-String -OutVariable output
$DevicesNum=$output.Substring($output.IndexOf("Found") + 7, 1)
Write-Host -ForegroundColor Yellow -BackgroundColor Blue 'Do you wanna run the script N/Y'
$key=Read-Host
if ($key.ToUpper() -notmatch 'Y')
{
exit
}
if ($DevicesNum -eq 1)
{
$serial=$output.Substring($output.Trim().IndexOf("serial") + 12, 24)
}
elseif ($DevicesNum -eq 0)
{
exit
}
else
{
Write-Host -ForegroundColor Yellow -BackgroundColor Blue 'Press key which number of debugger you wanna use'
@@ -24,7 +34,7 @@ $serial=$serial.ToCharArray()
$StringForCompare='adapter serial "'
for ($i = 0; $i -lt $serial.Count; $i=$i+2) {
$StringForCompare=$StringForCompare.Insert($StringForCompare.Length,"\x$($serial.Get($i))$($serial.Get($i+1))")
$StringForCompare=$StringForCompare.Insert($StringForCompare.Length,"$($serial.Get($i))$($serial.Get($i+1))")
}
$StringForCompare=$StringForCompare.Insert($StringForCompare.Length,'"')
$Path = "$dir"+"/board.cfg"