Tcl Source Code

View Ticket
Login
2014-10-28
11:45 Ticket [dcc03414f5] open serial port on windows 7 failed status still Open with 4 other changes artifact: 8d7e5f71a6 user: jan.nijtmans
11:42
Revert bug-fix for [2413550], in order to be able to investigate whether it caused [dcc03414f5] or n... Closed-Leaf check-in: 35aa29eca7 user: jan.nijtmans tags: bug-dcc03414f5
2014-02-25
17:12 Closed ticket [2413550fff]: Avoid double-open of serial ports on Windows plus 8 other changes artifact: 0f7bd6e2f2 user: oehhar
17:06 Add attachment serialTest.tcl to ticket [2413550fff] artifact: bf2444911e user: oehhar
08:02
Do not reopen a win serial channel for serial detection. There are issues with some Bluetooth virtua... check-in: eb0919a1ec user: oehhar tags: trunk
2014-02-24
17:25
Do not reopen a win serial channel for serial detection. There are issues with some Bluetooth virtua... check-in: b6459ef66c user: oehhar tags: core-8-5-branch
2014-02-18
19:55 Ticket [2413550fff] Avoid double-open of serial ports on Windows status still Open with 4 other changes artifact: 2b1a24d168 user: oehhar
2014-02-15
15:12 Ticket [2413550fff]: 4 changes artifact: 5f550355ff user: dkf
2014-02-14
08:01 Add attachment tcl8.6.1-bug-2413550.diff to ticket [2413550fff] artifact: 1586b1350f user: oehhar
07:59 Ticket [2413550fff] Avoid double-open of serial ports on Windows status still Open with 4 other changes artifact: 5776ddc74a user: oehhar
2014-01-30
11:04 Ticket [2413550fff]: 8 changes artifact: 4fea181e24 user: oehhar
11:02
win/tclWinChan.c Tcl_InitNotifier: Bug [2413550] Avoid reopening of serial channels which causes iss... check-in: 84307fe13f user: oehhar tags: bug-2413550
2008-12-11
21:45 Add attachment no_double_serial_open.patch to ticket [2413550fff] artifact: 610be90398 user: ferrieux
21:45 Ticket [2413550fff] Avoid double-open of serial ports on Windows status still Open with 4 other changes artifact: 724e1d0756 user: ferrieux
21:42 Ticket [2413550fff]: 4 changes artifact: 3890368ef9 user: schroedter
2008-12-10
10:26 New ticket [2413550fff]. artifact: d19ad23a49 user: ferrieux

Ticket UUID: 2413550
Title: Avoid double-open of serial ports on Windows
Type: Patch Version: None
Submitter: ferrieux Created on: 2008-12-10 10:26:48
Subsystem: 27. Channel Types Assigned To: oehhar
Priority: 8 Severity: Minor
Status: Closed Last Modified: 2014-02-25 17:12:06
Resolution: Fixed Closed By: oehhar
    Closed on: 2014-02-25 17:12:06
Description:
Currently, opening a serial port on Windows involves a double-open: (1) open generically (2) check the handle for serialness (3) reopen with OVERLAPPED flag if serial.

This causes trouble in some setups where the open/close (and its timing) is not transparent to the underlying driver, like bluetooth RFCOMM profile. See 

http://groups.google.fr/group/comp.lang.tcl/tree/browse_frm/thread/9f2f29db7b5864fd/fd6d04dbc15d8575?rnum=1&_done=%2Fgroup%2Fcomp.lang.tcl%2Fbrowse_frm%2Fthread%2F9f2f29db7b5864fd%2Fdd17ccbb0019ed90%3F#doc_fd6d04dbc15d8575

for a concrete example.

A simple and efficient solution is to use a "name hint" to detect COM ports by their filename instead of resorting to a syscall to detect serialness after the fact.

Rolf Shroedter has suggested that at least the two following patterns should be detected:

      COM[0-9]:?
      \\.\COM[0-9]+:?

It also turns out that the first one should be applied to the [file tail], since \foo\bar\COM4 is also a valid serial port reference in Windows.

However, we believe that a good strategy should be to make only a reasonable effort in that direction, leaving tricky cases handled by the current behavior; this in order not to spoil the performance of [open] for non-serials.

A patch will be uploaded shortly to support just the above two patterns.
User Comments: oehhar added on 2014-02-25 17:12:06:

Merged to core-8-5-branch [b6459ef66c] and to trunk [eb0919a1ec].

Phil Hoffman tested succesfully with the attached script.

Bug closed, thank you all,

Harald


oehhar added on 2014-02-18 19:55:32:

Thank you, Donal, for the comment.

Tests:

  • As the issue only appears with special hardware, this is imho not possible

Docs:

  • IMHO the docs are sufficient. On the open man page, the windows formats for serial ports are specified as "comx:" and "\\.\comx" which are the supported formats by the patch. So we do not need an alert, that "exotic but possible" file names for serial ports are not supported by hardware not supporting the double open (which is rare).
  • The only enhancement on the man page would be to remove all the Windows 95 and Windows 98 parts.

I was ready to commit today, but have test failures. I have to check, if they are due to the patch or not... Sorry, will take a week (I am on travel).

Harald


dkf added on 2014-02-15 15:12:21:

Should we add any tests? Should we add any docs? (With these settled, I see no reason to not commit.)


oehhar added on 2014-02-14 07:59:55:

Action by Phil Hoffman:

  • branch bug-2413550: [024a523361] successfully tested
  • Tested patch for tcl8.6.1 provided


oehhar added on 2014-01-30 11:04:54:

Patch applied for tcl 8.5 in branch [84307fe13f]


ferrieux added on 2008-12-11 21:45:40:

File Added - 304912: no_double_serial_open.patch

File Added: no_double_serial_open.patch

schroedter added on 2008-12-11 21:42:32:
The following patch performes a "name hint" to detect native Windows serial port name by one of the following patterns (case-insensitive). Pattern matching is checked quite restrictive, because *all open-filenames* need to pass this test.

COM[1-9]:?
\\.\COM[0-9]+
//./COM[0-9]+

For all filenames not matching the patterns above, the original behavior open-close-reopen is preserved, thus supporting (virtual) comports of any other name:
1. Open channel with NON-OVERLAPPED flag
2. Detect serial port by checking GetCommState() result
3. Reopen the serial port with OVERLAPPED flag
This behavior can be enforced even for native Windows serial ports e.g. with 

[open /com1 r+]

Attachments: