lookfor failure in SerialPort
am 30.11.2005 23:56:09 von SPINI am using Win32::SerialPort 0.19 and am having trouble getting the
lookfor to work. My understanding is that lookfor(1) should sit and wait
to read one character coming inbound on my serial port.
This is the sub that wraps the lookfor:
sub waitfor {
my $debug = 'y';
$ob->lookclear; # clear buffers
my $gotit = "";
my $response = shift;
$ob->are_match($response);
print "DEBUG: Waiting for \"$response\".\n" if $debug;
for (;;) {
return unless (defined ($gotit = $ob->lookfor(1)));
if ($gotit ne "") {
my ($match, $after, $pattern) = $ob->lastlook;
print "DEBUG: Got .\"$gotit$match$after\".\n" if $debug;
return $match;
}
return if ($ob->reset_error);
}
}
This is some of the context in which it is called:
while ($in) {
$loc = $ob->read(1);
if ($loc) {
# do stuff
} else {
$ob->write(chr(05)); # send
waitfor(chr(06)) or die; # wait for
...send next piece etc
}
}
This is the output I get from the sub and the die:
DEBUG: Waiting for "?".
Died at C:\horiba_pentra60Cplus.pl line 259,
(in cleanup) Can't call method "Call" on an undefined value at
C:/Perl/site/lib/Win32API/CommPort.pm line 211,
global destruction.
Outbound and inbound communications are working otherwise. I am using
Portmon and it indicates that the chr(05) goes out successfully, there
is one read on the port which returns with length of 0 and then the port
closes.
Troubleshooting help or any advice greatfully received.
Regards,
Spin