Hi Perl Monks,

I'm using Win32::SerialPort to connect to a virtual COM device. When I (accidentally) disconnect the device, such that the virtual COM port does no longer exist, any attempt to read or write to it will hang my Perl program forever, regardless of any timeouts set.

Is there a way to either avoid this hangup or to detect whether the COM port still exists and the serial port is still connected to it?

Just checking for the COM port to exist (e.g. using a lookup in the Registry) doesn't solve the problem, as accesses then also hang the program, if the COM port was only temporarily disconnected, in which case the COM port exists (again), but the Win32::SerialPort object is no longer connected to it properly.

Any help greatly appreciated!

In reply to Win32::SerialPort - How do I detect if device is still connected? by petro4213

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.