Re: Serial Ports and Perl
Hi Martin,
On Thu, Oct 26, 2017 at 07:37:07PM -0500, Martin McCormick wrote:
> If anybody has gotten the perl Device::SerialPort to
> work, I am interested to know what I am doing or not doing.
I have been using it successfully for a long time, but all I do is
read whole lines from the serial device like:
my $dev = '/dev/ttyUSB0';
my $port = Device::SerialPort->new($dev);
$port->baudrate(57600);
$port->write_settings;
open my $fh, '<', $dev or die "Can't open $dev: $!";
while (<$fh>) {
print "READ: $_\n";
}
So, I am only using Device::SerialPort to configure the device,
while all reading is done by treating it as a normal file.
I see you are using lookfor(), which I have never used before. From
a brief look at:
http://search.cpan.org/~cook/Device-SerialPort-1.002/SerialPort.pm#Methods_for_I/O_Processing
it seems you should be setting are_match() if you want lookfor() to
match anything.
Cheers,
Andy
--
https://bitfolk.com/ -- No-nonsense VPS hosting
Reply to: