in reply to Win32::SerialPort code hanging while reading a 'line'
Is there a reason you are using your own wrapper instead of lookfor? It won't block if there is no incoming line like your wrapper will.
Here's some untested code that is structured much the same way as my other serial code. $p is the serial port object.
$p->are_match( "\r", "\n" ); while () { if( my $line = $p->lookfor ) { Process_Line( $line ); } if( $p->write_done(0) ) { my $command = Fetch_Command(); $p->write( $command ) if $command; } sleep 1; }
TGI says moo
|
|---|