serial port read

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

here is the challenge i have  

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 line 39."

use Win32::SerialPort;
use strict;
my $InBytes=0;
# 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";


sub func
my($BlockingFlags, $InBytes, $OutBytes, $LatchErrorFlags) =  

return unless($InBytes);
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,


Site Timeline