develooper Front page | perl.beginners | Postings from March 2002

Re: perl serial port program

Thread Previous
Papo Napolitano
March 1, 2002 15:36
Re: perl serial port program
Message ID:
You should change the line

    die "Device::SerialPort Aborted without match\n" unless (defined $data);

to read

    die "Device::SerialPort Aborted without match\n" unless (defined

But be careful because the 'lookfor' method causes Device::SerialPort to
return an entire line (up to the first \n or \r)...
If you intend to read -only- one char, you should check Device::SerialPort
docs... There's plenty of examples =)


----- Original Message -----
From: Jeff Liu
To: Papo Napolitano ; Beginners
Sent: Friday, March 01, 2002 17:17
Subject: RE: perl serial port program

Hi Papo,

Thank you very much for your information. I can send to serial port from my
script now. But when I try to read from the port, my script died and showed
"Device::SerialPort Aborted without match". Do you have any idea about how
can I fix the problem? My script is as followed.


use Device::SerialPort;

$port = new Device::SerialPort("/dev/ttyS0");

while (1)
  $port->write("Feed Me:");

  while ($bytein eq "")
    $bytein = $port->lookfor;
    die "Device::SerialPort Aborted without match\n" unless (defined $data);
    sleep 1;
  print "$bytein\n";


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About