PuTTY Loopback Test: Verify a Virtual COM Port Pair in Minutes

Before you debug an application, debug the plumbing. The loopback test is the serial world’s oldest sanity check, adapted to a virtual pair: open a terminal on each end of the pair, type in one, and watch the characters arrive in the other. If they do, the driver, the pair and the port names are all proven good, and whatever problem you actually have lives in an application or its settings. If they do not, you have learned that in two minutes instead of an afternoon. This guide uses PuTTY; Tera Term or any other serial terminal follows the same steps with the same settings.

You need one com0com pair — the first-pair guide creates it — ideally renamed to COM names such as COM10 and COM11 (see the rename guide), because terminals list COM-style names in their port pickers and the CNC names can be awkward to select.

Session settings for the first window

Start PuTTY and build the session for the first end of the pair:

  1. Session category: set the connection type to Serial. In the Serial line field enter the first port, for example COM10. In the Speed field enter 9600 — the number is nominal on a virtual pair (with baud emulation off, com0com transfers as fast as it can whatever you set), but both windows and later your application should agree on it as a matter of hygiene.
  2. Connection > Serial category: set Data bits to 8, Stop bits to 1, Parity to None, and Flow control to None. Flow control off is the important one for a first test: a terminal waiting for a hardware handshake signal that a virtual pair is not asserting will look exactly like a dead port.
  3. Terminal category (optional): tick Local echo if you want to see your own typing in the window you type it in. With local echo off, what you type appears only in the other window — which is actually the cleaner proof, since anything on screen must have crossed the pair.
  4. Click Open. A blank terminal window with a cursor is success at this stage; an error dialog about opening the port is a finding, and the troubleshooting section below says what it means.

Save the session under a name like pair-end-a before opening it if you will repeat this test often — you will.

The second window and the type-across test

Start a second PuTTY instance and repeat the setup for the other end of the pair (COM11 in our example), identical line settings. Now type a sentence in the first window. Every character should appear in the second window. Type in the second window: the characters should appear in the first. That is the whole test, and a full pass means the pair carries data in both directions — the virtual equivalent of plugging a null-modem cable between two ports and watching both sides talk.

A useful variation: close one window, type a line into the other, then reopen the closed window’s session. On a default com0com pair you may find the line you typed waiting for you, because with receive overrun emulation off, characters sent while the far end is closed stay in the buffer instead of being discarded. That is documented driver behaviour, not a fault — com0com hangs and leftover characters explains it and the setting that makes the pair behave like a real cable here.

Testing your own application on the other end

The loopback becomes a development tool the moment one window is replaced by your program. Close the second PuTTY window, start your application configured for COM11, and keep PuTTY on COM10. Now you are the device: whatever your application sends appears in your PuTTY window, and whatever you type in PuTTY is delivered to your application as if a real instrument had sent it. This is the fastest way to answer the two questions that dominate serial debugging — what exactly did my program send? (look at the terminal) and does my program react correctly to this reply? (type the reply by hand). The workflow generalises into a full no-hardware test bench in testing a serial app without the hardware, and in automated form in the pySerial testing guide.

Testing a physical device or its app through a pair

The same trick extends one step further when a real device enters the picture. A common pattern: the device talks to a vendor application that exposes its data onward, or a data-forwarding tool bridges the physical port to a virtual one — the pair then lets a second program (yours, or a terminal) observe or share the conversation instead of the device being locked to a single application. The hub tool from the same project, hub4com, is built for exactly that bridging and splitting work; the hub4com guide explains how it routes a physical port to virtual ends. Even without the hub, simply proving ‘device to its own app works, app to pair works’ isolates faults to one side of the boundary at a time.

Log the session when the result matters

A loopback test you run once to convince yourself needs no record. A loopback test you run to convince a colleague, a vendor or your future self deserves one, and PuTTY can keep it: its session logging options record everything the terminal receives to a text file. Log the application-testing variant especially — the file shows the exact byte stream your application emitted, timestamps aside, in a form you can attach to a bug report or diff against a later run. When the ‘device’ on the other end misbehaves in the field, a logged known-good conversation from the pair is the reference you compare it against. Tera Term offers equivalent logging if that is your terminal; the habit matters more than the tool.

What a failed test tells you

  • PuTTY cannot open the port at all. The port may not exist (the pair was removed, or the driver is not loaded), or another program already has it open — serial ports are exclusive. If the driver itself is in trouble after installation, start from the troubleshooting hub.
  • The port opens but is not listed in the picker. Usually a naming issue: the pair still carries its CNC names. Rename it, or put it in the Ports class — see port not recognized for the full picture.
  • Characters appear in one direction only. Recheck that both windows use the same port settings and that you opened both ends of the same pair — with several pairs on a system, COM10’s partner is the end it was created with, not the numerically adjacent port.
  • Garbled characters. On a virtual pair this points to mismatched line settings between the two ends (speed is cosmetic here, but data bits and parity are not) rather than to a bad cable — there is no cable.
  • Nothing appears, but no error either, and flow control is on. Turn flow control off in both windows and retest; a handshake line held in the wrong state silences a port without any error message.

A passed two-window test is a small result with large value: it converts ‘the serial part is broken somehow’ into ‘the serial plumbing is proven; the bug is in this application or its configuration’. Keep the two saved sessions around — on a serial project, you will reach for them weekly.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *