如何将 Windows COM 端口输出重定向到文件?

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

How can I redirect Windows COM port output to a file?

windowsserial-port

提问by robsoft

Is there a simple way of redirecting serial port output to a file, that I can put into place on a test Windows desktop system without changing any code?

有没有一种简单的方法可以将串行端口输出重定向到文件,我可以在不更改任何代码的情况下将其放置在测试 Windows 桌面系统上?

I'm trying to debug a problem in a serial receipt printer module and I don't have the real device handy today. I don't want to start making any changes to the code if I can help it, I just want to capture what is currently being output at the moment so that I can review it in a file.

我正在尝试调试串行收据打印机模块中的问题,但我今天手边没有真正的设备。如果可以的话,我不想开始对代码进行任何更改,我只想捕获当前正在输出的内容,以便我可以在文件中查看它。

It's Windows XP, if that makes any difference.

它是 Windows XP,如果这有什么不同的话。

采纳答案by Dan F

A quick google led me to RS232 Data Logger- I haven't tried it, but if it does what it says on the tin it should be OK for you. Edit: it appears to be incoming, not outgoing. Might be worth a try though :-)

一个快速的谷歌让我找到了RS232 数据记录器- 我还没有尝试过,但如果它按照锡上所说的那样做,对你来说应该没问题。编辑:它似乎是传入的,而不是传出的。不过可能值得一试:-)

回答by FerranB

Another option is through command line:

另一种选择是通过命令行:

type com1: >> data.log

回答by Timmmm

Another option: Use puttyand turn on logging.

另一种选择:使用putty打开 logging

回答by Niki

You could run the printer module in a VM. VMWare allows you to redirect serial ports to files and named pipes.

您可以在 VM 中运行打印机模块。VMWare 允许您将串行端口重定向到文件和命名管道。

回答by Scott

Similar to VMWare, Virtual PC(& Virtual Server) can also redirect a COM port to a text fileand setup is very simple.

与 VMWare 类似,Virtual PC(& Virtual Server) 也可以将 COM 端口重定向到文本文件,并且设置非常简单。

回答by Ahmed Said

I think in the control pandel, printers, you can add manual printer and install dummay one So you can printing to a file for example

我认为在控制面板,打印机中,您可以添加手动打印机并安装dummay one 这样您就可以打印到文件例如

回答by pedrofernandes

If you are developer use Serial Port component from .NET or if you don't are a developer and only want get information to file use windows HyperTerminal

如果您是开发人员,请使用 .NET 中的串行端口组件,或者如果您不是开发人员并且只想获取信息以归档,请使用 windows HyperTerminal

回答by Nick Dandoulakis

I don't know if you can redirect COM ports but you can use com0comfor that kind of job.

我不知道您是否可以重定向 COM 端口,但您可以将com0com用于那种工作。

For example, you can pair(COM1, COM2), so you can write to COM1 and read from COM2.

例如,您可以配对(COM1, COM2),因此您可以写入 COM1 并从 COM2 读取。