Cannot access COM10: and above in Windows
I have some FTDI and CP2102 serial devices with so-called VCP (Virtual Comm Port) drivers in Windows. The first two worked, having been assigned names COM8: and COM9:. The third was called COM10:, but Tcl will not acknowledge its existence. I can talk to it in non-Tcl programs, including PuTTY.
"COM10:" is not a valid device name in Windows. As explained in the MSDN entry for CreateFile: "To specify a COM port number greater than 9, use the following syntax: "\\.\COM10". This syntax works for all port numbers and hardware that allows COM port numbers to be specified."
In Tcl you have to escape those backslashes, so you would use [open "\\\\.\\$comport" r+].
The Tcl docs are misleading in this regard; they say "An attempt to open a serial port that does not exist or has a number greater than 9 will fail. An alternate form of opening serial ports is to use the filename \\.\comX, where X is any number that corresponds to a serial port...". You can in fact open a serial port greater than 9 using the alternate form (only).
Very nice, this works. I'm sorry I missed that in the documentation. Has anyone considered modifying the Tcl filesystem code on Windows to recognize COM10:, etc. as an alias for \\.\COM10? PuTTY apparently does this, or it uses an alternate interface to access the device that bypasses this naming restriction. I see Windows allows COM10 and beyond as valid filenames, whereas it rejects COM0 through COM9. (Case insensitive.) Windows never allows names ending in colon, so maybe we could only apply this translation to names ending in colon, as I proposed above.
"Windows never allows names ending in colon"
That is technically incorrect. A colon in a file name indicates access to an alternate NTFS stream within the file, and CreateFile() supports an lpFileName ending in a colon in at least some circumstances.
Modifying the filesystem implementation imposes an overhead (albeit small) on all use to simplify an uncommon use case that is already platform specific (i.e. you don't open *nix serial ports using the "COMx:" name) and outdated (the "COMx:" x=1..9 DOS devices are supported in Windows for backwards compatibility). Introducing a Tcl-specific notion of a "COM10:" DOS device sounds wrong to me.
The correct approach is to update the Tcl documentation to reflect the correct names for COM devices on Windows, i.e. {\\.\COMx}, rather than referring to the legacy DOS device names "COM1:", etc.
When other application (like Putty) show you a "COM10:" they are using {\\.\COM10} internally; that is a UI issue.
Agree on all points.
So only the documentation request remains. This is documented in the open man page since a long time, see portability issues, Windows:
http://www.tcl.tk/man/tcl8.6/TclCmd/open.htm
So I close the bug.
Thank you all, Harald