UPSMon v0.01
(C)Copyright 1998 by Mike Byrne - All rights reserved

#include <standard.disclaimer>

 This program is released "AS IS".  The author guarantees nothing, and will
 not be held responsible for any damages you may incur while using this
 program.
 
 Your usage of this program signifies your agreement to these terms.
   

- Introduction

 UPSMon is a program I worked on a few months ago to interface with my
 APC Back-UPS 400.  The UPS connects to a serial port on your PC with
 a special cable.  UPSMon provides notification of power loss to the system
 in order to allow a graceful shutdown.
 

- Background
 
 I looked up "APC UPS CABLE" on www.dejanews.com to see how to make a cable
 to connect my UPS to my serial port.  Just as a warning, do not try to use
 a "straight through" or "null modem" serial cable.  I'm not sure exactly
 what they will do, but I know for sure they won't work, and it's possible
 that using one may damage something.
 
 After constructing the cable (in a later release I'll include the
 instructions and diagrams I used to construct my cable), I figured I'd need
 a daemon on the PC for the UPS to talk to.
 

- Details

 I first tried writing just an application to do what I wanted...  This worked
 for 85% of what I wanted to do.  It would detect the power failure, wait 10
 minutes, then if the power hadn't come back up, would call DosShutDown to
 shut down the system.  After calling DosShutDown, however, my program was
 unable to send the necessary signal back to the UPS to kill the power.  This
 is because calling DosShutDown apparently closes the COM drivers.  So, I
 decided that I need to write my own device driver to accomplish my goal.
 Now, program execution is as follows:
 
 Repeat
 
  Check For Power Failure
  If (Power is Failing) then Begin
   If (Battery is depleted) then perform immediate shutdown
   Repeat
    Sleep for 1 second
   Until (Power is back on) or (Battery is depleted) or (Power has been out for > 10 minutes)
   If (Power is back on) then exit else perform immediate shutdown
  End
 Until Killed


 The program will log all power failures for you, so you can see just how bad
 your power utility company is :)
 

- Installation

 It's easy to install.  Unzip the archive into some directory.  Install
 UPSMON.SYS into your config.sys, for example:
 
 DEVICE=X:\WHATEVER\DIR\UPSMON.SYS
 
 You will need to reboot for this to take effect.  Then, simply run upsmon.exe
 with the only parameter being the hex address of your serial port, ie:
 
 upsmon 3f8
 
 Would start UPSMon on COM port 1.  On most systems, here is how the port
 addresses correspond with the COM port numbers:
 
 COM1 = 3f8
 COM2 = 2f8
 COM3 = 3e8
 COM4 = 2e8
 
 If you are using some other COM port, it's up to you to figure out what
 address it's using.  Also, my program doesn't use an IRQ, so you could use
 a COM port without assigning it an IRQ if you like...
 
 Simply running upsmon from the command line will log all entries to the
 screen.  To redirect it to a file, try
 
 upsmon 3f8 > upsmon.log
 
 It might be a good idea to put this in your \STARTUP.CMD file.

 
- Contact
 
 You can reach me at upsmon@turbolink.net if you want.  Send questions,
 comments, whatever.  If you would like to see a feature in a next release,
 let me know.  If I don't get any feedback, I'll probably never update UPSMon
 again, since it suits my needs fine...
 
 
 Mike Byrne
 upsmon@turbolink.net
 http://www.turbolink.net
 
 
