From owner-freebsd-questions Wed Jun 28 21:21:14 1995 Return-Path: questions-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id VAA07269 for questions-outgoing; Wed, 28 Jun 1995 21:21:14 -0700 Received: from ess.harris.com (su15a.ess.harris.com [130.41.1.251]) by freefall.cdrom.com (8.6.10/8.6.6) with SMTP id VAB07257 for ; Wed, 28 Jun 1995 21:21:12 -0700 Received: from borg.ess.harris.com (suw2k.ess.harris.com) by ess.harris.com (5.x/SMI-SVR4) id AA00969; Thu, 29 Jun 1995 00:20:53 -0400 Received: by borg.ess.harris.com (4.1/SMI-4.1) id AA04415; Thu, 29 Jun 95 00:18:32 EDT Date: Thu, 29 Jun 95 00:18:32 EDT From: jleppek@suw2k.ess.harris.com (James Leppek) Message-Id: <9506290418.AA04415@borg.ess.harris.com> To: freebsd-questions@FreeBSD.ORG, xxnguyen@utacnvx.uta.edu Subject: Re: APC Backups 400 && ups daemon 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 also some of those UPS signals are open collector on the APC models I think pin 4 is common, pin 2 is line fail RS232 pin 3 is open collector line fail, pin 5 low battery open collector as with any "wiring" activity proceed at your own risk :-) Jim > From owner-freebsd-questions@freefall.cdrom.com Wed Jun 28 23:40:47 1995 > From: "Mr. TR Nguyen" > Subject: APC Backups 400 && ups daemon > To: freebsd-questions@FreeBSD.ORG (freebsd-questions) > Date: Wed, 28 Jun 95 21:42:48 CDT > X-Mailer: ELM [version 2.3 PL11] > Sender: questions-owner@FreeBSD.ORG > > > I think hackers would be a more appropriate forum, but it's kind > of swamped for the time being. Anyways, I have an A.P.C. Back-UPS 400 > with a serial connection to my FreeBSD 2.0.5R's comm port 3. > > I've unsuccessfully tried to write a simple program to read a single > byte from this port (/dev/tty02) and check whether or not the "POWER-FAIL" > bit has been raised (pin #4, according to the Owner's Manual) > > Here's what the simplistic logic looks like: > open() "/dev/tty2" # comm 3 > LOOP FOREVER: > read() a single byte > check to see if bit #4 has been set > ..... > END LOOP > > > Anyone with examples/tips to share with this stumped-abuser? > > Thankx so much, > TR Nguyen > >