[Nut-upsdev] PowerWalker and megatec_usb

Arjen de Korte nut+devel at de-korte.org
Thu Sep 13 07:16:45 UTC 2007


> I've (finally) decided to try and make my PowerWalker work with
> megatec_usb. So far it seems the agiler subdriver is the way to go,
> but it doesn't work. The initial detection process sometimes succeeds
> in 1 out of 5 "Q1" commands, but that's about it (which is better than
> what the krauler subdriver can do... absolutely nothing).

Having looked at this subdriver, I think this is duplicating what libusb
is already doing for us. Breaking up data in 8 byte chunks is probably not
needed and neither is setting the exact number of bytes you expect. So the
get_data_agiler() function could probably be reduced to something like

static int get_data_agiler(char *buffer, int buffer_size)
{
	return usb->get_interrupt(udev, (unsigned char *)buffer, buffer_size, 250);
}

Note the reduction in the timeout we set here. Although the USB 2.0
specification allows for up to 5 seconds for interrupt reports, this is
not what we want in NUT. Rather than keep waiting for information (because
the USB bus is apparently busy at the time), drivers should abort the
attempt to read data and retry the next time. This probably requires some
leniency in the upsdrv_updateinfo() function, so that it doesn't
immediately declare a UPS stale if it fails reading data a single time.
See for an example safenet.c, which allows for up to two consecutive
failures before declaring the data stale.

> So, what needs to be done to obtain more information? I don't seem to
> get anything readable out of the "get_descriptor" tool. What command
> line parameters should I use?

Could you post the output of 'lsusb -v' for your UPS here?

> Be aware that I'm still almost completely ignorant about this USB stuff...

I also was until a couple of weeks ago. You'll find that most of the low
level stuff will be dealt with by the libusb library, so it's probably
best to start reading there (see http://libusb.sourceforge.net/doc).

Best regards, Arjen
-- 
Eindhoven - The Netherlands
Key fingerprint - 66 4E 03 2C 9D B5 CB 9B  7A FE 7E C1 EE 88 BC 57




More information about the Nut-upsdev mailing list