Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Jun 95 8:36:13 EDT
From:      fcawth@squid.umd.edu (Fred Cawthorne)
To:        jleppek@suw2k.ess.harris.com (James Leppek)
Cc:        freebsd-questions@FreeBSD.org, xxnguyen@utacnvx.uta.edu
Subject:   Re: APC Backups 400 && ups daemon
Message-ID:  <9506291236.AA12850@squid.umd.edu>
In-Reply-To: <9506290418.AA04415@borg.ess.harris.com>; from "James Leppek" at Jun 29, 95 12:18 am

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> 
> If you wire the status line to the DSR (RS232 pin 6) then this should
> work:
> fd=open("device_name", O_RDONLY,0);
> 
> get status with
> int tty_status;
> ioctl(fd, TIOCMGET, &tty_status);
> 
> check it with
> if(tty_status & TIOCM_DSR)
> bla bla bla
> 
> loop as you see fit, but I would put a sleep(1) in there somewhere
>
This should indeed work...
Another thing that should be added is a kernel option to clear the RTS
line on a serial port when a reboot is completed.  These UPS's have 
a pin that lets you shut them down from the computer.  This is necessary
in case the power comes back on for only a short period of time.  If you
just let the battery run out, you won't have enough juice left to go
through a boot/shutdown cycle.  I modified a kernel a while ago to
do this, but it was a dirty hack.  (i.e. an outb and a sleep or
something like that)

  How about OPTIONS "RTS_REBOOT=0xwhatever" where the whatever is the
address of the port or something like that ???
I have an APC Back-UPS 450. (But the interface to the 400,450,and 600
is the same)  I have pin 1 on the UPS going to RTS, pin 2 going to DSR,
and pin 4 going to ground.  (In case anyone cares...)  

  What I do is start a reboot cycle, so that if the power comes back on, 
the system will just restart. (The UPS ignores the "turn-off" signal if
the power is on)  When the system is all the way down. (i.e. before the
"Rebooting..." printf) you just toggle RTS or some other serial port
output.  I guess toggling it would be more useful, because you could use
it for a UPS that requires the reverse sense of the reboot signal.
  The UPS monitoring daemon just checks to see if the power has
been off for more than 4 minutes, (while broadcasting warning
messages) and initiates a reboot cycle.  It sets RTS when it starts up 
as well.  (The UPS needs a high signal for .5 seconds for it to shut
off, and a set modem line gives you a low signal on the pin...)

  Anyway, this is a very easy thing to add to the kernel, and it is also
very easy to write a power failure monitoring daemon.  It would be nice
if at least the kernel thing was in the standard distribution.  Any
ideas??  I'll put it in and test it if there's some consensus on how
it should be configured.


Fred.

 

Fred.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9506291236.AA12850>