Monitor a COM port already in use

12,793

Solution 1

Yes, this is technically possible. You'll need a filter driver, a device driver type of a component that injects itself ahead of the native serial port driver. It gets a crack at the driver IRPs before sending them on to the regular driver.

This is the technique used by SysInternals' PortMon utility. However, you cannot write such a driver in C# code, the CLR cannot be loaded into ring 0. At least not until the super-secret Midori project sees the light of day.

COM filter drivers are pretty common, check out this one for example. You have to do some googling to find one that has a .NET wrapper though.

Solution 2

PortMon is the classic COM port monitor. It has to be running before the program opens the COM port, but the monitoring part can be enabled/disabled.

Solution 3

com0com may satisfy your needs. It worked for me.

Solution 4

You can use Portmon for Windows to monitor the activity. The other way I do this is with some hardware and a laptop. I'm not sure how you can monitor it yourself with a C# app. Once you are connected to it and attempt to connect again it will already be in use.

Also check this out, it's somewhat related, with a note on how PortMon works:
Serial Port Redirection or Splitting - Stack Overflow

If you have or can get more than one COM port, you could use a splitter and do the monitoring from the other port.

Share:
12,793
rross
Author by

rross

Updated on June 04, 2022

Comments

  • rross
    rross almost 2 years

    Is it possible to read from a COM port already in use on Windows XP?

    I would like to see the communication between some software and a device plugged into a serial device. I wrote a small program using C# to monitor the COM, but once it's in use by the other device it will not let you open it again. How can one monitor a COM port already in use?

    I'm open to third-party software.