f



serial port read

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 write.pl 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";

$PortObj->read_interval(100);
while(1)
{
func();
}

sub func
{
my($BlockingFlags, $InBytes, $OutBytes, $LatchErrorFlags) = 
$PortObj->is_status;

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


sleep(1);

}

any help appreciated,

thanks
jis
0
jis
4/19/2014 6:13:16 PM
comp.lang.perl.modules 4194 articles. 0 followers. jerrykrinock (6) is leader. Post Follow

0 Replies
714 Views

Similar Articles

[PageSpeed] 23

Reply: