简体   繁体   English

Windows 7 串口打开命令

[英]Command for opening serial port in Windows 7

Is there a Windows command for opening serial ports, say COM3 via the command prompt in Windows 7?是否有用于打开串行端口的 Windows 命令,例如通过 Windows 7 中的命令提示符说 COM3? For example:例如:

OPEN "COM6" AS #1

I cannot use pyserial or any other utilities that are not distributed with Windows 7.我无法使用 pyserial 或任何其他未随 Windows 7 分发的实用程序。

Preferred solution Opening a COM port in QBasic on Windows 7首选解决方案在 Windows 7 上的 QBasic 中打开 COM 端口

Maybe you can use the Powershell?也许你可以使用Powershell? It's included in Win7...它包含在Win7中...

code taken from here http://blogs.msdn.com/b/powershell/archive/2006/08/31/writing-and-reading-info-from-serial-ports.aspx代码取自这里http://blogs.msdn.com/b/powershell/archive/2006/08/31/writing-and-reading-info-from-serial-ports.aspx

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.open()
PS> $port.WriteLine("Hello world")
PS> $port.Close()

Reading from a Serial Port从串行端口读取

PS> $port= new-Object System.IO.Ports.SerialPort COM3,9600,None,8,one
PS> $port.Open()
PS> $port.ReadLine()

To send contents of a file to a serial port:将文件内容发送到串行端口:

copy file.bin com1 /b

To send a few characters to a serial port:将几个字符发送到串行端口:

echo hello > com1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM