Windows 7 串口打开命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12785638/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:57:47  来源:igfitidea点击:

Command for opening serial port in Windows 7

windowsbatch-filecmdwindows-7serial-port

提问by Olumide

Is there a Windows command for opening serial ports, say COM3 via the command prompt in Windows 7? For example:

是否有用于打开串行端口的 Windows 命令,例如通过 Windows 7 中的命令提示符说 COM3?例如:

OPEN "COM6" AS #1

I cannot use pyserial or any other utilities that are not distributed with Windows 7.

我无法使用 pyserial 或任何其他未随 Windows 7 分发的实用程序。

Preferred solutionOpening a COM port in QBasic on Windows 7

首选解决方案在 Windows 7 上的 QBasic 中打开 COM 端口

回答by Max

Maybe you can use the Powershell? It's included in Win7...

也许你可以使用Powershell?它包含在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()

回答by david

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