Skip to content
Tcl Source Code History Of Ticket 2913585
Login

History Of Ticket 2913585

Artifacts Associated With Ticket 2913585

  1. Ticket change [6169669eda] (rid 92237) by a_kovalenko on 2009-12-13 08:35:32:

    1. assignee initialized to: "andreas_kupries"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      1. set fd [ open COM5: r+]
          fconfigure $fd -blocking no
          puts $fd something
          close $fd
      Hangs indefinitely in SerialBlockingWrite() when the port is not connected.
      2. if we use -blocking yes instead, close $fd seems to succeed, but _leaves an open handle and a running SerialWriterThread_ forever: so we get "permission denied" when trying to reopen the port.
      
      Write timeout is ignored on Windows (it's documented at the open man page, and also obvious from the code).
      
      The error is fixable in many ways, of which I can't select the best one yet. The problem is that GetOverlappedResult() in SerialBlockingWrite() waits forever (an interesting thing is that the code below handles ERROR_COUNTER_TIMEOUT, though it can never really happen). Forwarding the write timeout to SetCommTimeouts() would at least give me an ability to close the port somehow. Ensuring that the handle is not open after successful [close $fd], whether  its mode is blocking or non-blocking, would also be a good practice (thus avoiding the awful non-blocking case described above, when the handle is inaccessible by TCL but continues to hold the device in busy state). 
      
      Also, [chan cancel] for all pending IO would be a good addition, but it's more about long-term TCL development plans.
      
      It may happen that there is an easy workaround for _usual_ (UART16550A PC) serial ports: putting them into -handshake none mode, when all pending writes should succeed immediately. However, it doesn't help with many other COMM devices, like com0com-forwarded channels, Bluetooth virtual serial ports and (maybe) some USB2RS232 adaptors. This difference explains why this error could live unnoticed for so long.
      
    4. foundin initialized to: "obsolete: 8.6b1.1"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "a_kovalenko"
    10. subsystem initialized to: "25. Channel System"
    11. title initialized to:
      [win32] serial channel blocks indefinitely on write
      
    12. type initialized to: "Bug"
  2. Ticket change [3d9e17e8ea] (rid 121116) by a_kovalenko on 2009-12-13 15:38:10:

    1. icomment:
      Errr, typo: please read "-blocking yes" above as "-blocking no" and vice versa.
      
      
    2. login: "a_kovalenko"
    3. mimetype: "text/plain"
    4. username: "a_kovalenko"
  3. Ticket change [37cda764eb] (rid 112094) by a_kovalenko on 2010-06-18 12:26:38:

    1. icomment:
      It turned out that there is a workaround for this bug, namely, 
      
      (#1) always wait for writable state, using [fileevent], before writing
      anything to port,
      
      (#2) _and_ don't set buffering to none (haven't yet tested what
      happens if I wait for fileevent and write more than -buffersize; it
      might as well be important always to write less).
      
      I continue to regard this as a bug, though: (#1) that is
      understandable and (#2) that is rather obscure must be _both_
      respected, and the penalty of uclosable channel and unopenable port
      (forever..err, until the application is restarted) seems cruel and
      unusual anyway. Documenting requirements (#1) and (#2) would be
      significantly better than nothing.
      
      
      
    2. login: "a_kovalenko"
    3. mimetype: "text/plain"
    4. username: "a_kovalenko"