Monitor a Serial Port (Win2k)

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

I have a Barcode-Scanner wich is connected to a com-port. When i start
the Hyperterminal and set the comport, i see the data that sends the
Scanner when i scan a label. This works fine.
Yet i will use the Scanner with this PerlScript:

use Win32::API;
use Win32::SerialPort;

my $Port = 'com7';
$Configuration_File_Name = 'config.sys';

$handle = new Win32::SerialPort ($Port, $quiet)
       || die "Can't open $PortName: $^E\n";

$handle->write_settings || die "Can't initialize Handle\n";

       || warn "Can't save $Configuration_File_Name: $^E\n";

       || warn "Can't reread $Configuration_File_Name: $^E\n";

open (LOG,">barcode.log") || die "Can't open 'barcode.log': $!\n";

while (1) {

my $reply = HardwareReply($handle,100);
print LOG "> Rx: $reply\n";

close LOG;

sub HardwareReply {
my ($Port,$timeout) = @_;


    my $in;
    my $max = 500;
    my $count = 0;
    my $return;
    my $to_read;
    my $readcount;
    my $input;
    my $counter=0;

    $timeout ||= '100';

    do {
        select(undef,undef,undef, 0.1);
        $to_read = $max - $count;

        ($readcount, $input) = $Port->read($to_read);

if ( $in=~/[\n\r]$/ ) {

    } while ((!$return) && ($counter<$timeout));

return $return;

The Script opens the comport, but the sub HardwareReply doesnt work.
Have anyone an idea what the problem is?

Site Timeline