Here's a nugget: In the lab, we're quite regularly using UART-to-USB converters to connect hardware designs to standard desktop computers. Once connected, the devices appear as serial devices in the host's OS. That is rather nice, because you can immediately exchange bytes with the connected board or even hook a terminal program such as minicom or putty to it.

While that's all nice and cheap, we ran into a peculiar issue with windows xp as the host OS: Normally, when you want to open such a device from C or any other programming environment, you're opening a pseudo-file called "COM1" to open, well, the device registered as "COM1". That's almost all you need to do (well, there's some more but that's not relevant here). Now a colleague connected a board which was registered as "COM10". One piece of software in the lab scans for available com ports, but failed to detect "COM10". It found other hardware at "COM1" and "COM2" but not at 10. The colleague was also sure that the software did find a board registered as "COM9" just moments ago.

I had a hunch, so I googled for "windows comXX file names" - note the double "X". Shortly after that, I arrived at a microsoft support page, which explains the issue - or rather, it details a workaround:

HOWTO: Specify Serial Ports Larger than COM9
      "\\\\.\\COM10",     // address of name of the communications device

So, you got to use "\\.\COMXX" as the new magic file name for extended happiness. That technique also works with "COM1" through "COM9", so that's the universal way you want to use.

Even though our software is back to working as expected, this left me with that familiar "The Fuck!?" look on my face. Again.

Posted Thu 08 Sep 2011 11:10:47 CEST Tags: