What we did (for this exact same application :-) was write our own routine to get a line of data one character at a time using select. Here's the relevant bit of code (modified slightly from the actual code we use):

sub Gets { my($fh, $timeout) = @_; my($str, $c, $rin, $rout, $found, $timeleft); $rin = ''; vec($rin, fileno($fh), 1) = 1; $timeout ||= 1; while (1) { ($found, $timeleft) = select($rout=$rin, undef, undef, $timeout) +; last unless $found; sysread($fh, $c, 1); $str .= $c if ($c ne "\0"); last if ($c eq "\n"); } return $str; }

Hope this helps!


In reply to Re: Serial I/O and time question by duff
in thread Serial I/O and time question by shepner

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.