Watching a modem.

[email protected] ("Stuart Grimshaw")
Newsgroups perl.loop
Message-ID <[email protected]>
I'm trying to create an event to wait for a modem to ring.

I'm using the Device::SerialPort from CPAN.

I can detect a ring with the following :

use Device::SerialPort qw(:STAT);
use Event qw(loop unloop);

$Port = new Device::SerialPort("/dev/ttyS0", 0) or die "Can't create port
object";

# Set up modem.
...
blah
blah
blah
...

while (1) {
    print "RING Detected\n" if ($Port->modemlines &
            $Port->MS_RING_ON);
}

All it does obviously is enter an infinate loop and print when it detects a
ring.

How can I use Event->var to watch for a change in $Port->modemlines?

I've tried this, and it doesn't work :

Event->var(
    var=>\$Port->modemlines ,
    cb=>\&checkring,
    poll=>'rw');

loop();

undef $Port;

sub checkring {
 if($Port->modemlines & $Port->MS_RING_ON) {
  print "Ring Detected\n";
  unloop();
 }
}

---------------------------------------
 Stuart Grimshaw         |
 Schoolsnet LTD          |   Special
 www.schoolsnet.com      |   Projects
                         |   Developer
 [email protected] |
---------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.