J.1. Prototypes and experiments

May 1996: early status hacks

APC’s Powerchute was running on kadets.d20.co.edu (a BSD/OS box) with SCO binary emulation. Early test versions ran in cron, pulled status from the log files and wrote them to a .plan file. You could see the results by fingering pwrchute@kadets.d20.co.edu while it lasted:

    Last login Sat May 11 21:33 (MDT) on ttyp0 from intrepid.rmi.net
    Welcome to the UPS monitor service at kadets.d20.co.edu.
    The Smart-UPS attached to kadets generated a report at 14:24:01 on 05/17/96.
    During the measured period, the following data points were taken:
    Voltage ranged from 115.0 VAC to 116.3 VAC.
    The UPS generated 116.3 VAC at 60.00 Hz.
    The battery level was at 27.60 volts.
    The load placed on the UPS was 024.9 percent.
    UPS temperature was measured at 045.0 degrees Celsius.
    Measurements are taken every 10 minutes by the upsd daemon.
    This report is generated by a script written by Russell Kroll<rkroll@kadets>.
    Modified for compatibility with the BSD/OS cron daemon by Neil Schroeder

This same status data could also be seen with a web browser, since we had rigged up a CGI wrapper script which called finger.

January 1997: initial protocol tests

Initial tests with a freestanding non-daemon program provided a few basic status registers from the UPS. The 940-0024C cable was not yet understood, so this happened over the [attachment:apcevilhack.jpg evil two-wire serial hack].

    Communicating with SMART-UPS 700 S/N WS9643050926 [10/17/96]
    Input voltage range: 117.6 VAC - 118.9 VAC
    Load is 010.9% of capacity, battery is charged to 100.0% of capacity

Note that today’s apcsmart driver still displays the serial number when it starts, since it is derived from this original code.

September 1997: first client/server code

The first split daemon/client code was written. upsd spoke directly to the UPS (APC Smart models only) and communicated with upsc by sending binary structures in UDP datagrams.

The first CGI interface existed, but it was all implemented with shell scripts. The main script would call upsc to retrieve status values. Then it would cat a template file through sed to plug them into the page.

Old CGI screenshot

upsstats actually has since returned to using templates, despite having a period in the middle when it used hardcoded HTML.

The images were also created with shell scripts. Each script would call upsc to get the right value (utility, upsload, battcap). It then took the value, plugged it into a command file with sed, and passed that into fly, a program which used an interpreted language to create images. fly actually uses gd, just like upsimage does today.

This code later evolved into Smart UPS Tools 0.10.