Apcupsd's Support for USB UPSes

General

Apcupsd version 3.9.4 or later (development version to be released as 3.10.1) provides direct support for USB UPSes on Linux systems. To run apcupsd with a USB UPS, you need the following things:

Connecting a Serial port UPS to a USB port

If you would like to free up your serial port and connect your existing serial port UPS to a USB port, it is possible if you have one of the later kernels. You simply get a serial to USB adaptor that is supported by the kernel, plug it in and make one minor change to your apcupsd.conf file and away you go. Thanks to Joe Acosta for this out to me.

The device that Joe and I are using is IOgear guc232a USB 2 serial adaptor. There may be other adaptors that work equally well. If you know of one, please let us know.

At my site, running RedHat 7.1 with kernel 2.4.9-12, I simply changed my /etc/apcupsd/apcupsd.conf configuration line to be:

DEVICE /dev/ttyUSB0

Depending on whether or not you have hotplug working, you may need to explicitly load the kernel modules usbserial and

pl2303. In my case, this was not necessary.

Getting and Building a Kernel

Please note that a number of Linux packagers are including Alan Cox's patches in their standard releases. This is true for RedHat 7.1 and 7.2 if you have the latest kernel updates. As a consequence before getting and building your own kernel, if you are already running a 2.4.5 kernel or later, please check whether or not it already has the necessary USB updates. This can be done by creating the device files and running the USB test program as described below.

For some very brief instructions on how to get and build your kernel, see the Kernel Configuration section of this manual. More information on configurating a kernel can be found in the kernel-HOWTO do.

Making the Device Files

Once you have your kernel installed and working, you need to define the hiddev device files. This can be done by invoking the script in <apcupsd-src>/examples/make-hiddev, which does the following:
#!/bin/sh
mkdir -p /dev/usb/hid
mknod /dev/usb/hid/hiddev0 c 180 96
mknod /dev/usb/hid/hiddev1 c 180 97
mknod /dev/usb/hid/hiddev2 c 180 98
mknod /dev/usb/hid/hiddev3 c 180 99
mknod /dev/usb/hid/hiddev4 c 180 100
mknod /dev/usb/hid/hiddev5 c 180 101
mknod /dev/usb/hid/hiddev6 c 180 102
mknod /dev/usb/hid/hiddev7 c 180 103
mknod /dev/usb/hid/hiddev8 c 180 104
mknod /dev/usb/hid/hiddev9 c 180 105
mknod /dev/usb/hid/hiddev10 c 180 106
mknod /dev/usb/hid/hiddev11 c 180 107
mknod /dev/usb/hid/hiddev12 c 180 108
mknod /dev/usb/hid/hiddev13 c 180 109
mknod /dev/usb/hid/hiddev14 c 180 110
mknod /dev/usb/hid/hiddev15 c 180 111

Installing the HIDDEV Header File

Once you have built the kernel, you must put a copy of hiddev.h into /usr/include. Use the following:
cd /usr/src<kernel-source-directory>/
cp include/linux/hiddev.h /usr/include/linux/

Building the Test Program

Next, we recommend that you build and run the hid-ups test program. To build it enter:
cd <apcupsd-src>/examples
make hid-ups
There should be no errors.

Now assuming that everything has gone well to this point and that you have connected your USB UPS, enter:
./hid-ups
It should print a sample report of the information that it has obtained from your UPS. CAUTION! Do not run two copies of this program at the same time, or your kernel will freeze.

The report that is printed should look very similar to the report in <src>/hid-ups.rpt.

If the program reports that the device was not found ensure that all the appropriate modules are loaded as described in the Kernel Configuration section of this manual, then unplug your UPS and plug it back in. This should permit the kernel to recognize the UPS.

Building and Installing apcupsd

If you have gotten this far successfully, the last step should go fairly easily. You need a beta version 3.9.4 or later of apcupsd. Follow the instructions in the Installation Chapter of this manual, being sure to include the following options (inocha, wpa the UPS, nor detect battery status. TRANSLATION: YOU CAN BREAK YOUR SYSTEM IF THERE ARE PROBLEMS WITH YOUR UPS's BATTERY. ALSO, IF YOUR TIMEOUT IS TO LONG. Please use another cable if possible!!!!!!!!!!!!!! Full Support for UNIFIX Linux 2.0 ----> <---- More UNIFIX additions ----> <---- Brian Schau Adds new code for UNIFIX Linux ----> apcupsd-2.7.1 35902 Sep 3 21:38 apcupsd.c By Chris: More changes and fixes with Pro Series tested. Better method of "walling" the console. Minor debugging added. ShareUPS Project Started, BETA. ----> apcupsd-2.7 35413 Aug 14 15:50 apcupsd.c TESTED on the following setups: SLACKWARE SMP/NON-SMP (2.1.49) SmartUPS 700 & BackUPS 600 REDHAT 4.1 SMP/NON-SMP (2.0.30) BackUPS 600 SUSE 5.0 SMP/NON-SMP (2.0.30) BackUPS 600 NOTE BackUPS Pro Series Untested at this time of release. All UPSes can be time limited shutdown. Fixed all possible killpower problems..... Changed rc.power to include a NOW command. Changed inittab file and added # What to do when battery power fails. pn::powerfailnow:/etc/rc.d/rc.power now Made changes for SuSE distribution. Change /sbin/init.d/powerfail file Chanages to CONFIG File USE_SLACKWARE=yes USE_REDHAT=no USE_SUSE=no Auto Updater USE_MAKE_UPDATES=yes USE_MAKE_INITTAB=yes RedHat version for "powerstatus" file REDHAT_VERSION=42 ----> apcupsd-2.6 35718 Jul 10 08:10 apcupsd.c Added more info to apcupsd.maunal about special external controls. SEE "6) OTHER" in apcupsd.maunal ----> apcupsd-2.6.pre6 35718 Jul 10 08:10 apcupsd.c Made changes in rc.power to become more universial. Made N-th attempt to make use of APC cable #940-0095A "DRAT" in "dumb mode". Will now try "smart mode". "DOUBLE DRAT" APC has a new cable #940-0095C. They just want to make things hard for us........ More Pro Fixes S.u.S.e work around. This is a major DANGER!!!! If you call /usr/sbin/apcupsd /dev/apcups killpower, in a non-power problem situation. "YOU WILL SCREW YOURSELF" this safe guard is a direct override of the daemon. ----> apcupsd-2.6.pre5a 36279 Jun 23 16:39 apcupsd.c OOPS......forgot an "endif" in the distribution Makefile ----> apcupsd-2.6.pre5 36279 Jun 23 16:39 apcupsd.c Added Linux Flavor Dependencies in CONFIG file. Fixed "nologin", so only root can login during a powerfailure. All other attempts are defeated at the login prompt. ----> apcupsd-2.6.pre4 35616 Jun 19 15:40 apcupsd.c Possible RedHat 4.2 fix. ----> apcupsd-2.6.pre3 35282 Jun 17 01:41 apcupsd.c Fixes RedHat install and Makefile to make backup of files to be changed during installation. Sorry about the mistake RedHat users. ----> apcupsd-2.6.pre2 35282 Jun 17 01:41 apcupsd.c More Pro Fixes and stuff for RedHat install and Makefile ----> apcupsd-2.6.pre1 35279 Jun 16 23:04 apcupsd.c More Pro Fixes and stuff for RedHat install ----> apcupsd-2.5 36558 Jun 1 19:41 apcupsd.c More Pro Fixes and stuff for RedHat install ----> apcupsd-2.5.pre4 35