On Thu, Dec 20, 2001 at 03:36:02PM -0500, Matthew Pollack wrote:
> I'm kind of new to POE, so please bear with me.  I have searched the
> archives of this mailing list, but have not yet come upon an answer to
> my question.  I am trying to create a recurring, timed event to poll a
> serial port for incoming data (using Device::SerialPort).  However, I
> haven't been able to come up with a method for creating the timing loop,
> e.g. I'd like to check for data every 200 milliseconds.  I tried using
> $_[KERNEL]->delay(...) but I cannot figure out how to make the evert
> reccur.


POE alarms don't automatically recur.  Instead, you should call
delay() again:

  sub poll_for_serial_data {
    my ($kernel, $heap) = @_[KERNEL, HEAP];

    # deal with the serial port here...

    # Make the alarm recur.
    $kernel->delay( poll_for_serial_data => 0.2 );
  }

You should have Time::HiRes installed if you want better accuracy with
times shorter than one second.

-- Rocco Caputo / [EMAIL PROTECTED] / poe.perl.org / poe.sourceforge.net

Reply via email to