*BSD News Article 14079


Return to BSD News archive

Newsgroups: comp.os.386bsd.development
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!haven.umd.edu!uunet!psgrain!m2xenix!agora!rgrimes
From: rgrimes@agora.rain.com (Rodney Grimes)
Subject: Re: Powerfail / UPS implementation
Message-ID: <C51q9w.Fqo@agora.rain.com>
Keywords: ups powerfail device driver init
Organization: Open Communications Forum
References: <2107@hcshh.hcs.de>
Date: Tue, 6 Apr 1993 05:08:19 GMT
Lines: 69

hm@hcshh.hcs.de (Hellmuth Michaelis) writes:

>One of the machines nearby has a uninterruptable power supply built in and
>i would like to have it activated.

>So what is the best (most generic) way of implementing it into 386BSD ?

>What i have in mind is:

>	- a device driver capable of reporting the status of the power
>		supply (running from AC / running from DC). Should the
>		query be implemented as a read() returning a char or
>		as a ioctl() ?

Depends on the UPS, many UPS (I know TripLite is this way) use a serial
port to send status, you can query the UPS with certail commands, I think
you can even have it power down the system.  In this case no device driver
is really needed, just open /dev/ttyxx (ohh, for you DOS people /dev/comxx).

Also some one has a major cdev entry reserved for something called the
xten power controller, don't have a clue as to what that is.  Could this
person please contact me.

>	- a daemon starting at /etc/rc.local and running in the background
>		asking every minute or so for the power supply status by
>		using the device driver above.

Better to be interrupt driven, in the serial case you could sleep until
a character arrived, as I the device should send a message when power
failure has occurecd.  I don't like the idea of polls, especailly at
once a miniute.  Some UPS only give you 5 minitus of standby and you
would be wasting 1/5 of the availiable time with 1 min. polls.

>	- on AC power failure the daemon sends SIGPWR to init, causing it
>		to go to single user mode (powerfail mode ?).

Humm, maybe invoke shutdown with the number of minutes - 1 of time that
the UPS can hold the sysem up.  Then cancel the shutdown if AC comes back...

>	- now init has to monitor the power supply, if the AC power comes
>		back again. if AC comes back again, init takes the system
>		back to multiuser mode, else the batteries get empty, then
>		after AC power comes back, init reboots as usual.

It would be better if the a halt occured before AC went away, thus the disks
would be synced..

>The only hardware dependent part would be the device driver, but since the
>output is binary (power good/bad) the driver should be simple to adapt to
>common ups-monitoring devices.

Some devices also work by justing raising and lowering DSR or one of the
other RS-232 signals, again, no specail driver, just use ioctls in the
standard com port.  Almost all of the UPS for PC systems work in this
way.

>Since the only (PC-based) ups-device i have ever seen is mine (built in),
>is the above draft sufficient as a general purpose solution ?

>Does another solution already exist for 386BSD ?

>Any comments ?

>hellmuth
-- 
Rod Grimes						rgrimes@agora.rain.com
Accurate Automation Company          All opinions belong to me and my company!
Get your free copy of  386bsd  from  agate.berkeley.edu:/pub/386BSD  via  ftp!
An out of work contractor... You need unix work done.... Send me your project!