Tcl Source Code

View Ticket
Login
Ticket UUID: dcc03414f517b7a74998e606a2d2c3692ccbfef2
Title: open serial port on windows 7 failed
Type: Bug Version: 8.5., 8.6.2
Submitter: lll Created on: 2014-10-28 09:15:56
Subsystem: 27. Channel Types Assigned To: oehhar
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2014-11-03 10:24:43
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2014-11-03 10:24:43
Description:
I have a usb-serial port cable [pl2302], enumerated as com3 in my windows 7 box. In interactive tclsh86, I can open com3 with: [open com3: r+] without any problem. But if I save the command to a file: anyname.tcl, for example. and run >tclsh anyname.tcl it will give: couldn't open "com3:": no such file or directory ...

    I tried tcl85, same problem. but There is no problem with tclsh84.
User Comments: jan.nijtmans added on 2014-11-03 10:24:43:
Thanks, LL L, for testing!

Indeed error-message was empty when the filename contains invalid characters. On Windows ':' in a filename is invalid if it is not part of an extended device or a drive prefix.

Fixed in core-8-5-branch and trunk.

oehhar added on 2014-11-03 09:33:19:

I have retried the "open COM30: r+" issue. It raises an error with an empty error message:

% open COM30: r+
% set errorInfo

    while executing
"open COM30: r+"

This issue rises for the following versions for me:

  • TCL 8.5.16
  • TCL 8.5.17

and not in

  • TCL 8.4.20
  • TCL 8.5.12
  • current 8-5-branch (exe I have sent around)
  • TCL 8.6.1
  • TCL 8.6.3rc1

So I suppose, this issue was cured in the meanwhile.


oehhar added on 2014-11-03 08:02:02:
Thanks, LL L, for testing.

I suppose with the "COM30:", you hit another bug not related to that.
With "COM30" you don't open a serial port but a regular file.
With "COM30:", I dont know what this is and why there is just no answer...

Thank you,
Harald

lll added on 2014-11-03 01:59:34:
Hi,
It seems that this version can open both valid comX with or without ":".
There is no feed back (exception) if I give a invalid com number with ":", see logs below~

D:\Tcl_Source_Code-25a624797c\win\Release_VC10>tclsh85.exe
% open com3 r+
filea03ef8
% close filea03ef8
% open com3: r+
filea03ef8
% close filea03ef8
% open com30 r+
couldn't open "com30": no such file or directory
% open com30: r+

%

oehhar added on 2014-10-31 13:53:19:

The issue is, that "COM3:" is not accepted, while "COM3" is. It is not clear why this is the case as the patch explicitly does cover this case.

But anyway, Jan has prepared the patch [25a624797c] to remove the ":" for all system calls, which is the recommended action for windows.

This works well for me. I am not sure if we should document, that "com3" and "com3:" actually works, as the open man page only states "com3:".

Harald


lll added on 2014-10-31 01:21:12:
Good news.
I can also open the virtual port [com3] without the ":" suffix in my script with version 8.6.2.
It looks like I have found a work around and don't have to revert whole things back to version 8.4. 
Good job!

Thanks,
LLL

oehhar added on 2014-10-30 16:43:42:
Sorry, last post was a ":" missing:

Wrong: "COM3:"
Correct: "COM3" or "com3" or "Com3"...

Sorry,
Harald

Here is the log of Phil:
Under wish86:

(System32) 18 % set fp [open COM3 r+]
file1f84670
(System32) 19 % close $fp
(System32) 20 % set fp [open COM3: r+]
couldn't open "COM3:": no such file or directory
(System32) 21 % set fp [open //./COM3 r+]
file1f84770
(System32) 22 % close $fp
(System32) 23 % set fp [open {\\.\COM3} r+]
file1f84770
(System32) 24 % close $fp
(System32) 25 % set fp [open //./COM3: r+]
couldn't open "//./COM3:": no such file or directory
(System32) 26 % set fp [open {\\.\COM3:} r+]
couldn't open "\\.\COM3:": no such file or directory
(System32) 27 % info patchlevel
8.6.2
(System32) 28 %

Interesting enough, under tclsh

PS C:\Users\Phil> tclsh
% set fp [open COM3: r+]
file150ac50
% close $fp
% info patchlevel
8.6.2

oehhar added on 2014-10-30 16:21:20:
Phil Hoffman pointed out that the correct name is "com3" not "com3".
This might be the explanation...

LLL, may you please check ?

Thank you,
Harald

jan.nijtmans added on 2014-10-30 08:31:13:
Branch [bug-dcc03414f5] was meant to investigate whether [2413550] caused this regression or not. It was not meant to be merged to trunk.

Since III now confirmed that [bug-dcc03414f5] fixes his problem, we are now sure on which commit caused the regression. Should be investigated before taking further action.

oehhar added on 2014-10-30 08:23:59:
Hi Ill,

well, the initial issue was similar to yours and the now reverted patch is IMHO a good thing.
We have to find out why it fails when run with a script and not when run interactively.

So, no direct revert I suppose, sorry.
The fix was delivered by another person. I will try to contact him and get direct communication.

As serial com adapter drivers tend to be buggy and often do not supporte the full serial api (no control lines etc), it would be helpful to know the type of the adaptor and the driver version. Due to this fact, only you can test, sorry.

Thank you,
Harald

lll added on 2014-10-30 08:13:44:
I don't have time to look into the source code now. 

I tried latest release of tcl8.6.2 on another machine (win7/32). 
[open comX: r+] failed on both interactive and non-interactive mode(script) with usb-serial cable (virtual com port X), no problem with tcl8.4.

lll added on 2014-10-30 01:56:46:

good news. ~ I compiled and tested OK. Thank you for your help. and when i can get the official release with this bug fix?


jan.nijtmans added on 2014-10-29 09:03:28:

Checkout [35aa29eca7] compiles file with MinGW, MinGW-w64 and VS2012. I suspect you compiled with MSVC 6.0, which doesn't work out-of-the box. You will need the latest Windows PSDK which works with VC++ 6.0 (whatever that is ....) as well.


lll added on 2014-10-29 01:42:30:
I got errors while compiling the version.
http://core.tcl.tk/tcl/artifact/8714d30185695cd50aebdcd7adc8c2709eccf442

jan.nijtmans added on 2014-10-28 11:45:04:

I strongly suspect that this bug is introduced with the fix for [2413550] (even though I don't have com3 so I can neither test nor reproduce this.

Can you test [35aa29eca71dee14a931410b0e51c573aab91450|35aa29eca7] (which simply reverts that patch), in order to verify this theory? Assigning to Harald. Feedback from any other person who was involved with [2413550] appreciated!


Attachments: