Subject: Re: UPS unattended shutdown
To: Dan J Fraser <dfraser@mother.com>
From: Bill Studenmund <skippy@macro.stanford.edu>
List: tech-userlevel
Date: 03/15/1997 20:06:37
On Fri, 14 Mar 1997, Dan J Fraser wrote:
> On Fri, 14 Mar 1997, Jason Thorpe wrote:
> > [ CC'd tech-userlevel, since this is probably a totally userland thing. ]
> > On Fri, 14 Mar 1997 16:27:43 -0500 (EST)
> > Dan J Fraser <dfraser@mother.com> wrote:
> > > I'd like to set up NetBSD to automatically shut down my UPS during a power
> > > failure... monitoring the UPS is not a problem, but I need to send an
> > > ioctl to the serial port to tell the UPS to shut off power to the computer
> > > after NetBSD has shut down completely.
> >
> > Hmm, do you _need_ to perform an ioctl? What is the command you send
> > to the UPS? Can't you just write a message out the tty? (I assume
> > you're reading messages on the tty from the UPS..)
>
> The UPS (APC Back-UPS 400) requires a high RS-232 level signal to one of
> it's pins in order to shut down the power.
>
> The UPS puts out high RS-232 level signal to indicate a power
> failure... so it could be monitored by watching the CD line of the comport
> or somesuch. You'd do something like raise DTR to tell it to shut down.
> The UPS will only shut off power during an actual power failure, so
> accidental shutdowns aren't really a problem.
You don't need a new ioctl. As (I think) Mike Long suggested, an lkm which
added a shutdown hook will do.
There already is an ioctl to let you twiddle one of the modem control
lines. It's TIOCMSET (to SET the Modem bits). I believe the com driver is
one of the drivers which supports this ioctl.
man 4 tty for more details.
Take care,
Bill