Working off serial port
Michael Fowler
michael at shoebox.net
Wed Jan 12 17:52:15 CST 2000
On Wed, Jan 12, 2000 at 01:58:36PM -0900, Kevin Creason wrote:
> Because of crank calls to Emergency, we want to log PBX activity. I've got
> a unix machine nearby... heh heh. So I thinks, what better way to capture
> and parse the data from it's gobblety gook than to use Perl?
This may not be as well-suited to Perl as you would initially think. The
gobblety-gook, I assume, is a stream of bits, and while Perl can handle
streams of bits (with pack and unpack), it can get a little awkward. You
may want to consider C or C++. Considering the fact that you're dealing
with a serial device (which will probably involve ioctl() invocations), Perl
may be even less well-suited. While Perl does have ioctl(), many ioctl()
calls involve C data structures, which can be a little messy to deal with.
> Two big problems:
> 1. It's got to run all the time, even when no-one is logged in
Easy enough, just have it fork itself then have the parent exit. There is a
set procedure for this, involving a pair of forks and a setsid() call to
truly daemonize, but this should be sufficient to allow it to run
indefinately.
> 2. How do you get info off the hardware in Perl?
Usually the same way you'd do it in C. Opening the serial device
(/dev/ttyS[0-1] on Linux, I don't know about HP-UX. Perl also has ioctl().
If worst comes to worst, you can write a module for Perl in C.
> The actual OS is HPUX, not linux. :(
>
> AND that's another issue: how do you configure the port to be the right
> config? (1200/7/E/1) I'm not sure how to do that under linux, either.
In Linux, setserial is used for this I believe. I have no idea how to do it
with HP-UX, possibly through ioctl()'s. A good way of figuring it out is to
find a program that talks to a modem (such as minicom), and looking at the
source.
Michael
--
There isn't a mome rath alive that can outgrabe me.
--
=================================================
Mailing list info: If at any time you wish to (un|re)subscribe to
the list send the request to majordomo at hfb.pm.org. All requests
should be in the body, and look like such
subscribe anchorage-pm-list
unsubscribe anchorage-pm-list
More information about the Anchorage-pm
mailing list