Reputation: 474
I am trying to send ASCII code (for ENTER, SPACE, SHIFT, F1, F2, F3 and F4 keys) serially in Powershell
port= new-Object System.IO.Ports.SerialPort COM1,115200,None,8,one
$port.open()
# Carriage return - ENTER
$port.WriteLine("`r")
Start-Sleep -Milliseconds 500
$port.ReadExisting()
[Byte[]] $request = 13
$port.Write($request)
Start-Sleep -Milliseconds 500
$port.ReadExisting()
$port.Close()
Here in above code, I am sending Carriage Return serially. When I use WriteLine
then it works but it fails when I am trying with Write
.
Upvotes: 1
Views: 2703
Reputation: 6292
Often CR+LF work as a command terminator on serial ports, so it probably doesn't pick up what you are doing unless you WriteLine. To send a CR+LF you should try
$port.Write("`r`n")
Upvotes: 1