Reputation: 145
Is there any way to connect and communicate with a COM port (e.g. COM4) using windows terminal (Windows 8 <) inbuilt commands or using a batch program?
MODE COM4:9600,N,8,1,P
Above command displays the confugurations of COM4. But how I can send or receive data?
Upvotes: 10
Views: 69164
Reputation: 48923
Identify connected COM ports:
mode
powershell -c "[System.IO.Ports.SerialPort]::getportnames()"
Send message with CR/LF:
echo hello >COM4
Send a file:
type file.txt >COM4
Read COM port:
type COM4
The better interactive way is to use Putty or minicom
from within WSL 1!
Upvotes: 2
Reputation: 547
use windows powershell
Writing to a Serial Port
PS> [System.IO.Ports.SerialPort]::getportnames()
PS> $port= new-Object System.IO.Ports.SerialPort COM4,9600,None,8,one
PS> $port.open()
PS> $port.WriteLine(“Hello world”)
PS> $port.Close()
Reading from a Serial Port
PS> $port= new-Object System.IO.Ports.SerialPort COM4,9600,None,8,one
PS> $port.Open()
PS> $port.ReadLine()
Upvotes: 11