CodePudding user response:
http://blogs.msdn.com/b/powershell/archive/2006/08/31/writing-and-reading-info-from-serial-ports.aspxSuggestion of this article, Powersehll use serial communication
PSMDTAG: FAQ: How do I read/write data from a Serial Port?
Writing to a Serial Port
PS> [System. IO Ports. SerialPort] : : getportnames ()
COM3
PS> . $port=new - Object System. IO Ports. SerialPort COM3, 9600, None, 8, one
PS> $port. The open ()
PS> $port. WriteLine (" Hello world ")
PS> $port. The Close ()
Reading from a Serial Port
PS> . $port=new - Object System. IO Ports. SerialPort COM3, 9600, None, 8, one
PS> $port. The Open ()
PS> $port. ReadLine ()
For information about how to read from a serial port in an asynchronous manner in PowerShell V2, use the method DataReceived event on the port object with the Register - ObjectEvent pre-existing cmdlets.