SerialPort Sniffing

Aaron Summernite picture Aaron Summernite · Jan 22, 2012 · Viewed 8.7k times · Source

I have a device that connects to pc via USB, which gets mapped to virtual serial port by driver and a software, that connects to that serial port and allows me to manage the device. I don't know what protocol software uses to connect with the device. I could figure out the protocol by looking at communication between device and software, but the thing with serial ports is that once software connects to serial port, there is not way other software could connect to that port too (which makes sense of course).

So I thought I could write a piece of software that does following:

  1. connects to virtual serial port the device is at
  2. creates virtual serial port a software would connect to
  3. internally transfers everything from first port to second and vice versa, but logging all this information to some dump file

My question here is: is that possible to create virtual serial port using .NET? I heard no, because you somehow need to create a driver or something and that requires kernel-level programming, is that right? And if that is, still, is there a way I could observe communication between a device and a software without any bridging software?

Thanks in advance! Aaron

Answer

Shaun07776 picture Shaun07776 · Jan 22, 2012

Have you tried Portmon.

This is what the website says

it's a utility that monitors and displays all serial and parallel port activity on a system. It has advanced filtering and search capabilities that make it a powerful tool for exploring the way Windows works, seeing how applications use ports, or tracking down problems in system or application configurations.

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

KNOWN ISSUE: There's a bug in PortMon v3.03 (see here) which makes the needed 'Computer' menu item not appear on some systems. One workaround is to connect to local machine in v3.02 before opening v3.03.