The Update 2 is closer to the actual issue. There is a purge_all when the port is closed (close is also called from DESTROY). When I look at the TK example I put into the CPAN distribution (eg/demo7.plx), I see a blocking write near the beginning with the comment:
# "write" first to init "write_done"
and explicit checks of write_done(0) around the Tk callbacks to prevent beginning new writes while an old one is in progress. That demo also ran with no handshaking.

In the code given, it is not clear which internal operations are blocking/non-blocking. But he does comment on handshaking and buffer management (and uses the is_xx_limit parameters).

I have to speculate a bit about the state information. It is not stored explicitly, although when he closes the app with characters remaining in the write buffer - but blocked by the handshaking - they are actually in the serial driver's buffer (during an "overlapped", i.e. non-blocking TO PERL background write). It is not clear if both Perl and Tk are closed before restarting. He may be holding an OS handle open. But I don't know for sure.

I do think flushing the buffer on close (e.g. by setting handshake to 'none' or doing a blocking write) will fix the problem.

-bill

Edit by tye: Preserve formatting


In reply to Re^2: Win32::SerialPort Error: Overlapped-I/O operation is in progress by Anonymous Monk
in thread Win32::SerialPort Error: Overlapped-I/O operation is in progress by Dr. Mu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.