Archive for March, 2010

Windows and heaps of COM

March 10th, 2010

Here at Nias Digital we produce a number of products which appear as USB/serial devices.  Each time you plug one in Windows comes over all helpful and caches that particular device’s VID/PID/serial tuple against the COM number so next time you plug it in it appears in the same place.

The problem comes from the fact that many programs, including the Windows hotplug notification mechanism, only provide 7 or 8 bits of storage for the COM number – as soon as you plug in your 128th device some things break and by the 256th nothing works all that well any more.  The most common response to this problem is to manually change the COM number in the Advanced tab of the port settings dialog however all the numbers which Windows has cached as above are marked as unavailable – with the right device history there can be no ports left available in the working range!

To get around this some Registry hacking is in order.  First, clear out the unneeded VID/PID/serial cachings.  These are dependent on the manufacturer of the USB/serial bridge hardware but for FTDI parts you’ll find the mappings in
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Enum/FTDIBUS
Delete all the keys inside that path and you’ll clear the mappings.  The actual COM numbers though will still be marked as unavailable.  To clear this, find the key
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/COM Name Arbiter
(yes it’s the only key I know of with spaces in the same) That key has a binary value called “ComDB” which is a bitmask of all reserved COM port numbers.  For example, if it reads
ff f0 00 00...
Then then COM1 through COM12 will be marked as reserved.  If you’re running in to the same problems as me then at least the first 127 bits in the string will be set.  All you have to do is go through and 0 out bits corresponding to devices you don’t care about any more.  In my case I’ve got 10 internal serial ports (mostly on PCI serial expanders) so I edit my ComDB field to start with ff c0 and the rest 0s.  Be a little careful if you’ve got Bluetooth serial ports, they take up big chunks and removing their entries can break things.

Once that’s done, rejoice!  Plugging in new USB/serial adaptors (or old ones whose cachings you’ve removed) will now have their COM numbering starting down low again.

NOTE: Tested on XP and seems like it should work on later versions; if you have an addendum, post as comments :-)

Posted in Uncategorized | Comments (0)