Connecting multiple virtual serial ports together

Connecting multiple virtual serial ports together

Now that we know how the com0com works, we can try using it.

Open the com0com setup. Check if there is already a virtual com port pair connected and ensure it has ports class enabled.

If you already have a pair of connected virtual ports with COMx names you can skip the following paragraph.

If there is no pairs already created click Add Pair button to add a new pair. If Windows asks you to restart the computer just close the popup (no restart should be needed). New pairs by default are created as CNCAx <> CNCBx where x is a number. Newly created pairs don’t have port class enabled, so if you want to use them in programs you will have to enable it by checking the checkboxes and pressing Apply button. After enabling the ports class the port will become visible under a new name with COMx naming convention and will be available for use with programs.

 

2014-12-18 16_05_31-Setup for com0com

Here you can see that I have four COM port pairs installed, the chosen one for this example is COM6 and COM9 pair.

You can also check the device manager to see the ports that are available. The ports available to the programs will be listed under Ports (COM and LPT), while the serial port pairs and non-enumerable ports (available just to applications like hub4com) will be listed under com0com.

 

2014-12-18 16_06_14-Upravljanje računalnika 2014-12-18 16_07_00-Upravljanje računalnika

Now you can use your favorite terminal emulator software to connect to both of the serial ports to check the functionality. I will use RealTerm software in my example. Open two instances of the program. Open one port from the pair (COM6) in one instance and the other port (COM9) in the second instance of the program. To open ports in RealTerm you need to first choose the port name and then click the Open button. If changing the port settings you either have to click the Open button twice (to open and close the port) or click the Change cutton. You can send the data from one program to another, emulating a null modem cable. For sending data in RealTerm you can either type the data after clicking in the terminal window or you can use the Send tab. Send ASCII button sends the data in the text box next to it.

 

2014-12-18 16_15_07-RealTerm_ Serial Capture Program 2.0.0.70

Using the Pins tab you can also try out the flow control routing of com0com package. By default the DTR of transmitting port is connected to DSR and DCD signal inputs of the second port. RTS is connected to CTS. When you modify RTS or DTR signal on one port using Set or Clear buttons you can see the connected signals change on the other port.

2014-12-18 20_50_44-RealTerm_ Serial Capture Program 2.0.0.70

(This is a multipage post. Read on for examples on hub4com for connecting multiple ports >>)

Tagged with: , , , ,

5 Comments on “Connecting multiple virtual serial ports together

    • 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.

  1. Hello I have had good success using com0com to practice with virtual serial before going to real hardware and I wired together a serial sniffer cable so that I could separately capture the outgoing byte stream each direction. Now I need to do the same thing with a USB GPS device which uses the Prolific chipset USB serial and hub4com looks like the perfect solution but I cannot make it work.
    I have three virtual com port pairs setup:
    command> list
    CNCA0 PortName=-
    CNCB0 PortName=COM#,RealPortName=COM20
    CNCA1 PortName=COM#,RealPortName=COM16
    CNCB1 PortName=COM#,RealPortName=COM14
    CNCA2 PortName=COM#,RealPortName=COM18
    CNCB2 PortName=COM#,RealPortName=COM19
    and I launch hub4com in an admin cmd window with the command:
    hub4com –octs=off –no-default-fc-route=All:All –route=0:1,3 –route=3:0,2 \\.\COM20 \\.\COM14 \\.\COM19 \\.\COM8
    but I cannot open a connection to any of the com ports.
    The GPS software returns:
    “Error.. Cannot create UART handle. Comm port is not available or may be in use”
    and PuTTY returns:
    “Unable to open connection to COM? Unable to open serial port”
    I tried to connect to COM8, COM14, COM19 & COM20 I did not expect COM8 to work. I also tried the same hub4com as a standard user.
    Can you see what I’m doing wrong?

    • Hi, it’s been quite some time since I used this. The error seems to indicate that you probably have a handle open somewhere to that port. This may be due to other software trying to access it (eg. open in terminal or by system – legacy mouse and bt drivers may sometimes take over) or it being already in use. You can use RealTerm in sniffer mode (Echo port tab, Echo on, Monitor) with a single com0com port to do the bidirectional logging, however it will not work for high data troughput and is not as fast, so for some applications it may not work. There are also software solutions that enable you to examine tx/rx data at the driver level. I mainly still use a hardware 4 port cable or the above RealTerm solution. Regards,
      Dejan

Leave a Reply

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

*