25 Apr 2009

How to monitor serial ports in Windows

Lately I’ve been doing a lot of serial programming in C# to communicate medical equipment with a Windows Forms applications. If you have ever tried it you’ll know that serial communications in .NET, although conceptually easy, have a lot of little quirks. Sometimes you wish to monitor exactly the traffic that is flowing in the serial port.

Unfortunately there’s no way to open a serial port which is already in use. One possible solution is to use a Y-cable and split physically the cable. Today I’ve discovered a very nice tool from SysInternals (Microsoft now) called PortMon. It is capable of monitor and display serial port activity and it can even do it remotely. Basically you get a serial port sniffer.

If you just care about the OPEN, CLOSE, READ and WRITE operations, open the filter dialog and type:

IRP*

If you are doing any kind of serial port programming this tool is highly recommended.