首页 新闻 会员 周边 捐助

串口数据监听

0
悬赏园豆:30 [待解决问题]

本人想实现监听一个正在与其他软件通信的串口数据?用.NET提供的SerialPort类,与串口通信时必须要先open该串口,但是如果串口正在与其他软件通信,执行open操作会抛异常,拒绝访问该串口,如果在其他软件与串口通信前就执行open操作,又会影响到该软件与串口的通信。在网络上有很多封装好的软件可以实现串口数据监听,不知道是通过什么原理实现的?请问哪个高手指点指点一下,谢谢!

single-free的主页 single-free | 初学一级 | 园豆:52
提问于:2012-03-22 16:32
< >
分享
所有回答(4)
0

问嗷嗷

会长 | 园豆:12463 (专家六级) | 2012-03-22 16:43
0

先判断是否open。

rabbi88 | 园豆:4 (初学一级) | 2012-03-22 17:08
0

一個 串口,只能有一個軟件操作。如果一個打開了,另一個就打不開。可以 2個串口,並用同一個數據線,其實,是一個擴展。

無限遐想 | 园豆:3740 (老鸟四级) | 2012-03-22 17:17
0

可以看看 SysInternal 的 PortMon 的介绍

http://technet.microsoft.com/en-us/sysinternals/bb896644

The Portmon GUI is responsible for identifying serial and parallel ports. It does so by enumerating the serial ports that are configured under HKEY_LOCAL_MACHINE\Hardware\DeviceMap\SerialComm and the parallel ports defined under HKEY_LOCAL_MACHINE\Hardware\DeviceMap\Parallel Ports. These keys contain the mappings between serial and parallel port device names and the Win32-accessible names.

When you select a port to monitor, Portmon sends a request to its device driver that includes the NT name (e.g. \device\serial0) that you are interested in. The driver uses standard filtering APIs to attach its own filter device object to the target device object. First, it uses ZwCreateFile to open the target device. Then it translates the handle it receives back from ZwCreateFile to a device object pointer. After creating its own filter device object that matches the characteristics of the target, the driver calls IoAttachDeviceByPointer to establish the filter. From that point on the Portmon driver will see all requests aimed at the target device.

Portmon has built-in knowledge of all standard serial and parallel port IOCTLs, which are the primary way that applications and drivers configure and read status information from ports. The IOCTLs are defined in the DDK file \ddk\src\comm\inc\ntddser.h and \ddk\src\comm\inc\ntddpar.h, and some are documented in the DDK.

DiryBoy | 园豆:639 (小虾三级) | 2012-03-23 12:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册