From: mathog@seqaxp.bio.caltech.edu
Sent: Wednesday, November 10, 1999 7:54 PM
To: Info-VAX@Mvb.Saic.Com
Subject: TCONTROL, UPS monitor, terminal bit control

Following my signature is the AAAREADME.TXT file from:

  http://seqaxp.bio.caltech.edu/pub/software/TCONTROL.ZIP

TCONTROL monitors/sets pins on a serial port.  Included is UPS_MONITOR.COM,
which monitors a UPS through TCONTROL and shuts down the system gracefully
following a power failure.  I have tested this with a DS10 and a Tripplite
Omnismart 850 but it should work with many other UPS's (once you know which
bits to set and watch.)  

Many thanks to everyone who pointed me at the various example code and 
special thanks to Frank da Cruz who provided several key bits of knowledge.
(One of which is that set term/modem leads to DTR cycling continuously
between up for 30 seconds and down for 5 - don't ask me why it does that!)

No guarantees, warranties, or even commitments to fix bugs, but this is 
freeware, so have at it.

Regards,

David Mathog
mathog@seqaxp.bio.caltech.edu
Manager, sequence analysis facility, biology division, Caltech 

**************************************************************************


This directory contains the following files:

  TCONTROL.EXE  Alpha executable for tcontrol, a command line program
                which can be used to control a terminal line attached to
                a UPS
  TCONTROL.C    source code for tcontrol, 
  UPS_INFO.TXT  Information on Tripplite UPS lan 2.1 and lan 2.2 control
                signals.  Others may be added at future time.
  UPS_MONITOR.COM  A procedure designed to be run detached which uses
                TCONTROL to monitor a UPS attached to a terminal line.  
                It will shut down the system after N minutes if a powerfail is
                detected.  If the power comes back before then, the shutdown is canceled.
                Edit it to fit your system.  Start it up like:
                $ run sys$system:loginout -
                   /detach /uic=[SYSTEM] -
                   /input= sys$manager:ups_monitor.com -
                   /output= sys$manager:powerfail_shutdown.log -
                   /priority=6 -
                   /process_name="UPS_MONITOR"


TCONTROL usage:

First configure the terminal with:

$ set term/perm/nobroadcast/nomodem tta0:

Then to use TCONTROL

$ tcontrol :== $disk:[dir]tcontrol
$ tcontrol device bitset waithigh waitlow maxwait
   device:   tta0: or other serial device (not LAT)
   bitset:   bits to set high from {DTR,RTS,SecTX}, others go low
   waithigh: wait until these bits go high, from {CTS,DSR,CARRIER,RING}
   waitlow:  wait until these bits go low, from {CTS,DSR,CARRIER,RING}
      if more than one in a list separate with spaces
   maxwait   wait this many seconds before timing out

   The symbol TCONTROL_HIGH is set on exit, contains the names of the high bits
   or TIMED_OUT 

TCONTROL always sets all three of these {DTR,RTS,SecTX}.  For use with 
Tripplite Omnismart UPS's you want to set DTR high, RTS low, and SecTX 
doesn't matter (no pin.)   If RTS goes high it sends the UPS a signal to 
shut down the inverter which will be ignored if line power is present but
accepted if the UPS is running on batteries.  WATCH OUT FOR THIS!  It may
not be possible to boot a DS10 and many other systems attached to one of
these UPS boxes if it is running on batteries.  During boot the serial bit
values jump all over the place (determined by watching them with an
external modem) and if RTS ever goes high it instantly kills the UPS and
the DS10 along with it.  Don't write any data bytes through the terminal
as TxD must stay low and the only way to accomplish that is to not use
the data line. 

Use at your own risk, caveat emptor, we assume no responsibility, etc.

10-NOV-1999
David Mathog
Manager, sequence analysis facility, biology division, Caltech 
mathog@caltech.edu