Wednesday, July 29, 2009

Com0com no go

I had an email from Dave Freese, W1HKJ today. He is going to try to resolve the issue with Fldigi and the Eterlogic Virtual Serial Port Emulator and I have volunteered to help test any changes. Dave asked whether I was using the commercial (but free) VSPE or com0com which is an open source alternative. I had come across com0com some time ago, but it wasn't immediately apparent whether it did what I wanted, nor was it immediately clear how to use it.

I thought that while I waited for Dave to come up with something I would try com0com, because it would be nice to have a free open source solution to the problem of many programs wanting to access one radio. The VSPE is freeware (at least, the 32-bit version is) but it might not remain so forever. So I downloaded the com0com setup file and installed it.

Com0com is essentially a null modem emulator. That is, it sets up pairs of virtual serial ports that can be used to connect one program to another on the same computer without requiring two real serial ports and a cable connecting them. Because that's all it does, I had first thought that it was no use for my purpose. But there is a companion program called hub4com, available from the same site, that can be used to connect the ports together in various ways. You can connect a real serial port to two, three or more virtual serial ports, connect programs to the other ends of those serial ports, and by that means all those programs can talk to the device attached to the real port. At least, you could if it worked. But for me, it didn't.

Unlike the VSPE ports, com0com doesn't allow more than one device at a time to connect to one of its virtual ports. So if you want three different programs to be able to talk to your radio at the same time, you need to create three pairs of virtual ports. This is done by running the command line setup program setupc.exe and entering the following three lines (note that each line is split in two by your browser):

install 0 PortName=COM11,EmuBR=yes PortName=-,EmuOverrun=yes,HiddenMode=yes

install 1 PortName=COM12,EmuBR=yes PortName=-,EmuOverrun=yes,HiddenMode=yes

install 2 PortName=COM13,EmuBR=yes PortName=-,EmuOverrun=yes,HiddenMode=yes

This assumes that you want your three ports to be COM11 to COM13. You can change those port names and create more or fewer ports as you wish. You are actually creating virtual serial cables, and the "other" ends of these cables are also serial ports, which are named by default CNCB0, CNCB1, CNCB2 etc. It's useful to use these distinctive names for the other ends so they aren't confused with the ports your applications want to connect to.

An annoying feature of this software is that for each port you create - that's two ports for each virtual cable - the Windows Add New Hardware Wizard starts and has to be told to install drivers. The reason for this is that the com0com drivers are not "signed". This is one of the ways that Microsoft discriminates against free software and amateur developers. Signing drivers requires an expensive Authenticode certificate. This is free software, so there is no revenue to pay for one. So the drivers aren't signed. You can curse Microsoft every time the Wizard starts up. I did.

There is a graphical setup utility called setupg.exe. You can probably use it to create the ports instead of the command lines shown above. I used it to check that I had set the ports up correctly. The result should look something like the screenshot below.

In order to use these virtual cables to connect your logging software, digimode programs and so on to your radio, you must connect them together using the hub4com program. As I stated earlier, you can download this from the com0com site. It comes in a separate zip file and should be extracted into the same folder as the com0com program. You can then open a command prompt, go to the com0com program folder and enter a command like this (again it is one line):

hub4com.exe --route=All:0 --route=0:All --baud=38400 --octs=off \\.\COM1 \\.\CNCB0 \\.\CNCB1 \\.\CNCB2

This is supposed to connect the ports so that all data from CNCB0 to CNCB2 (which are the other ends of COM11 to COM13) goes to COM1 and your radio, and all data from the radio sent to COM1 goes to CNCB0, CNCB1 and CNCB2, and from there to COM11-13 and your programs. It also sets the baud rate to 38400, which is what I am using with my K3, and turns CTS off. It's probably advisable to put this command into a batch file, so you can easily re-run it (or make changes to it) without retyping. Obviously if your radio is connected to something other than COM1 you should change that part of the command.

Unfortunately, it doesn't work properly. At least, I couldn't get it to work properly. I did get KComm and Fldigi to connect (separately) to my K3 on COM1 via virtual port COM11. But a lot of the time nothing happened at all. And I never got two programs connected simultaneously.

I ended up using RealTerm (another SourceForge project) for testing, since it is much easier to see what is happening (or, most of the time, what isn't happening) than trying to use ham radio programs that just do nothing if they don't get what they wanted. I found that I could type commands - such as mode commands (MDx;) - while connected to any of the serial ports, and see the K3 respond to them. But output from the K3 was only sent to the first virtual port that connected to it, whichever that was. I also found that if I connected to a port, sent commands and received responses, disconnected, and then connected again, sometimes there was no communication on the second connection.

I spent a lot of time trying to find out what I was doing wrong, but it appeared to me that everything was set up correctly and the software was not performing according to the documentation. So I have given up on it. I am describing what I did here in the hope that someone cleverer or more persistent than me will find out what the problem is, get it working properly, and tell me.

It would be good to have a free, open source way of enabling two or more programs to talk to a radio simultaneously. But I just don't have the patience to spend any more time on it.

1 comment:

Unknown said...

Ran across your blog while looking for information on how to configure Com0Com and Hub4Com. I am successfully using SKCC Logger to retrieve QRG from my Kenwood TS-2000 while at the same time running DXLabs Commander to control the radio. Running both with Com0Com and Hub4Com.

73 de WY5R - KD