How to convert a linux-src to access APC USB HID on FreeBSD?

Riccardo Torrini riccardo at torrini.org
Sun Jun 29 14:19:34 PDT 2003


Hi there,
I asked the same question to Nick Hibma but he is very busy and can't
help me.  If someone know how to convert a linux-src to freebsd to
access my UPS I'd happy to test any piece of (non explosive) code he
sent me...

Also please Cc: me, I'm only on current at .  Thanks in advance.


I'm trying to interface my new APC (RS 500) with FreeBSD 4.8-STABLE
(but if you make a -CURRENT only code I'm able to test it) but after
some search I found that all around there are only linux applications
and I'm unable to convert them myself to FreeBSD ones.  Can you help me?

Looking on the net I found apcupsd-3.10.5 but it is a Linux-only src,
it has all protocol exposed, would be simple to convert (knowing how
linux works, at least).  If you know how to help me to convert this
single src (linux-usb.c usb.h) to FreeBSD send me a note, I'll be
happy to test.  I collect all under my local site:
	ftp://ftp.torrini.org/pub/FreeBSD/APC-hacking/

Also note that linux-usb.c and usb.h are GPL-ed, I simple extract from
the original tarball without touching the code.  If you need the whole
archive search for apcupsd-3.10.5.tar.gz on sourceforge.

Even a reduced version able only to acquire time and power would help.


# usbdevs -v -d
Controller /dev/usb0:
addr 1: self powered, config 1, UHCI root hub(0x0000), VIA(0x0000), rev 1.00
  uhub0
 port 1 powered
 port 2 addr 2: low speed, self powered, config 1, \
	Back-UPS RS 500 FW:30.j2.I USB FW:j2(0x0002), \
	American Power Conversion(0x051d), rev 0.06

After playing with usbhidctl I found that my APC use 0xff84, 0xff85 and
0xff86 instead of 0x84, 0x85 and 0x86 as it would so I created a custom
file with the contents of /usr/share/misc/usb_hid_usage and with a copy
of pages 132/133 to 0xff84/0xff85 and now it decode pages/usages.

Now I'm at a dead end, usbhidctl say:
	device does not support immediate mode, only changes reported.
but interrogating device with -a and/or -l show me only zeros.

If you need my config/boot.log feel free to download them from:
	ftp://ftp.torrini.org/pub/FreeBSD/APC-hacking/

What else can I do (apart from changing UPS)?

I hope you can point me to the right direction (docs or ML)...


-- 
Riccardo. ( http://www.GUFI.org/~vic/ )


More information about the freebsd-hackers mailing list