The device that Joe and I are using is IOgear guc232a USB 2 serial adapter. There may be other adapters 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.
Please note if you have cable number 940-0128A, your UPS will be connected to your serial port as a standard serial UPS and the rest of this chapter will not apply to your case.
For some very brief instructions on how to get and build your kernel, see the Kernel Configuration section of this manual. More information on configuring a kernel can be found in the kernel-HOWTO do.
#!/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 111Note, as of RedHat 8.0, the hiddev devices are defined when the OS is installed, except they are defined as /dev/usb/hiddev0 - 15. Thus you will either need to run the above script and stick with our scheme, or you can choose to use the standard RedHat definitions. If you go with the Red Hat locations, you will probanly have to change the DEVICE entry in your apcupsd.conf file by hand.
cd /usr/src<kernel-source-directory>/ cp include/linux/hiddev.h /usr/include/linux/This step should not be necessary if you have a preconfigured kernel as long as you have loaded the kernel-headers rpm.
cd <apcupsd-src>/examples make hid-upsThere should be no errors. Now assuming that everything has gone well to this point and that you have connected your USB UPS, enter:
./hid-upsIt 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.
If ./hid-ups tells you "No permission, try this as root", you know what to try. If it says "Couldn't find USB UPS device, check your /dev.", then it is very unlikely that apcupsd will work. You probably need to run the script "make-hiddev" before continuing.
./configure \ --with-serial-dev=/dev/usb/hid/hiddev[0-15] \ --with-upstype=usb \ --with-upscable=usb \ --enable-pthreads \ --enable-usbPlease note, it is IMPORTANT to include the --with-serial-dev=/dev/usb/hid/hiddev[0-15] \ line. This will cause the apcupsd.conf file to contain:
DEVICE /dev/usb/hid/hiddev[0-15]If you are on a Red Hat system and sticking to the Red Hat naming scheme, however, the --with0serial-dev option needs to be /dev/usb/hiddev[0-15]. The [0-15] is not a typo, but should be entered exactly as shown. This is because the UPS can change device numbers while it is running. Every time there is a blip or slowdown on the USB line, the kernel will invalidate the UPS connection, then a few moments later, it will reconnect but with a different device number. Not very Unix like, but that is what happens. This bizarre syntax allows apcupsd to try a range of devices until it finds or re-finds the UPS device.
If you are technically inclined, you may want to look at the /proc file system to see what devices are attached to your USB ports. The most interesting information will be found by listing the contents of /proc/bus/usb/devices. This information is updated by the kernel whenever a device is plugged in or unplugged, irrespective of whether apcupsd is running or not. To interpret the codes in this file, please see http://www.linuxhq.com/kernel/v2.4/doc/usb/proc_usb_info.txt.html
As a reference, on my system, I have the following entry for my Back-UPS 350 direct connected USB device:
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=1.5 MxCh= 0 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=051d ProdID=0002 Rev= 1.00 S: Manufacturer=American Power Conversion S: Product=Back-UPS 350 FW: 5.2.I USB FW: c1 S: SerialNumber=BB0115017954 C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr= 30mA I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=hid E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl= 10ms
And for my IOgear that runs my serial SmartUPS 1000 (plugged into a USB port):
T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 4 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=0557 ProdID=2008 Rev= 0.01 C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=serial E: Ad=81(I) Atr=03(Int.) MxPS= 10 Ivl= 1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl= 0ms E: Ad=83(I) Atr=02(Bulk) MxPS= 64 Ivl= 0ms
Note that the IOgear device is using the serial driver (the I: line) while the Back-UPS 350 is using the hid driver.
Here is an example of a cat /proc/modules on my machine (RedHat 7.1 - kernel 2.4.9-12). Note, I am running both an IOGear serial USB device and a standard USB device.
nfs 77312 9 (autoclean) es1371 26816 0 (autoclean) ac97_codec 9376 0 (autoclean) [es1371] gameport 1856 0 (autoclean) [es1371] soundcore 4144 4 (autoclean) [es1371] nfsd 69920 4 (autoclean) lockd 51664 1 (autoclean) [nfs nfsd] sunrpc 62832 1 (autoclean) [nfs nfsd lockd] parport_pc 14736 1 (autoclean) lp 6176 0 (autoclean) parport 24832 1 (autoclean) [parport_pc lp] autofs 10784 1 (autoclean) nls_iso8859-1 2880 1 (autoclean) smbfs 35344 1 (autoclean) 3c59x 26336 1 (autoclean) ipchains 36704 0 pl2303 7648 1 hid 18576 1 usbserial 18288 1 [pl2303] input 3648 0 [hid] usb-uhci 21568 0 (unused) usbcore 50784 1 [pl2303 hid usbserial usb-uhci]
I am not a kernel expert, but for a standard USB connection, I believe that you need the following modules loaded:
usbcore input hid
For the IOGear serial USB connection, you need:
usbcore usbserial pl2303
You can check this by bringing up your system, fiddling around until you get apcupsd to work with the UPS, then do:
cat /proc/modules
and save the output some place. Then reboot your computer and before you do anything else, do the cat /proc/modules again. Most likely you will find some of the usb modules are missing in the second listing.
There are two solutions:
hotplug-2001_02_14-15
You might want to read the man page on hotplug, and it might be necessary to:
cp /etc/hotplug/usb.rc /etc/init.d/hotplug
to get it fully working.
/sbin/modprobe <missing-module-name>
in the /etc/rc.d/init.d/apcupsd script just after the start) case (at about line 17). This will force the modules to be loaded before apcupsd is invoked.