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

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

问题描述

我正在尝试通过 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:

如何停止复制过程?

当 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.

回到过去,我是在暴露年龄吗?

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

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

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