خرید بک لینک

I'm coecting via serial port with powershell to a device and I'm trying to change one value until another value gets to 0. I'm using Do-Until but it just runs endlessly with the first value being changed over and over. What I need to do is, initially I check Value2 aka $line1, if it's not 0, I need to check Value1 aka V45, add 10 to it, send the command to change it and reset the device, then check again Value2 and if it's not 0 repeat. I tried Do-While($line -ne 0), Do-Until($line -le 0) with the same outcome. When I tried Do-Until($line -ne 0) it stopped after the first run, with Value1 (higher) and Value2(lower) changed. I ran the script 3-4 times and eventually Value2 got to 0. I guess I have something wrong in the Do-Until(While) statement and I'm not seeing it.

$port.WriteLine("R?`r")
$string1 = $port.ReadLine()
$line1 = [int]($string1 -split ",")[11]
if($line1 -ne 0){
    do{
        $port.WriteLine("V45?`r")
        $v45 = [int]$port.ReadLine()+10
        $port.WriteLine("V45,${v45}`r")
        $port.ReadLine()
        $port.WriteLine("RST`r")
        $port.ReadLine()
        $port.ReadLine()
        $port.WriteLine("R?`r")
        $string = $port.ReadLine()
        $line = [int]($string1 -split ",")[11]
    }until($line -eq 0)
}

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 3 فروردين 1395 ساعت: 17:57

صفحه بندی