---------------------------
CLARiiON SPS Simulator
Version 0.1
Author: Derek Konigsberg
E-Mail: octo@logicprobe.org
---------------------------

Included is a program that simulates the functionality of the
Supplemental Power Supply (SPS) for a CLARiiON RAID controller.
This program consists of two components.  A daemon which talks
to the Storage Processor (SP) through the serial port, and a
control program that lets you interface with the daemon while it
is running.  I've written this with flexibility because you
really should be interfacing this code with UPS monitoring
software.

Installation
------------
Edit "spsd.h" to fill in the default serial port, and the path to where
you plan to put the "spsd-stop.sh" script.

Type "make" to compile the code.

Copy "spsd" and "spsctl" to whatever bin directory you like, and copy
"spsd-stop.sh" to whatever path you specified in "spsd.h".

Edit "spsd-stop.sh" in the directory you copied it to, and put in there
any commands you would like executed when the SP reports that it is safe
to shut down power.

Put "spsd" in your startup scripts, so it is run on boot.

Put the appropriate calls to "spsctl" in the scripts for your UPS 
monitoring software, so the SP will be informed of power failure events.

That's it, hopefully!

Command usage
-------------
Usage: spsd [options]
        -d      Debug mode
        -f      Run in foreground
        -p port Serial port to use
        -m msg  Initial message to send
        -h      Print this help message

Usage: spsctl [options]
        -m msg  Message to set
        -d      Debug mode
        -p port Serial port being used by spsd instance
        -h      Print this help message

Message types
-------------
0 - SPS not ready, battery charging
1 - SPS battery on-line, main power off-line, running on battery
2 - SPS Enabled, battery fully charged, system cache enabled

The default message type is "2", which indicates that the UPS is fully 
charged and good to go. 

When the line power fails, your UPS control software should use "spsctl" 
to change the message to "1".  After the SP is finished flushing cache to 
disk, "spsd" will execute the "spsd-stop.sh" script to indicate that it is 
safe for your machine to proceed with shutting down.

When main power is back online, but the UPS is still charging its battery, 
you should probably set message "0", which tells the SP that it isn't yet 
safe to enable write cache, but that the main power is back on-line.
