Connecting multiple virtual serial ports together

However many times you may want to connect a real device to a virtual serial cable. This can be done using program hub4com. While the com0com works on the “driver side” of the com port the hub4com works on the “software side” and can be used to connect mutliple com ports (virtual or real ports) together. Also more than two ports can be connected together and ports may be forwared thru internet.

With this utility also also more complicated connections are possible, such as connecting multiple output serial ports to a single data source or making a software serial port sniffer cable. Hub4com is a part of com0com project, but is distributed separately. It can be downloaded here. You could also check one folder up to see if there are any newer versions. Unless you want to compile the program yourself you should download the binary version which is packed in To install it just unzip the contents of the archive to com0com installation folder (you will probably find it in Program Files x86).

To get some help for the program you have to run it without any arguments. You can do this from command prompt. Just clicking on the executable will show the help, but will dissapear too fast for you to be able to read it. First open a command prompt (Win Button + R, enter cmd into text box and press ok).

2015-01-14 21_35_56-Zaženi


Command prompt will start in your user directory so you have to navigate to the directory containing hub4com.exe In my case this can be done by entering “cd C:\Program Files (x86)\com0com” command into command prompt.

2015-01-14 21_40_47-C__WINDOWS_system32_cmd.exe

Now you can run the hub4com.exe program with “hub4com” command. This will show the help for the program.

For example a very basic setting would be to create a hub for three ports:

This will forward any data received on any port to both other ports. Note that CNC* ports are usually used with virtual only (not available to software) com0com driver and COM* are real or virtual comports. For running the above command you should have all the named ports set up as a com0com virtual pairs (for example CNCB0<>CNCA0, CNCB1<>CNCA1, CNCB2<>CNCA2).

If the communication devices don’t need any hardware flow control it is good to add the following modifiers to the hub4com to prevent issues with flow control:

Flow control is not necessary a bad thing, but if it is not used (and you don’t want to think / worry  about it) it is better to just turn it off. The full command would be:

For example we could use the above command for monitoring a communication between a USB GPS device connected to COM8 and host PC GPS software. Note that one of the ports has been changed to COM8 to directly connect to hardware port. (You will probably also want to set the baudrate with –baud=… setting.)

Our host PC GPS software would now connect to one of the two com0com connectors, for example to CNCA0. Our “sniffer” software would connect to the other connector CNCA1. On the CNCA1 port you can receive the data from both sides, however this simple sniffing configuration will only work nicely for half duplex communication (only one device communicating at one time). When both devices are sending data at once you will get mixed characters from both sources. There is no way to directly tell which device sent the data and you can not inject data to both devices.

For a more elaborate sniffing cable connection you could use the following command:

With this command the data from COM8 is connected to CNCB0(CNCA0) and CNCB1(CNCA1). The data from CNCB0(CNCA0) is forwarded to COM8 and CNCB2(CNCA2). This way the COM8 and CNCA0 communicate bidirectionally while we have a receive only ports CNCA1 and CNCA2. Each of these ports will be used for receiving/sniffing data from one of the bidirectional ports. This configuration is actually equivalent to what you will usually find online as a hardware bidirectional serial port sniffer cable.

By adding additional data routes you could also make the ports CNCA1 and CNCA2 be able to inject data to each of the bidirectional ports. This is a feature that can only be implemented in software as there is no way you can combine two RS232 TX signals in hardware…

I have only touched some of the things you can do with hub4com, also additional functions such as multiplexing, serial over internet, internet server and many more modes are available. Actually with so many settings available in hub4com the possibilities are countless, so your imagination is the limit (or maybe the amount of time you want to spend playing with it) 😉

Tagged with: , , , ,
3 comments on “Connecting multiple virtual serial ports together
  1. Louis Carrel says:

    Thanks for the article, a very nice read! However, I would like also to add, that there are also other pieces of software that can create virtual COM ports or let you connect a real device with a virtual port. All additional details can be found in the articles, like this one
    Software to connect real devices to a virtual serial cable

  2. Is it possible to switch baud rate up to 57600?
    Can you describe it?

    • dejko1 says:

      The com0com emulation normally doesn’t care about the baudrate, so you can safely connect with 57600 baud on one virtual port and 9600 baud on other port (which would not be possible in physical word). Actually com0com won’t emulate the baudrate mismatch on virtual fable (wrong data you would get), however you can use the “enable baud rate” tick to emulate the timings/delays caused by sending at the chosen baudrate.

Leave a Reply

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