From owner-freebsd-questions Thu Jun 29 00:54:59 1995 Return-Path: questions-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id AAA15506 for questions-outgoing; Thu, 29 Jun 1995 00:54:59 -0700 Received: from genesis.atrad.adelaide.edu.au (genesis.atrad.adelaide.edu.au [129.127.96.120]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id AAA15500 for ; Thu, 29 Jun 1995 00:54:55 -0700 Received: from msmith@localhost by genesis.atrad.adelaide.edu.au (8.6.9/8.6.9) id RAA22262; Thu, 29 Jun 1995 17:14:56 +0930 From: Michael Smith Message-Id: <199506290744.RAA22262@genesis.atrad.adelaide.edu.au> Subject: Re: APC Backups 400 && ups daemon To: xxnguyen@utacnvx.uta.edu (Mr. TR Nguyen) Date: Thu, 29 Jun 1995 17:14:56 +0930 (CST) Cc: freebsd-questions@FreeBSD.ORG In-Reply-To: <199506290242.VAA22022@utacnvx.uta.edu> from "Mr. TR Nguyen" at Jun 28, 95 09:42:48 pm Content-Type: text Content-Length: 1297 Sender: questions-owner@FreeBSD.ORG Precedence: bulk Mr. TR Nguyen stands accused of saying: > 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) Urk. You're confusing pin 4 (CTS) with bit #4 in a serial data stream. > Anyone with examples/tips to share with this stumped-abuser? Yup; try this : int fd, status; fd = open("/dev/tty2",O_RDONLY); ... for(;;) { status = ioctl(fd, TIOCMGET, NULL); if (status & TIOCM_CTS) power_has_failed() sleep(60); } Haven't tested it, but it ought to work 8) Make sure you don't have a getty on the port at the same time. > TR Nguyen -- ]] Mike Smith, Software Engineer msmith@atrad.adelaide.edu.au [[ ]] Genesis Software genesis@atrad.adelaide.edu.au [[ ]] High-speed data acquisition and [[ ]] realtime instrument control (ph/fax) +61-8-267-3039 [[ ]] My car has "demand start" - Terry Lambert [[