Do you have a question? Post it now! No Registration Necessary. Now with pictures!
April 19, 2014, 6:13 pm
rate this thread
I am not able to read the data from serial port.
i have a trick done.
I have a program, which throws data on serialport. i want to spy this serial port,
so i created a virtual port pair, com8-com9. the program dump the data into com8.
and i try to read the data from com9.
i see two issues -
1. I am not able to read any data using perl script from serial port com9. but i can see the data on a hyperterminal.
2. whenver i run the data, i get the error.
"Second Read attempted before First is done at write.pl line 39."
# create some widgets here
our $buffer = '';
our $data ='';
our $PortObj = Win32::SerialPort->new ('COM8', 1) or die "Can't open serial
port COM1: $^E\n";
$PortObj->baudrate(115200) or die "fail setting baud rate";
$PortObj->parity("none") or die "fail setting parity";
$PortObj->databits(8) or die "fail setting databits";
$PortObj->stopbits(1) or die "fail setting stopbits";
$PortObj->handshake('none') or die "fail setting handshake";
$PortObj->write_settings or die "fail write settings";
my($BlockingFlags, $InBytes, $OutBytes, $LatchErrorFlags) =
my $count_in = $PortObj->read_bg(10);
my ($done, $count_in, $string_in) = $PortObj->read_done(1);
# background read with wait until done
any help appreciated,