如何在 Windows 命令提示符下通过串口发送文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36443169/
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-08 19:32:30  来源:igfitidea点击:

How to send file over serial port in Windows Command Prompt

windowscmdserial-portfile-transfer

提问by James Jason

I'm trying to send files over a COM port, but failed every time.

我试图通过 COM 端口发送文件,但每次都失败。

First, I configure a serial on each machine like this:

首先,我在每台机器上配置一个串口,如下所示:

MODE COMx:115200,N,8

where x is the COM port number.

其中 x 是 COM 端口号。

After this I'm trying to do:

在此之后,我正在尝试做:

COPY file.zip COM1: /B

and the reverse on the receiving PC.

而在接收 PC 上则相反。

In most cases I've gotten a broken archive. But last tries gave me nothing at all - first PC says that the file was sent, but the second is just waiting for data. Is there somebody who knows how to solve this?

在大多数情况下,我得到了一个损坏的存档。但是最后一次尝试什么也没给我 - 第一个 PC 说文件已发送,但第二个只是在等待数据。有没有人知道如何解决这个问题?

回答by Ben

This works for me to send a binary file to an Arduino :

这适用于我将二进制文件发送到 Arduino :

mode COM21 BAUD=115200 PARITY=n DATA=8
copy yourfile.txt \.\COM21

Notice the \\.\which is mandatory for port numbers >= 10, and can be used too for port numbers 1-9.

请注意,\\.\对于端口号 >= 10 是必需的,并且也可以用于端口号 1-9。

回答by James

You need to specify /B for binary file after the .zip file (or whatever else it is) as well as at the end of the command line. e.g. COPY ABinary.File /B COM1 /Botherwise it will stop at the first non-text ASCII character.

您需要在 .zip 文件(或其他任何文件)之后以及命令行末尾为二进制文件指定 /B 。例如,COPY ABinary.File /B COM1 /B否则它将在第一个非文本 ASCII 字符处停止。

Try using Hyperterminal at the receiving end and Transfer > Capture Text

尝试在接收端使用超级终端并传输 > 捕获文本