Perl - serial input and buffering problem

J

jc

Hello.
I'm inputting from a barcode reader to a serial port (with Active State
PERl 5.6.1 and using W2000). This sends strings similar to;
"abcdefg<cr>"
(ie a string with a carriage return on the end).


My problem is that the string presented in the Perl program is always 1
behind the current string just scanned.

I'm using code similar to;
############################
$/ = "\r"; # Set up the record separator

open( FRED, "+>COM1" ) or die "error message";
my $mystring;
$mystring = <FRED>;
print $mystring;
############################

Regards JC......
 
B

Bob Walton

jc said:
Hello.
I'm inputting from a barcode reader to a serial port (with Active State
PERl 5.6.1 and using W2000). This sends strings similar to;
"abcdefg<cr>"
(ie a string with a carriage return on the end).


My problem is that the string presented in the Perl program is always 1
behind the current string just scanned.

I'm using code similar to;
############################
$/ = "\r"; # Set up the record separator

open( FRED, "+>COM1" ) or die "error message";
my $mystring;
$mystring = <FRED>;
print $mystring;
############################

Regards JC......

You will probably have better results if you

use Win32::SerialPort;

It seems to deal well with all the foibles of the Windows implementation
of serial ports. HTH.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,048
Members
47,650
Latest member
IanTylor5

Latest Threads

Top