NOTICE ***** begin ***** NOTICE ***** AMH 7/5/98

Docs are closer to Date...........

This version requires that /sbin/powersc file be updated.
It is suggested that you update your /etc/apcupsd.conf file
for the new stuff.

NOTICE ****** end ****** NOTICE

/***************************************************************************/
/*                     README.cables for apcupsd                           */
/*      BY:  "Andre M. Hedrick" <hedrick@astro.dyer.vanderbilt.edu>        */
/***************************************************************************/

----> apcupsd v3.4.4

Hewlett Packard partno. 5061-2575 for HP PowerTrust 2997A UPS.
Treat as a CUSTOM-SMART and SmartUPS.

----> apcupsd v3.0.0

Support for 940-0095A and 940-0095C cables.
These are dual purpose cables for both smart and simple signals.

----> apcupsd v2.9

 CUSTOM-SMART Cable

 Firstly, the cable:
 You will need a simple 3 wires cable connected as follows:

 PC (9 pin)     APC
  2 RxD          2
  3 TxD          1
  5 GND          9

----> apcupsd v2.8 Sept 15, 1997

Date: Sun, 14 Sep 1997 01:12:02 -0700
From: "Daniel M. Crowl" <dancrowl@artcommerce.com>
To: hedrick@astro.dyer.vanderbilt.edu
Subject: APC cable question..

        I admit that after reading your README's and the stuff at APC I am
thoroughly confused about which cable to buy/make -- I have an APC
Smart-UPS 600 running a 586 RH 4.1 Linux box. I don't see a listing for
#940-024(B/C) at the APC site -- just 940-020,  with no character
designators (B/C/anythingElse...)

I guess my question is:  To incorporate SmartUPS "Smart Mode" support do
I buy a #940-020B, -024(B/C) or make the cable illustrated in your Sept
20, 1996 comment?

SMART MODE CABLES: #940-0024B and #940-0024C
UPS SUPPORT: SmartUPS SU and BackUPS Pro

DUMB MODE CABLES: #940-0020B and CUSTOM Design Below.
UPS SUPPORT: SmartUPS SU and BackUPS

STUPID MODE CABLE: #940-0023A
UPS SUPPORT: BackUPS

UKNOWN MODE CABLES: #940-0095A and #940-0095C
UPS SUPPORT: ???????????????

----> apcupsd v2.5pre?

From cph@martigny.ai.mit.edu Tue May 27 14:43:53 1997
Date: Tue, 27 May 1997 00:28:55 -0400 (EDT)
From: Chris Hanson <cph@martigny.ai.mit.edu>
To: hedrick@astro.dyer.vanderbilt.edu
Subject: APC #940-0095A cable

Hi,

I have been messing around trying to get my APC Back-UPS Pro PNP to
work under Linux.  In the process of trying to figure out how the
included cable is built (#940-0095A), I fried the cable.  I took this
as an opportunity to dissect the cable and find out what is really
inside.  After a lot of work with an X-acto knife, I figured it out.

Since you're maintaining apcupsd, and you state that this cable is
"insupportable", I thought you might be interested in this
information.  Perhaps it will help you to support the cable, and thus
help other people with this UPS.

----------------------------------------------------------------------
Construction and operation of the APC #940-0095A cable.
This cable is included with the APC Back-UPS Pro PNP series.


UPS end                                      Computer end
-------                                      ------------
                    47k        47k
BATTERY-LOW (5) >----R1----*----R2----*----< DTR,DSR,CTS (4,6,8)
                           |          |
                           |          |
                           |         /  E
                           |       |/
                           |    B  |
                           *-------|  2N3906 PNP
                                   |
                                   |\
                                     \  C
                                      |
                                      |
                                      *----< DCD (1)
                                      |
                                      |
                                      R 4.7k
                                      3
                                      |
                               4.7k   |
SHUTDOWN (1)    >----------*----R4----*----< TxD (3)
                           |
                           |  1N4148
                           *----K|---------< RTS (7)

POWER-FAIL (2)  >--------------------------< RxD,RI (2,9)

GROUND (4,9)    >--------------------------< GND (5)


Operation:

* DTR is "cable power" and must be held at SPACE.  DSR or CTS may be
  used as a loopback input to determine if the cable is plugged in.

* DCD is the "battery low" signal to the computer.  A SPACE on this
  line means the battery is low.  This is signalled by BATTERY-LOW
  being pulled down (it is probably open circuit normally).

  Normally, the transistor is turned off, and DCD is held at the MARK
  voltage by TxD.  When BATTERY-LOW is pulled down, the voltage
  divider R2/R1 biases the transistor so that it is turned on, causing
  DCD to be pulled up to the SPACE voltage.

* TxD must be held at MARK; this is the default state when no data is
  being transmitted.  This sets the default bias for both DCD and
  SHUTDOWN.  If this line is an open circuit, then when BATTERY-LOW is
  signalled, SHUTDOWN will be automatically signalled; this would be
  true if the cable were plugged in to the UPS and not the computer,
  or if the computer were turned off.

* RTS is the "shutdown" signal from the computer.  A SPACE on this
  line tells the UPS to shut down.

* RxD and RI are both the "power-fail" signals to the computer.  A
  MARK on this line means the power has failed.

* SPACE is a positive voltage, typically +12V.  MARK is a negative
  voltage, typically -12V.  The RS-232 hardware translates SPACE to a
  0 and MARK to a 1.

----> apcupsd v2.5pre?

 * APC940-0095A non-infinite resistance values:
 *
 * CPU             UPS
 * DCD (1)         Pin 1 -- 4 kohms, Pin 5 -- 50 kohms
 * RX (2)          Pin 2 -- 0 kohms
 * TX (3)          Pin 1 -- 0 kohms, Pin 5 -- 50 kohms
 * DTR (4)         Pin 5 -- 50 kohms
 * Gnd (5)         Pin 4 -- 0 kohms, Pin 9 -- 50 kohms
 * DSR (6)         Pin 5 -- 50 kohms
 * RTS (7)         Pin 1 -- 4 kohms, pin 5 -- 110 kohms
 * CS (8)          Pin 5 -- 50 kohms
 * RI (9)          Pin 2 -- 0 kohms
 *
 * NOTE: line-fail signal is on the RD line at the CPU end of the cable

----> apcupsd v2.4 May 19 1997

BackUPS Pro BETA TEST ONLY use #940-0024(B/C) cables.

Karsten Wiborg <4wiborg@informatik.uni-hamburg.de>
Christopher J. Reimer <reimer@doe.carleton.ca>

----> apcupsd v2.1 May  6 1997

#940-0024(B/C) is smart mode signaling only.
BackUPS Pro must use smart mode signaling to use #940-0024(B/C) cables.

----> apcupsd v2.0 May  4 1997

#940-0024B Now Supported
#940-0024C Now Supported

There is NOW SmartUPS "Smart Mode" support!!!!!!!!!

BackUPS Pro "Smart Mode" support unknown???????????

USE_SMART=(yes/no) depending on UPS type.

BackUPS Pro "Smart Mode" may be able to use USE_SMART=yes

----> Enhanced_APC_UPS v1.9 Apr 14 1997

----> Enhanced_APC_UPS v1.8 Apr  7 1997

-D_SMARTUPS can no longer be define if you select USE_APC=yes
There is no SmartUPS "Smart Mode" support, it has never been available.
I am waiting to hear from APC about pinouts for the following cables
#940-0023A their Unix OS cable and
#940-0095A their Win95OS cable.
If you want to use and APC cable, you must have cable #940-0020B ONLY....

----> Sept 20 1996:


One may choose to use the include files ( inittab, rc.6, and rc.inet2 )

You may use this cable with both the Back-UPS and Smart-UPS from APC.
YES, I did state the above line, but you must set in the CONFIG file

Both cables for the Back-UPS from APC only have been tested and are
in use on three different Linux-Boxes.

   Cable for a smarter Back-UPS from APC only.
 
   Computer Side   |  Description of Cable           |  UPS Side
   DB9f  |  DB25f  |                                 |    DB9m
    4    |   20    |  DTR (5vcc)             *below  |    n/c
    8    |    5    |  CTS (low-batt)         *below  |     5
    2    |    3    |  RxD (other line-fail)  *below  |     3
    5    |    7    |  Ground (Signal)                |     4
    1    |    8    |  CD (line-fail from ups)        |     2
    7    |    4    |  RTS (shutdown ups)             |     1
   n/c   |    1    |  Frame/Case Gnd (optional)      |     9

*BELOW*

List if componets one needs to make this CABLE:

1) One (1) male DB9 connector.
2) One (1) female DB25 or DB9 connector.
   solder type not crimp DB connectors with standard hoods.
3) two (2) 4.7K ohm 1/4 watt %5 resistors.
4) one (1) foot of 3/32" (inch).
5) shrink wrap/boot.
6) rosin core solder.
7) three (3) to five (5) feet of 22AWG multi-stranded five (5) conductor cable.


First solder both of the resistors into pin# (4) DB9 or (20) DB25 the DTR.
This will be used as the Vcc pull-up voltage for testing the outputs on
you "BackUPS by APC" !!!! ONLY !!!!, all others at your own RISK!!!!!!

Next bend each of the resistors so that one connects to (8) DB9 or (5) DB25
the CTS (aka battery low signal) and the other to (2) DB9 or (3) DB25 the
RxD (aka another line fail signal).  This line is not currently used, but
it will be in the near future.

   Note: 8/5 is also wire to pin# 5 on the UPS side of the cable.
   Note: 2/3 is also wire to pin# 3 on the UPS side of the cable.

   note: we use the DTR as our +5 volts power for the circuit.

The rest of the wire connections are listed above.

I use this cable and daemon on my server that controls an APC BackUPS-600VA
that has one Cisco 1005 ISDN/Enet router, one 24-port HP-Enet Hub, and one
server (AMD-5x86-P75) w/o monitor.  Enjoy the power security of UPS control.

-----------------------------

-- snip /etc/rc.d/rc.6 |
        /etc/rc.d/init.d/halt |
        /sbin/init.d/halt ------

  # See if this is a powerfail situation.
  if [ -f /etc/powerfail ]; then
    echo "APCUPSD to the Resque!"
    echo
    /sbin/powersc KILL
    sleep 120
    exit 1
  fi

-----------------------------

-- snip /etc/rc.d/rc.local |
        /etc/rc.d/init.d/apcups |
        /sbin/init.d/apcups --

#
if [ -x /sbin/powersc ]; then
  /sbin/powersc INIT
fi
#

/***************************************************************************/

/***************************************************************************/
/*                README.BackUPS-Pro Users of apcupsd                      */
/*        BY:  "Christopher J. Reimer" <reimer@doe.carleton.ca>            */
/*          "Andre M. Hedrick" <hedrick@astro.dyer.vanderbilt.edu>         */
/***************************************************************************/

BackUPS Pro series users:

/***************************************************************************/
/*              #940-0095A cable is smart mode only ???                    */
/***************************************************************************/

Tues, July 8 1997
From : hedrick@astro.dyer.vanderbilt.edu

N-th hack at cable #940-0095A.
I theory and test on a bread board, I got the !@#$%& thing to work,
but noluck with a plain jane BackUPS.  Will try to get it to work with
a SmartUPS.  Anyone want to try the dumb mode code?

/***************************************************************************/
/*              #940-0020B cable is dumb mode only.                        */
/***************************************************************************/

Date: Thu, 22 May 1997 13:34:49 -0600
From: Eric Jones <ejones@rap.ucar.edu>
To: hedrick@astro.dyer.vanderbilt.edu
Subject: apcupsd

Hi,

I just wanted to report an (almost) success story. I'm running your
apcupsd using an APC BackUPS Pro. I used the 940-0020B cables.

I'm trying to run it under Debian Linux which uses Sys V style init. Do
you have any info on how to do this correctly? If I figure it out I'll
forward the info on to you. The daemon works perfectly though. It
detects loss of power and shuts down only when the battery is low.

Thanks,

Eric Jones
ejones@ucar.edu

/***************************************************************************/
/*            #940-0024(B/C) cable is smart mode only.                     */
/***************************************************************************/

Note:
I called APC and they claim that the command language for SmartUPSs and
BackUPS Pro models are different.  I don't know the results if you try
to run this daemon with a BackUPS Pro.  I assume that there is no harm
since is an ASCII command set.

i.e

You send a character and then poll for the response.

From: Karsten Wiborg <4wiborg@informatik.uni-hamburg.de>

A -> invokes the testing of the LEDs
G -> gives T when power failure and S if not
Q -> returns 08 if the Online-LED is on and 10 if the on-battery LED
     is on. It also returns 50 if the battery power is almost
     used up and the UPS starts beeping without pause.
R -> ends the communication between UPS and computer. The UPS
     tells the computer BYE
S -> returns NA
U -> does a power failure test
W -> switches the UPS on battery but returns online after a short time
X -> returns online after a W-command
Y -> does something I don't know what probably Attention like you
     described

a -> returns a bunch of wild characters I have no idea of
b -> returns the firmware revision (in my case 21.L.I)
n -> returns the serial number
y -> returns (c) APCC

8 -> returns 00
9 -> returns FF
- -> returns NO
+ -> returns NO
' -> returns 00
@222 -> returns OK

The UPS itself sends a ! when the power fails and a $ if the power
returns. The UPS does NOT send a % if the battery is low. It also
does NOT seem to send a + if the battery is recharged enough.
It does send continuously ! in maybe 30second-intervals as long as
the power is gone.
So in order to safely shutdown LinuX, one has to immediately send
the Q-command to the UPS as soon as the UPS itself sends the ! to
the computer. As long as the UPS returns 10 the battery is okay but
as soon as the UPS returns 50, we are in trouble and LinuX has to
be shutdown ASAP !!! So we have to send the Q-command continuously
to poll for the UPS-information.

From: "Christopher J. Reimer" <reimer@doe.carleton.ca>

        Also, could you put an option into apcupsd that uses
the @ option, which I explain below, similar to the kill_power option.



f  Does not work
N  "
M  "
Q  same as smart ups.  some of your missing bits will be telling
   you smart trim and smart boost info, but I have not seen this
  happen as of yet.
P  does not work
F       "
L       "
O       "
C       "
B       "
Y  same as smart ups, sort of , bring the ups into smartmode
R  put the ups into dumb mode
W  same as smart ups
X  same as smartups, but some funny responses
power on      sleep mode                        ups off
NO              NG (does not turn on)           OK (does not turn on)
U same as smart ups, responds with OK, if not in sleep mode or off,
then it replies NA
A  same as smart ups responds OK
^a  ups type
a  some weird string
Z ~1.5 sec Z  does not work
D  does not work
V  "
c  "
k  "
l  "
m  "
n  serial #
o  does not work
p  "
r  "
s  "
u  "
x  "
y  same as smart ups
7  does not work
8  always reports 00
9  always reports FF (the windows 95 monitoring software is always sending
this to the ups ???)
-  always says no
S  soft shutdown, ups goes back online when power comes on line,
  at least it does with a good battery
@xxy  go into sleep mode after delay, and come on again in xx hours and
       y * 6 minutes
G  same as smartups, but also it returns L if there was a power outage
   during sleep mode
K ~1.5ms K  same as smart-ups


        Also, the ups puts out certain characters due to various
conditions

?  right after power-up
!  power-fail on battery
$  back on line
% or -  indicates discharged battery
+  indicates batteries recharged

/***************************************************************************/

/***************************************************************************/
/*                README.SmartUPS-VS Users of apcupsd                      */
/*          "Andre M. Hedrick" <hedrick@astro.dyer.vanderbilt.edu>         */
/***************************************************************************/

SmartUPS v/s series users:

See README.BackUPS-Pro

/***************************************************************************/

/***************************************************************************/
/*             README.NewerBackUPS-Pro Users of apcupsd                    */
/*        "Andre M. Hedrick" <hedrick@astro.dyer.vanderbilt.edu>           */
/***************************************************************************/

Newer BackUPS Pro series users:

This a newer version is my best guess......it has almost all of the
features of the Smart UPS series less the "temp" and "dip switches"
I believe that the difference is the serial number series.

Mine (donated by A.S.A. Computers) has this serial number: 'FB9742936193'

The way to test is to try both modes.

UPSTYPE newbackupspro :: returns for cat /etc/apcupsd.status

APC      : Jan 27 16:18:25
CABLE    : APC Cable 940-0095A
UPSMODEL : Smarter BackUPS Pro
UPSMODE  : Stand Alone
ULINE    : 123.8 Volts
MLINE    : 124.5 Volts
NLINE    : 123.8 Volts
FLINE    : 60.0 Hz
VOUTP    : 123.8 Volts
LOUTP    : 016.2
BOUTP    : 13.8 Volts
BCHAR    : 100.0
BFAIL    : 0x08

UPSTYPE backupspro :: returns for cat /etc/apcupsd.status

APC      : Jan 27 16:20:51
CABLE    : APC Cable 940-0095A
UPSMODEL : BackUPS Pro
UPSMODE  : Stand Alone
LINEFAIL : OK
BATTSTAT : OK
LINEVOLT : OK
LASTEVNT : POWER FAILURE

Yes, all I did was change the "UPSTYPE" for this example.
If you do not have a "newbackupspro", the top example will return
garbage.......

/***************************************************************************/
/***************************************************************************/
/*                README.Share-UPS Users of apcupsd                        */
/*      BY:  "Andre M. Hedrick" <hedrick@astro.dyer.vanderbilt.edu>        */
/***************************************************************************/

TO COME....... BETA RELEASE DOCS>>>>>>>

Beginning Project:

Information by : "Ralf Gutensohn" <rgutenso@tap.de>

>From the manual:

Basic ports

The funtionality of a Share-UPS Basic port is shown below. The following
limitations and capabilities apply the the basic port interface:

- pins 3, 5 and 6 are open collector outputs which must be pulled up
to a common referenced supply no greater than +40Vdc. The transistors
are capable of a maximun non-inductive oad of 25mAdc. Use only Pin 4
as the common.

- The output at Pin 2 generate a Lo-to-HI RS232 level what the device is
signaling On-Battery.  The pin is normally at a LO RS-232 level.

- The Share-Ups may be signaled to shutdown the UPS by applying a HI RS-232
level to Pin 1 for 4.5 seconds. Shutdown is also dependent on the UPS~s state
and the Share-UPS~s shutdown mode.

               BASIC PORT
              DB-9S pinout

                 6 7 8 9
                 o o o o
                o o o o o
                1 2 3 4 5

--------------

My translation of this part of the email message.....

BASIC UPS I/O of BackUPS Dumb

One needs to use APC cable #940-0020B or my CUSTOM cable.

--------------

Do you can help us ????
You know anyone tried to use the ShareUPS with Linuxsystems ?

Thanks for any help :)

Regards
Ralf Gutensohn
rgutenso@tap.de

/***************************************************************************/

/***************************************************************************/
/*        README.apcaccess Users of apcupsd with apcaccess                 */
/*       "Andre M. Hedrick" <hedrick@astro.dyer.vanderbilt.edu>            */
/***************************************************************************/

Usage: apcaccess < reconfig | status | slave | shutdown >

apcaccess reconfig ::	is WIP

apcaccess status   ::	Called from either "master" or "slave" to get a status
			report about UPS conditions.  This will replace
			the psuedo procfs file found in /etc directory.

apcaccess slave    ::	Called from a "slave" to tell master that I am leaving
			the network so skip over me until I return.  This is
			a TCPIP command passed back to the master machine.

			Called from the "master" to search and try to reconnect
			a returning "slave" to the network.

			This feature is functional but is quirky.
			The quirks are a timing function of reestabishing
			TCPIP sockets once they have been closed.

apcaccess shutdown ::	Only called by master to bring down all machines
			connected to managed UPS over TCPIP.  This results
			in the master machine cycling the UPS power.


