From owner-freebsd-questions Thu Jun 29 05:27:14 1995 Return-Path: questions-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id FAA22602 for questions-outgoing; Thu, 29 Jun 1995 05:27:14 -0700 Received: from squid.umd.edu (squid.umd.edu [129.2.40.6]) by freefall.cdrom.com (8.6.10/8.6.6) with SMTP id FAA22596 for ; Thu, 29 Jun 1995 05:27:11 -0700 Received: by squid.umd.edu (5.65/Ultrix3.0-C) id AA12850; Thu, 29 Jun 1995 08:36:14 -0400 From: fcawth@squid.umd.edu (Fred Cawthorne) Message-Id: <9506291236.AA12850@squid.umd.edu> Subject: Re: APC Backups 400 && ups daemon To: jleppek@suw2k.ess.harris.com (James Leppek) Date: Thu, 29 Jun 95 8:36:13 EDT Cc: freebsd-questions@FreeBSD.org, xxnguyen@utacnvx.uta.edu In-Reply-To: <9506290418.AA04415@borg.ess.harris.com>; from "James Leppek" at Jun 29, 95 12:18 am X-Mailer: ELM [version 2.3 PL11] Sender: questions-owner@FreeBSD.org Precedence: bulk > > > 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.