串行端口重定向或拆分

发布于 2024-08-03 02:26:10 字数 1539 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

黑寡妇 2024-08-10 02:26:10

您可能会发现 Mark Russinovich 的 PortMon 对您的工作很有帮助,尽管它没有提供源代码。它将记录与端口相关的所有系统调用,并具有广泛的过滤功能,以将该日志保持在可管理的大小。

编辑: PortMon 的工作原理是在运行时将内核模式设备驱动程序注入到系统中。该驱动程序通过将过滤器驱动程序插入堆栈来挂钩它想要监视的端口。该过滤器驱动程序将通过它的所有 IRP 报告给应用程序。这不是一件容易实现的事情,而且它确实无法在用户模式下完成。

Windows DDK 确实有端口过滤器驱动程序的示例代码,但从示例到有用的东西需要做很多工作。

可能可行的纯用户模式解决方案是使用两个附加串行端口来窃听线路。一对 USB 转串口适配器和一些接线就可以满足您的需要。那么监视和关联发送和接收线路只是“编程的小问题”。单芯片解决方案可以基于 FTDI 的 FT2232H 设备,该设备具有可用的 评估模块。添加几个 RS232 电平转换器和一些 D 连接器,您就可以在 USB 上获得一个串行窃听器,它看起来就像 Windows 的两个 COM 端口。

另一种开箱即用的方法是许多逻辑分析仪和混合信号示波器可以进行串行协议解码,通常作为可选组件。 Saelig 是廉价 USB+软件解决方案的来源之一。我自己从他们那里购买了芯片和模块,但对他们销售的任何基于 USB 的逻辑分析仪没有任何直接经验,尽管我认为我应该在包里和上网本一起放一个……

You might find that PortMon by Mark Russinovich is helpful in your work, although it isn't provided with source code. It will log all system calls related to a port, and has extensive filtering capabilities to keep that log to a manageable size.

Edit: PortMon works by injecting a kernel mode device driver into the system when it runs. That driver hooks the ports that it wants to monitor by inserting a filter driver into the stack. That filter driver reports all IRPs that pass through it to the application. This is not an easy beast to implement by any stretch, and it really can't be done in user mode.

The Windows DDK does have sample code for a port filter driver, but it is a lot of work to go from the sample to something useful.

A pure user mode solution that might work out is to use two additional serial ports to eavesdrop on the wire. A pair of USB to serial adapters and a bit of wiring will do what you need. Then it is only a "small matter of programming" to monitor and correlate the send and receive lines. A single chip solution could be based on the FT2232H device from FTDI, which has an available evaluation module. Add a couple of RS232 level translators and some D connectors and you've got a serial eavesdropper on USB that looks like two COM ports to Windows.

Another outside the box approach is that many logic analyzers and mixed signal oscilloscopes can do serial protocol decoding, often as an optional component. One source of inexpensive USB+software solutions is Saelig. I've bought chips and modules from them myself, but don't have any direct experience with any of the USB-based logic analyzers they sell despite thinking that I should have one in my bag along with the Netbook...

谈情不如逗狗 2024-08-10 02:26:10

我很多年前写过一篇。 DDK(设备驱动程序套件)包括并行端口驱动程序(即上面)的过滤器驱动程序的示例源代码:我调整了此示例以与串行端口驱动程序一起使用,然后添加了监视和拆分等功能。

这是串行端口,而不是 USB。

我还实现了另一个驱动程序,它是一个“虚拟”串行端口,即它实现了一个串行端口 API,但随后将数据 I/O 重定向到其他地方。

实施工作量很大(好几个月)。

I wrote one, many years ago. The DDK (device driver kit) included sample source code for a filter driver for (i.e. immediately above) the parallel port driver: I adapted this sample to work with the serial port driver, and then added functionality such as monitoring and splitting.

This was serial ports, not USBs.

I also implemented another driver, which was a 'virtual' serial port, i.e. it implemented a serial port API but then redirected the data I/O elsewhere.

It was a lot of work (many months) to implement.

爱的十字路口 2024-08-10 02:26:10

一如既往,这取决于您要做什么。如果您需要弄乱两个串行设备之间的线路连接方式或需要一些“良好”的时序信息,最好的选择是外部 分线盒 就像安东尼已经告诉过的那样。

如果您只需要某种监控,可以使用 PortMon串口监视器

也许您编写了两个将通过串行连接进行通信的应用程序。要在没有本地环回电缆的单台 PC 上完成此操作,您可以尝试 Com0Com

As always it depends on what you're going to do. If you need to mess around with how the lines between two serial devices are connected or need some 'good' timing informations, the best you can get is an external break-out box like Anthony already told.

If you just need some kind of monitoring you can go with PortMon or Serial Port Monitor.

Maybe you write two applications which are going to communicate over a serial connection. To get this done on a single PC without a local loopback cable you can try Com0Com.

烦人精 2024-08-10 02:26:10

购买 RS232 DB9 串行数据分流器。这是一个连接在两个串行端口之间的硬件设备,被动监听设备之间的“聊天”。我使用以下设备两年半了,它为我节省了大量的故障排除时间和精力。 (我以前每天晚上都会把它带回家,以防止支持技术人员“借用”它。)制作这个设备很容易,但接下来的数据挖掘很灵活。

“利用串行数据流并透明地监视数据活动。输出可以馈送到监视器打印机或其他设备。Dip 开关允许编程以单独或一起监视主发送和接收线路。无需外部电源、易于安装、透明连接理想的 RS232/串行软件开发辅助工具。”

或者,制作或购买串行分路监视器电缆。请参阅 NST 文档了解一种可能的配置。

我强烈建议您不要使用软件解决方案,因为监控软件可能会受到物理情况的影响。

Purchase a RS232 DB9 Serial Data Tap. This is a hardware device that is connected between the two serial ports and listens passively to the "chatter" between the devices. I used the following device for two-and-a-half years and it saved me significant amounts of troubleshooting time and effort. (I use to take it home every night to keep support technicians from "borrowing" it.) It is easy to make this device, but the following data tap is flexible.

"Tap in on a serial data stream and transparently monitor data activity. The output can be feed into a monitor printer or other device. Dipswitches allow programming to monitor the main transmit and receive lines, individually or together. No external power required, easy install, transparent connection Ideal RS232/Serial software development aid."

Alternatively, make or purchase a Serial Tap Monitor Cable. See the NST documentation for one possible configuration.

I strongly recommend you do not use a software solution because the monitoring software may be affected by physical situations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文