Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Jun 95 00:18:32 EDT
From:      jleppek@suw2k.ess.harris.com (James Leppek)
To:        freebsd-questions@FreeBSD.ORG, xxnguyen@utacnvx.uta.edu
Subject:   Re: APC Backups 400 && ups daemon
Message-ID:  <9506290418.AA04415@borg.ess.harris.com>

next 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

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" <xxnguyen@utacnvx.uta.edu>
> 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
> 
> 



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