apcupsd and USB interfaces on APC UPS under FreeBSD

READ THIS FIRST

APC works just fine with FreeBSD 6.1 and apcupsd. For detailed information, please read apcupsd - Configuring a UPS daemon. As of 22 Apr 2006, the problems have been fixed. My thanks to those that worked on the problem and resolved the issues. I take no credit there.

This page remains as a record of what was done.



Travis Campbell and Dan Langille are were working to get apcupsd to work with APC RS/XS series of USB capable UPSs. For now, we are using the devel/libusb port but no progress has been made.

We have the recommendations of the FreeBSD port maintainer.

We found that Riccardo Torrini had already done some work in this area. See his post to the FreeBSD hardware and hackers mailing lists. His results are at ftp://ftp.torrini.org/pub/FreeBSD/APC-hacking/help.needed.

Mike Tancsa also posted http://www.tancsa.com/apc-usb.tgz which is also mirrored right here.

Riccardo suggested that if we have an APC USB UPS, then we can try to sniff the protocol under Windows:

APC contacts

USB HID usage table

This usage table lets usbhidctl(1) decode the HID data correctly for the APC RS/XS1000's.

USB Code maintainers

devel/libusb

This FreeBSD port is considered beta. It does come with a testing utility (testlibusb) which should list devices but does not. See this post.

Other utilities

We found that usbutils provided useful device information. The APC is an HID class device. I'm told there is a generic power device definition and that if the APC complies with that definition, it may be worth implementing a upower(4) driver. We don't yet know how would this be any different than getting apcupsd to do the right thing with /dev/uhid0.

Compare the usbutils output with that of the usbhidctl command with the table. At first glance, it's the same data, presently differently, by two different programs. This is a good sign. It means we should be able to create a driver/interface to the APC UPS using the code examples as a starting point.

Resources

These are documents we have collected along the way:

See also http://www.exploits.org/nut/

These are the ioctl's used in the linux usb driver: http://www.charmed.com/txt/hiddev.txt