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

Re: perl serial port program

Thread Previous | Thread Next
From:
Papo Napolitano
Date:
February 28, 2002 14:51
Subject:
Re: perl serial port program
Message ID:
063d01c1c0aa$6a475e80$fe00000a@exodo
I'm using the Device::SerialPort to monitor the logs from our Panasonic
phone system ;)
Take a look at CPAN.

It's as easy as:

use Device::SerialPort;
$port = new Device::SerialPort("/dev/ttyS0");
$port->baudrate(9600);
$port->parity("none");
$port->databits(8);
$port->stopbits(1);
$port->handshake("rts");
$port->write_settings;
while (1) {
  $data = "";
  while (($data = $port->lookfor) eq "") {
    die "Device::SerialPort Aborted without match\n" unless (defined $data);
    select undef, undef, undef, 0.25; # Prevent the program to takeover the
CPU ;)
  }
}

There, in $data you have a line up to the first \n.

HTH.-


----- Original Message -----
From: Jeff Liu
To: Beginners
Sent: Thursday, February 28, 2002 19:00
Subject: perl serial port program



Hi there,

I need to cook a perl script talking to /dev/ttyS0, it will be used to
monitor a RAID device via serial port. But even spending the whole day I was
still not lucky enough to be successful. Could you please show me a way to
deal with it?

Many thanks,
Jeff Liu


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About