Front page | perl.beginners |
Postings from July 2003
signals and reading from serial port
Thread Next
From:
Kristian Rink
Date:
July 15, 2003 03:58
Subject:
signals and reading from serial port
Message ID:
20030715125707.6af50cbd.afterimage@gmx.net
hello all,...
...being writing a small script which is supposed to read data from
a telephone system connected to the serial port of my linux box.
basically, all the script does by now is to detach from the terminal
and lurk in the background, reading from a pipe filled by cat:
open(INPUT, "cat /dev/ttyS0 |")||die "cannot cat port...";
.
.
.
while (<INPUT>)
{
print OUTPUT $_;
filter_input($_,$parsetable,$keytable,$dataset);
}
.
.
.
basically, it works more or less fine. I set up some signal handlers
to catch SIGHUP and SIGTERM enabling me to reset or cleanly stop the
process. unfortunately, while running through this loop, the script
seems to be stuck for all eternity waiting to read input from
<INPUT> if nothing happens, there... basically, i would like to have
something like this
while( (<INPUT>) && (!$caughtterm) && (!$caughthup))
{
print OUTPUT $_;
filter_input($_,$parsetable,$keytable,$dataset);
}
($caughtterm and $caughthup are set by the handlers for SIGTERM /
SIGHUP) to make the process interruptable / resetable even while
waiting for input. anyhow, this does not work, for obvious reasons
(nothing happens until any input is recieved). I was even for a
short time thinking about polling the serial port in a loop similar
to the one above but this probably also might end up in the script
hanging and waiting for input until eternity ends...
can anyone give me a hint how to make this serial input
interruptable? hints on documentation to be read for this also are
greatly appreciated,
tia, have a nice week everyone.
cheers,
kris
--
these outrageous events
break through the peaceful silence...
into a fragile community
enters madness, insanity.
Thread Next
-
signals and reading from serial port
by Kristian Rink