From Win32::SerialPort:

Version 0.15 adds an optional $quiet parameter to new. Failure to open a port prints a error message to STDOUT by default. Since only one application at a time can "own" the port, one source of failure was "port in use". There was previously no way to check this without getting a "fail message".(italics added by starbolin) Setting $quiet disables this built-in message. It also returns 0 instead of undef if the port is unavailable (still FALSE, used for testing this condition - other faults may still return undef). Use of $quiet only applies to new.

This would imply something like:

{ $|++;print "\rPort Busy ",$i++;sleep 1; die "Can't wait any longer\n" if ($i>=15); } while (($portObj = new Win32::SerialPort ($PortName, $quiet))==0); die "Other reason for not working: $!\n" if ($portObj==undef);
I don't think $^E will have any information in either case as the port is not setup yet only the control block is being created and even that has failed, but that's an untested assumption.

If you haven't already, you should fully explore the resources on Bill's page

Good luck


s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}

In reply to Re: using win32::serialport by starbolin
in thread using win32::serialport by Anonymous Monk

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.