Subject: Re: Detecting a closed circuit
To: James K. Lowden <jklowden@schemamania.org>
From: Andrew Brown <atatat@atatdot.net>
List: netbsd-help
Date: 12/06/2002 11:17:42
>> >The UPS in our machine room provides a pair of wires which are an open 
>> >circuit when on line power and a closed circuit when on battery power. 
>> >I'd like to detect this on a NetBSD/i386 box so sysadmins can be
>> >notified via pager when we go onto UPS.  I'd prefer if it could be
>> >detected on two different boxes for failover, but one box would work.
>> 
>> off the top of my head (upon which i am not wearing any sort of
>> electrical engineering hat), i'd say that the closed circuit could be
>> used to drive a relay that would connect the...uh...ctr line to the
>> dcd line on a serial port.  or something like that.
>
>I can't tell a relay from an oscilloscope, which might be why I don't
>think you need one.  

i just figured the use of a relay would serve to isolate whatever
voltage was passing over the "closed circuit connected to the ups"
from the computer.  it would suck if, when you went onto battery
power, your computer exploded from the power going over the newly
closed circuit.

>"man termios" says when you open a terminal file the process normally
>blocks "until a connection is established ... [as] indicated by the
>assertion of the hardware CARRIER DETECT (CD) line".  

>So, suppose your circuit-that-closes-on-batter-power tied CD to something
>already high, say, DTR.  Order of events becomes:
>
>Wire everything up.
>Start program that opens the terminal device.
>Program blocks, awaiting "connection".
>Wait for blackout.
>[time passes...]
>Blackout.
>Circuit closes, raising CD.
>Program unblocks, calls in the National Guard, whatever.

exactly.

>I think this would work for two machines.  In terms of RS-232, assuming
>these machines are within 100 feet of each other, I don't see any reason
>you couldn't tie their DTRs together and their CDs together, and bridge
>them both with the same close-on-battery curcuit.  

or set up the relay so the two individual dtr lines were bridged to
the two individual dcd lines when the ups circuit closed.

>It looks easy from here, but I never did any such thing.  And, see, no
>relay. :)

i still think you should use the relay.  they're cheap, though.

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
werdna@squooshy.com       * "information is power -- share the wealth."