为 Arduino 编写 Windows 命令行 com-port
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9247630/
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
Windows command line com-port writing for Arduino
提问by Rai220
I need to send some information from my PC to an Arduino. I tested it with PuTTYand it works great.
我需要将一些信息从我的 PC 发送到 Arduino。我用PuTTY对其进行了测试,效果很好。
I need to send characters, '1' or '2', to control a servo and I am using these commands:
我需要发送字符“1”或“2”来控制伺服,我正在使用这些命令:
mode com10:9600,n,8,1
模式 com10:9600,n,8,1
... and I see that my Arduino received some data.
...我看到我的 Arduino 收到了一些数据。
After that, I try to use that:
之后,我尝试使用它:
echo 1>com10
回声 1>com10
OR
或者
echo "1">com10
echo "1">com10
and nothing nothing happens.
什么也没有发生。
With PuTTY it works corrent and turning, when I press 1 or 2. With the Arduino serial monitor it works great too.
使用 PuTTY,当我按 1 或 2 时,它可以正常工作并转动。使用 Arduino 串行监视器,它也可以很好地工作。
采纳答案by Rai220
At the end, I used PowerShellto do this task:
最后,我使用PowerShell来完成这个任务:
powershell "$port= new-Object System.IO.Ports.SerialPort COM10,9600,None,8,one; $port.open(); $port.WriteLine("1"); $port.Close()"
回答by Khulja Sim Sim
回答by jfrmilner
回答by unununun
mode com3 BAUD=9600 PARITY=n DATA=8 STOP=1 && echo blahblah > com3
模式 com3 BAUD=9600 PARITY=n DATA=8 STOP=1 && echo blahblah > com3
about the same:
差不多:
powershell "$port= new-Object System.IO.Ports.SerialPort COM10,9600,None,8,one; $port.open(); $port.WriteLine("1"); $port.Close()"
回答by dc42
This will send the contents of a file to COM10 under Windows 7, not sure about other versions:
这将在Windows 7下将文件内容发送到COM10,其他版本不确定:
copy myfile \\.\COM10
复制我的文件 \\.\COM10
If you just use "copy myfile COM10" then it creates a file called COM10 instead.
如果您只是使用“copy myfile COM10”,那么它会创建一个名为 COM10 的文件。
So you might like to try:
所以你可能想尝试:
echo 1>\\.\com10
回声 1>\\.\com10
回答by Joey
Three points:
三点:
- COM10 isn't a reserved file name like COM1–4, so it couldbe that you're just creating a file.
echo 1>foo
is the same asecho >foo
which will printECHO is on.
(you're redirecting stream 1, aka stdout).echo "1">foo
will print"1"
includingthe quotes.
- COM10 不是像 COM1-4 那样的保留文件名,因此您可能只是在创建文件。
echo 1>foo
与echo >foo
将打印的相同ECHO is on.
(您正在重定向流 1,又名标准输出)。echo "1">foo
将打印"1"
包括引号。
To actually echo a 1
somewhere you'd have to use
要实际回声1
某个地方,您必须使用
>foo echo 1
or
或者
(echo 1)>foo