Windows/.NET 监控/调试串口的方式?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/335279/
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/.NET way to monitor/debug the serial port?
提问by pearcewg
I have an application which is .NET 2.0, running on Windows XP Professional. This app uses the Serial Port to communicate with some custom devices.
我有一个运行在 Windows XP Professional 上的 .NET 2.0 应用程序。此应用程序使用串行端口与一些自定义设备进行通信。
For some reason, a few of our custom built PCs have an issue with the Serial Port, where it will stop functioning after a few weeks of use. Other that auto-reboots, which won't work in my scenario, are there any utilities out there which can debug/diagnose the serial port? Is there any .NET library which can help with this (can I write my own utility to debug the port)?
出于某种原因,我们的一些定制 PC 存在串行端口问题,在使用几周后它将停止运行。除了自动重启,这在我的场景中不起作用,是否有任何实用程序可以调试/诊断串行端口?是否有任何 .NET 库可以帮助解决这个问题(我可以编写自己的实用程序来调试端口吗)?
Also, has anyone had any experience with the following library: Sax CommStudio
另外,有没有人对以下库有任何经验: Sax CommStudio
采纳答案by Jon B
I've used Sax CommStudio in the past, but now I just use System.IO.Ports.SerialPort.
我过去使用过 Sax CommStudio,但现在我只使用 System.IO.Ports.SerialPort。
By any chance are you using a USB serial port? I've had problems with those going BSOD and whatnot. If that's the case, you have a driver problem, not a software problem.
您是否有机会使用 USB 串行端口?我遇到了那些会蓝屏死机之类的问题。如果是这种情况,则是驱动程序问题,而不是软件问题。
If you want to do some troubleshooting outside of your app, you might have a look at HHD's serial monitor. I think they have a free trial, but if you're doing any serious RS232 development it's really worth buying.
如果您想在应用程序之外进行一些故障排除,您可以查看HHD 的串行监视器。我认为他们有免费试用版,但如果您正在进行任何认真的 RS232 开发,那么它确实值得购买。
回答by Will Dean
portmon - http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx
portmon - http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx
I'd say that's the closest to a 'standard' tool for monitoring serial ports on Windows. But heaven help you if you need to try and track down something after two weeks using this kind of tool...
我会说这是最接近用于监视 Windows 串行端口的“标准”工具。但是,如果您需要在两周后使用这种工具尝试追踪某些事情,那么天堂会帮助您...
I would suspect a driver problem - is it a 'proper' serial port with a conventional UART, or is it some kind of USB-Serial converter or similar?
我怀疑是驱动程序问题 - 它是带有传统 UART 的“正确”串行端口,还是某种 USB 串行转换器或类似的?
Update 2017: Portmon was a reasonably useful suggestion in 2008, but has never been updated to work with 64-bit versions of Windows, so don't bother trying it now on a modern machine.
2017 年更新:Portmon 在 2008 年是一个相当有用的建议,但从未更新为适用于 64 位版本的 Windows,所以现在不要在现代机器上尝试它。
回答by Tim Long
You mention you are running on Windows XP and .NET 2.0, .NET may well be your problem since there are bugs affecting serial ports in most versions of .NET. The minimum version that I'd recommend for using serial ports is .NET 3.5 SP1.
您提到您在 Windows XP 和 .NET 2.0 上运行,.NET 很可能是您的问题,因为在大多数 .NET 版本中存在影响串行端口的错误。我建议使用串行端口的最低版本是 .NET 3.5 SP1。
See also: http://blog.zachsaw.com/2010/07/net-serialport-woes.html
另见:http: //blog.zachsaw.com/2010/07/net-serialport-woes.html
回答by Robert
I've used the HDD Software Free Serial Port Monitor. It will log all the traffic and open/close on the serial port. That way you have a log of the data and the operation of the serial port.
我使用了 HDD Software Free Serial Port Monitor。它将记录所有流量并在串行端口上打开/关闭。这样你就有了数据和串口操作的日志。