in reply to Best way to read/write to a serial port
You may want to look at the 3 parameter 'open'.
open( $com, "+<","/dev/ttyUSB0" ) || die "Cannot open serial port : $! +\n"; while( 1 ) { my $in = <$com>; # input # do stuff here ( You should be able to do both input and output w +ithin the loop. print $com "..."; # output if ( $in eq "quit" ) { last; } }
The default behavior of a 2 parameter 'open' is output only. Look at the documentation for open for more information. Also look at 'read/write' and 'sysopen/sysread/syswrite' if you need to input/output a specific number of bytes. ( Especially if your going to pad with the "\0" null character. )
Good Luck.
"Well done is better than well said." - Benjamin Franklin
|
|---|