Im having an issue where in i need to send commands through the serial comms port and then wait until particular response ins received.
Currently i have :
$VerbosePreference = "Continue" $port = New-Object System.IO.Ports.SerialPort "COM8", 115200
Open the port object:
$port.Open()
Read and write:
$port.WriteLine("LI") $port.WriteLine("DEBUG AUDIT ON") $port.WriteLine("AR 00")
Write-Output $value while (($timer.Elapsed.TotalSeconds -lt $Timeout) -and ($value -notcontains "*Audit =")){ Start-Sleep -Seconds 2 Write-Verbose -message "Still waiting for action to complete after [$totalSecs] seconds..."
} } $timer.Stop() if ($port.IsOpen){ if ($port.BytesToRead -gt 0){ $value = $port.ReadExisting();
} } Write-Output $value $value =" " $port.Close()
Basically i need to send down an "AR 00" command, i then need this to wait until the word "Interop" or "instance" are in the input buffer. ( or the 60 second timeout happens)
Once this has been received i then need to write-output everything that was in the buffer.
Is this possible, if so can some point me and my puny skill in the right direction on how to do this.
If is possible to execute more based on the wait result For example where timrout = result 0, "Interop" = result 1, instance= result 2 If result 0 goto ... If result 1 goto .. If result 2 goto ..
Etc
Any help would be really grateful