批处理文件:从串行端口接收数据并将其写入txt文件 [英] Batch-File: Receive Data from the Serial-Port and write it into txt-File

查看:161
本文介绍了批处理文件:从串行端口接收数据并将其写入txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过usb串行端口从Arduino提取一些数据,并将其写入txt文件.因此,我正在使用一个批处理文件(Windows 7,普通的cmd),该文件发送例如一个"d"以从Arduino请求所需的数据.收到"d"后,Arduino开始将数据发送到PC.批处理文件读取数据并将其写入一些txt文件.批处理代码为:

I'm trying to extract some data from an Arduino over the usb-serial-port and to write it into a txt-file. Therefore i'm using a batch-file (Windows 7, ordinary cmd), which sends e.g. a "d" to request the desired data from the Arduino. Having received the "d", the Arduino starts to send the data to the pc. The batch-file reads the data and writes it to some txt-file. The batch code is:

    mode COM4 BAUD=9600 PARITY=n DATA=8
    echo d >COM4
    COPY COM4 data.txt

到目前为止,该方法仍然有效,但问题是:

That works so far, but the problem is:

如何停止COPY处理?

How do I stop the COPY-process?

当Arduino完成数据发送后,批处理文件将继续等待更多信息.我的首选解决方案是,Arduino发送诸如"end"之类的字符串,批处理文件会识别出该字符串并停止读取.有可能吗?

When the Arduino is done with sending the data, the batch file keeps on wating for more. My preferred solution would be, that the Arduino sends some string like "end", the batch file recognizes this and stops reading. Is that somehow possible?

推荐答案

我相信副本会将Control-Z识别为文件字符的结尾并终止.

I believe that copy will recognize a Control-Z as an end of file character and terminate.

哈肯斯回到过去的dos时代,我在显示自己的年龄吗?

Harkens way back to the old dos days, am I showing my age?

这篇关于批处理文件:从串行端口接收数据并将其写入txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆