Definition: com0com (Null-modem emulator) is an open-source kernel-mode virtual serial port driver for Windows. It enables developers and engineers to create interconnected pairs of virtual COM ports (e.g. COM3 <-> COM4) without physical serial hardware or cables.
What is a Null Modem?
Historically, a null modem is a physically crossed RS-232 serial cable used to connect two DTE (Data Terminal Equipment) devices directly—such as two PCs—without a modem in between. The Transmit (TX) line of one device connects to the Receive (RX) line of the other, and hardware handshaking lines (RTS/CTS, DTR/DSR) are cross-connected.
RS-232 Signal Line Breakdown
- TX (Transmit Data): Outgoing data line carrying serialized binary data from the transmitting device. Connected directly to the remote device's RX pin.
- RX (Receive Data): Incoming data line receiving serialized binary data. Connected to the remote device's TX pin.
- RTS (Request To Send): Hardware flow control signal asserted by the sender when it has data ready to transmit. Connected to the remote device's CTS input pin.
- CTS (Clear To Send): Hardware flow control input line asserted by the receiving device to indicate its buffer is ready to receive data. Connected to remote RTS output.
- DTR (Data Terminal Ready): Handshaking line driven by the DTE device to signal power and operational session readiness. Crossed to remote DSR and DCD.
- DSR (Data Set Ready): Handshaking input line indicating the connected modem/device is active and ready for communication.
- GND (Signal Ground): Common electrical ground reference line (Pin 5 on DB9 connector) shared between both devices.
How com0com Virtual Null-Modem Driver Works
The com0com driver creates virtual device instances in Windows kernel space. When an application writes data to virtual port CNCA0 (aliased as COM3), the driver redirects the data stream directly into the input buffer of virtual port CNCB0 (aliased as COM4), simulating an instantaneous physical null-modem link with near-zero latency.
Key Use Cases
- Embedded Systems Emulation: Test desktop firmware software against hardware emulators without requiring physical USB-to-Serial adapters.
- Industrial Protocol Testing: Simulate Modbus RTU, NMEA 0183 GPS telemetry, or SCADA equipment locally.
- Legacy Software Bridging: Connect two legacy Windows applications that expect dedicated hardware COM ports.
- Automated Testing Pipelines: Run CI/CD unit and integration tests for serial communication drivers entirely in software.
Configuring Virtual COM Pairs via CLI (setupc.exe)
While com0com offers a graphical user interface (GUI), it can be fully scripted and configured using the command-line utility setupc.exe:
# Install a new virtual port pair
install PortName=COM3 PortName=COM4
# View existing virtual port pairs
list
# Enable baud rate emulation (optional)
change CNCA0 EmuBR=yes
change CNCB0 EmuBR=yes
# Remove a virtual port pair
remove 0
Comparison: Physical vs. Virtual Serial Ports
| Feature | Physical Serial Port (RS-232) | Virtual COM Pair (com0com) |
|---|---|---|
| Hardware Required | RS-232 Cables, USB-to-Serial DB9 | None (Kernel Driver) |
| Maximum Speed | Typically 115,200 baud (up to 1-3 Mbps) | Unlimited (RAM throughput GB/s) |
| Latency | Physical propagation delay | Near-zero (<1 ms memory copy) |
| Signal Pin Emulation | Physical voltage levels (±12V) | Software emulated (RTS, CTS, DTR, DSR, DCD) |
Complementary Tool: com2tcp
Included with the com0com suite is com2tcp, a console application that bridges a virtual COM port to a TCP/IP network connection. This allows serial applications to communicate over Ethernet or local sockets seamlessly:
# Bridge virtual COM4 to a remote TCP server on port 4000
com2tcp.exe \\.\CNCB0 192.168.1.50 4000