Im working on a script to interface with a packet radio TNC which is attached to my BSD machine. Simple interactions with with the TNC working fine:
open (COM, "+<",$port) or die "Cant open $port\n";
print COM "c ",$station,"\r"; #try to connect
$_=<COM>; #grab the text returned
print STDOUT "Command sent: ",$_,"\n";
$_=<COM>; #grab the text returned
print STDOUT "more returned text: ",$_,"\n";
close (COM);
Simple operations like the one above are all fairly consistant in their behavior and the output is easily dealt with. Others, however, are not quite as simple. To summerize what Ive found:
- There are varying numbers of lines returned (0 to N)
- The time it takes to return a line of text can vary greatly (<1sec to a couple minutes)
- The only constant termination to work with is \r which appears on each line.
What I would *like* to do is to run $_=<COM> for $N seconds or until EOL whichever comes first. Any thoughts on how I would do this? Since I dont code all that frequently, any examples would be exceedingly welcome....
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.