require 5.003; use Win32::SerialPort qw( :STAT 0.19 ); use strict; my $line; my $deck = openSerial("com3:", 19200, 'none', 8, 1); # $deck->handshake("xon"); # $deck->buffers(4096,4096); do { my $bytesWritten = $deck->write('$CCPDT,1,4,0,0,3000,1,0,0,0' . "\r\n"); $line = rawReadSerial($deck); } while (1); sub readLineSerial { my ($ser) = @_; my ($numChars, $c); my $line = ''; do { do { ($numChars, $c) = $ser->read(1); } while ($numChars < 1); $line .= $c; } while ($c ne "\n"); return $line; } sub rawReadSerial { my ($ser) = @_; my ($numChars, $c); my $line = ''; do { do { ($numChars, $c) = $ser->read(1); #print "$numChars read=$c\n"; } while ($numChars < 1); print $c; $line .= $c; } while ($c ne "\n"); return $line; }