How Com ports are allocated to Bluetooth drivers and how to diagnose and resolve installation issues because of this.
© Gijsbert van der Linden ()
Infralin Consultancy (http://www.infralin.com)
Last updated: 9-9-2004
Several Bluetooth applications like Microsoft’s ActiveSync and Nokia’s PC Suite make use of Com port emulations to communicate with a Bluetooth device. The Bluetooth driver maps the device to a Com port, while the PC application communicates with that Com port, without having to deal with the specifics of the Bluetooth protocol.
In many cases the mapping of these virtual com ports raises issues when installing applications. How does this mapping of com ports work, what are ways to diagnose the problems and how to resolve this.
My experience is based on the Sitecom dongle CN-502 with the Windows XP SP2 and Sitecom/Widcomm specific drivers, but the description in this document might very well be helpful for owners of other Bluetooth devices using virtual Com ports as well.
Windows keeps track of which Com ports have been allocated/blocked in the registry entry:
HKLM\System\CurrentControlSet\Control\Com name Arbiter\ComDB
The way this entry is coded was described on the X-Micro site, of which the following text was copied:
COM port database consists of a 32 integer array, with each bit (0 or 1)
representing whether a COM port is used. To make the Bluetooth COM port start
at a particular number, user needs to block all COM ports below that number,
install BTW to add the Bluetooth COM ports and reset the COM ports which we
blocked. So for example if you open up this Registry key and look at the
"ComDB" element you may see something like the following:
FF 1F 00 00 ... (NOTE: values are in hex, so change to binary where FF = 11111111, etc)
If you convert the values you see into binary (use the scientific calculator), each 0 or 1 will correspond to a COM port, if its free or used. If you have COM ports 1 thru 13 that are used, your registry looks like
FF 1F 00 00 ...
FF -> 1 1 1 1 1 1 1 1
COM PORT 8-7-6-5 4-3-2-1
1F -> 0 0 0 1 1 1 1 1
COM PORT 16-15-14-13-12-11-10-9
Start from top right and go right to left, top to bottom and see which port is blocked or available.
The key is as follows:
1 is blocked
0 is available.
So to block COM ports until COM 5 and start at COM 6, the registry would be
3F 00 00 00.....
3F -> 0 0 0 1 1 1 1 1
COM PORT 8-7-6-5 4-3-2-1
Be aware that a com port that is being blocked is not necessarily used for any application. When de-installing an application (e.g. the Widcomm drivers used by many Bluetooth dongles) these blockings are often not released.
To see which com port is allocated by which application/driver, have a look at the registry entry:
This is how this entry looks like on my laptop after installing the Sitecom/Widcomm driver and allocating some extra com ports through its Advanced Configuration option:
It shows that the com ports 4 – 8 have been allocated to the (Sitecom/Widcomm) Bluetooth driver.
The Bluetooth driver in its turn allocates the ports to applications. This is (for the Sitecom/Widcomm driver) governed through the registry entry:
(for the Windows XP2 driver the key is HKLM\System\CurrentControlset\Enum\BthEnum\...)
Each subkey defines one of the com ports allocated to the Bluetooth driver
This is how the first one looks like in my case:
"DeviceDesc"="Bluetooth Communications Port"
"FriendlyName"="Bluetooth Communications Port (COM3)"
The Sitecom/Widcomm driver keeps track of which ports it has already allocated and what next number to use, in the registry key:
Especially for Microsoft’s ActiveSync a lot of installation problems have been reported and I had my decent share of it. At first it worked without any problems, but after some other installations I could not get it to work anymore. The problem was (and often is with others) that ActiveSync only supports Com ports 1 – 9 and that many applications do not clean-up their com port allocations and blockings when de-installing itself. If all the Com ports in the range 1 - 9 have been allocated to (or blocked by) other applications, you’ll never get ActiveSync to work. The trick in this case is to manually de-allocate the com ports allocated by others. This is how to do this:
De-install the Bluetooth driver software and the Bluetooth applications.
See what com ports are still in use (using the registry key HKLM\HARDWARE\DEVICEMAP\SERIALCOMM) and update the ComDB registry entry as described above. This results in the following table for the first byte (the other 31 bytes should become/remain hexadecimal 00):
Highest com port used ComDB Hex value
Then delete all values for the Registry key:
(I actually removed more entries from the registry, but I suppose this was the one that made the difference).
Both the blocking of the com ports and the deletion of this entry should have been handled by the de-installation process of course, but as with many other applications, the de-installation process of the typical Bluetooth drivers leaves a lot of rubbish behind.
Once this has been done you can install the BT driver and ActiveSync software again, following the normal installation procedure. It should now assign low numbered com ports again. You are advised to install ActiveSync before any other Bluetooth application making use of Com ports.