Click here to get back home

lookfor failure in SerialPort

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
lookfor failure in SerialPort Spin 11-30-2005
Posted by Spin on November 30, 2005, 4:56 pm
Please log in for more thread options


I 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 <ENQ>
        waitfor(chr(06)) or die;        # wait for <ACK>
        ...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, <UPLOAD> line 2.
(in cleanup) Can't call method "Call" on an undefined value at
C:/Perl/site/lib/Win32API/CommPort.pm line 211, <UPLOAD> line 2 during
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


Posted by Spin on December 2, 2005, 8:18 am
Please log in for more thread options


Spin wrote:
>
> Troubleshooting help or any advice greatfully received.

Actually, the most effective way to use lookfor in conjunction with a
serial connection is to make sure that the machine at the far end of the
cable is turned on. There are, indeed, some disadvantages to
telecommuting...

Spin


Similar ThreadsPosted
Need help with Win32::SerialPort August 13, 2004, 5:43 am
need help with "SerialPort" module April 25, 2006, 11:34 pm
help on win32::serialport June 4, 2007, 5:12 pm
SerialPort error July 7, 2007, 10:58 pm
Please help on win32::serialport July 13, 2007, 12:41 pm
SerialPort write question October 28, 2004, 11:52 am
Serialport Read question October 28, 2004, 11:59 am
Loopback with Device::SerialPort? March 18, 2005, 1:24 pm
problem with Device::SerialPort November 30, 2005, 4:19 pm
problem in using win32::SerialPort September 7, 2007, 2:27 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap