[Nut-upsdev] Liebert PSI 1440 support
Peter Selinger
selinger at mathstat.dal.ca
Sun Sep 25 16:20:31 UTC 2005
Stewart Morgan wrote:
> Peter Selinger wrote:
> > The CVS version is cleaner than the 2.0.2, but does not differ
> > significantly in functionality. -- Peter
>
> Apart from the addition of Belkin support? :)
Yes, that detail :) I assume you saw the discussion on Sep 7/8 with
Jochen Bern about how Liebert and Belkin seem to behave
identically. But your problem appears to be more fundamental than
that.
> > If you just want to read raw information from your device, you can use
> > the program "get_descriptor.c" that I posted on the mailing list on
> > Aug 30:
>
> Right, I've managed to build it; though from the output (below, with
> libusb debug on), it doesn't look like it wants to play :(
>
> ----8<--------8<--------8<--------8<--------8<--------8<--------8<----
> #> USB_DEBUG=3 ./get_descriptor /dev/usb0 /dev/ugen0 0 0 0 128 0x22 0
> usb_set_debug: Setting debugging level to 3 (on)
> usb_os_find_busses: Found /dev/usb0
> usb_os_find_devices: Found /dev/ugen0 on /dev/usb0
> usb_control_msg: 128 6 512 0 0xbfbfe210 8 1000
> usb_control_msg: 128 6 512 0 0x804d040 34 1000
> skipped 1 class/vendor specific interface descriptors
> USB error: could not set alt intf 0/0: Invalid argument
> Warning: could not set alt intf 0/0: Invalid argument
> usb_control_msg: 128 6 8704 0 0xbfbfe2e0 2048 1000
> USB error: error sending control message: Input/output error
> Can't get endpoint 128 descriptor 0x22 index 0: error sending control
> message: Input/output error
> ---->8-------->8-------->8-------->8-------->8-------->8-------->8----
Do you have reason to believe that your USB is indeed device 0 on bus
0? I am not familiar with BSD, but usually the first device on any bus
is a host controller. In this case, it would not be surprising that
you can't get descriptor 0x22 - it would not have one.
I am attaching another program, usbtest.c, that iterates through all
USB devices and dumps information about them (similar to usbview).
If you could post the output of this, it might help.
Also run the Development version of NUT from CVS, with the -DD option,
and post the output. It might contain some hints as to where things fail.
----------------------------------------------------------------------
/* usbtest.c: dump a bunch of information about connected USB devices,
using the libusb API. See http://libusb.sourceforge.net/doc/.
Copyright (C) 2005 Peter Selinger. Licenced under the GNU General
Public License. */
#include <stdio.h>
#include <usb.h>
void fprint_usb_device_descriptor(FILE *fout, struct usb_device_descriptor *p) {
char *indent = " ";
fprintf(fout, "%sbLength: %u\n", indent, p->bLength);
fprintf(fout, "%sbDescriptorType: %u\n", indent, p->bDescriptorType);
fprintf(fout, "%sbcdUSB: %04x\n", indent, p->bcdUSB);
fprintf(fout, "%sbDeviceClass: %u\n", indent, p->bDeviceClass);
fprintf(fout, "%sbDeviceSubClass: %u\n", indent, p->bDeviceSubClass);
fprintf(fout, "%sbDeviceProtocol: %u\n", indent, p->bDeviceProtocol);
fprintf(fout, "%sbMaxPacketSize0: %u\n", indent, p->bMaxPacketSize0);
fprintf(fout, "%sidVendor: %04x\n", indent, p->idVendor);
fprintf(fout, "%sidProduct: %04x\n", indent, p->idProduct);
fprintf(fout, "%sbcdDevice: %04x\n", indent, p->bcdDevice);
fprintf(fout, "%siManufacturer: %u\n", indent, p->iManufacturer);
fprintf(fout, "%siProduct: %u\n", indent, p->iProduct);
fprintf(fout, "%siSerialNumber: %u\n", indent, p->iSerialNumber);
fprintf(fout, "%sbNumConfigurations: %u\n", indent, p->bNumConfigurations);
}
void fprint_usb_endpoint_descriptor(FILE *fout, struct usb_endpoint_descriptor *p) {
int i;
char *indent = " ";
fprintf(fout, "%sbLength: %u\n", indent, p->bLength);
fprintf(fout, "%sbDescriptorType: %u\n", indent, p->bDescriptorType);
fprintf(fout, "%sbEndpointAddress: %u\n", indent, p->bEndpointAddress);
fprintf(fout, "%sbmAttributes: %02x\n", indent, p->bmAttributes);
fprintf(fout, "%swMaxPacketSize: %u\n", indent, p->wMaxPacketSize);
fprintf(fout, "%sbInterval: %u\n", indent, p->bInterval);
fprintf(fout, "%sbRefresh: %u\n", indent, p->bRefresh);
fprintf(fout, "%sbSynchAddress: %u\n", indent, p->bSynchAddress);
fprintf(fout, "%sextralen: %u\n", indent, p->extralen);
fprintf(fout, "%sextra:", indent);
for (i=0; i<p->extralen; i++) {
fprintf(fout, " %02x", p->extra[i]);
}
fprintf(fout, "\n");
}
void fprint_usb_interface_descriptor(FILE *fout, struct usb_interface_descriptor *p) {
int i;
char *indent = " ";
fprintf(fout, "%sbLength: %u\n", indent, p->bLength);
fprintf(fout, "%sbDescriptorType: %u\n", indent, p->bDescriptorType);
fprintf(fout, "%sbInterfaceNumber: %u\n", indent, p->bInterfaceNumber);
fprintf(fout, "%sbAlternateSetting: %u\n", indent, p->bAlternateSetting);
fprintf(fout, "%sbNumEndpoints: %u\n", indent, p->bNumEndpoints);
fprintf(fout, "%sbInterfaceClass: %u\n", indent, p->bInterfaceClass);
fprintf(fout, "%sbInterfaceSubClass: %u\n", indent, p->bInterfaceSubClass);
fprintf(fout, "%sbInterfaceProtocol: %u\n", indent, p->bInterfaceProtocol);
fprintf(fout, "%siInterface: %u\n", indent, p->iInterface);
fprintf(fout, "%sendpoints:\n", indent);
for (i=0; i<p->bNumEndpoints; i++) {
fprint_usb_endpoint_descriptor(fout, &p->endpoint[i]);
}
fprintf(fout, "%sextralen: %u\n", indent, p->extralen);
fprintf(fout, "%sextra:", indent);
for (i=0; i<p->extralen; i++) {
fprintf(fout, " %02x", p->extra[i]);
}
fprintf(fout, "\n");
}
void fprint_usb_interface(FILE *fout, struct usb_interface *p) {
char *indent = " ";
int i;
fprintf(fout, "%snum_altsetting: %d\n", indent, p->num_altsetting);
for (i=0; i<p->num_altsetting; i++) {
fprint_usb_interface_descriptor(fout, &p->altsetting[i]);
}
}
void fprint_usb_config_descriptor(FILE *fout, struct usb_config_descriptor *p) {
int i;
char *indent = " ";
fprintf(fout, "%sbLength: %u\n", indent, p->bLength);
fprintf(fout, "%sbDescriptorType: %u\n", indent, p->bDescriptorType);
fprintf(fout, "%swTotalLength: %u\n", indent, p->wTotalLength);
fprintf(fout, "%sbNumInterfaces: %u\n", indent, p->bNumInterfaces);
fprintf(fout, "%sbConfigurationValue: %u\n", indent, p->bConfigurationValue);
fprintf(fout, "%siConfiguration: %u\n", indent, p->iConfiguration);
fprintf(fout, "%sbmAttributes: %02x\n", indent, p->bmAttributes);
fprintf(fout, "%sMaxPower: %u\n", indent, p->MaxPower);
fprintf(fout, "%sinterface:\n", indent);
fprint_usb_interface(fout, p->interface);
fprintf(fout, "%sextralen: %u\n", indent, p->extralen);
fprintf(fout, "%sextra:", indent);
for (i=0; i<p->extralen; i++) {
fprintf(fout, " %02x", p->extra[i]);
}
fprintf(fout, "\n");
}
void fprint_usb_device_manufacturer(FILE *fout, struct usb_device *dev) {
usb_dev_handle *udev;
char *indent = " ";
int r;
char string[255];
udev = usb_open(dev);
if (!udev) {
fprintf(fout, "%sCan't open device\n", indent);
return;
}
if (dev->descriptor.iManufacturer) {
r = usb_get_string_simple(udev, dev->descriptor.iManufacturer, string, sizeof(string));
if (r > 0) {
fprintf(fout, "%sManufacturer: %s\n", indent, string);
} else {
fprintf(fout, "%sCan't get Manufacturer\n", indent);
}
} else {
fprintf(fout, "%sNo Manufacturer\n", indent);
}
if (dev->descriptor.iProduct) {
r = usb_get_string_simple(udev, dev->descriptor.iProduct, string, sizeof(string));
if (r > 0) {
fprintf(fout, "%sProduct: %s\n", indent, string);
} else {
fprintf(fout, "%sCan't get Product\n", indent);
}
} else {
fprintf(fout, "%sNo Product\n", indent);
}
if (dev->descriptor.iSerialNumber) {
r = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof(string));
if (r > 0) {
fprintf(fout, "%sSerialNumber: %s\n", indent, string);
} else {
fprintf(fout, "%sCan't get SerialNumber\n", indent);
}
} else {
fprintf(fout, "%sNo SerialNumber\n", indent);
}
if (udev) {
usb_close(udev);
}
}
void fprint_usb_device(FILE *fout, struct usb_device *devices) {
struct usb_device *p;
int i;
char *indent = " ";
for (p = devices; p != NULL; p = p->next) {
fprintf(fout, "%sDEVICE %p\n", indent, p);
fprint_usb_device_manufacturer(fout, p);
fprintf(fout, "%snext: %p\n", indent, p->next);
fprintf(fout, "%sprev: %p\n", indent, p->prev);
fprintf(fout, "%sfilename: %s\n", indent, p->filename);
fprintf(fout, "%sbus: %p\n", indent, p->bus);
fprintf(fout, "%sdescriptor:\n", indent);
fprint_usb_device_descriptor(fout, &p->descriptor);
fprintf(fout, "%sconfig:\n", indent);
fprint_usb_config_descriptor(fout, p->config);
fprintf(fout, "%sdev: %p\n", indent, p->dev);
fprintf(fout, "%sdevnum: %u\n", indent, p->devnum);
fprintf(fout, "%snum_children: %u\n", indent, p->num_children);
fprintf(fout, "%schildren:", indent);
for (i=0; i<p->num_children; i++) {
fprintf(fout, " %p", p->children[i]);
}
fprintf(fout, "\n");
fprintf(fout, "\n");
}
}
void fprint_usb_bus(FILE *fout, struct usb_bus *bus) {
struct usb_bus *p;
char *indent = "";
for (p = bus; p != NULL; p = p->next) {
fprintf(fout, "%sBUS %p\n", indent, p);
fprintf(fout, "%snext: %p\n", indent, p->next);
fprintf(fout, "%sprev: %p\n", indent, p->prev);
fprintf(fout, "%sdirname: %s\n", indent, p->dirname);
fprintf(fout, "%sdevices:\n", indent);
fprint_usb_device(fout, p->devices);
fprintf(fout, "%slocation: %u\n", indent, p->location);
fprintf(fout, "%sroot_dev: %p\n", indent, p->root_dev);
fprintf(fout, "\n");
}
}
int main() {
int busses, busses1;
int devices, devices1;
struct usb_bus *my_busses;
/* set up some internal structures. */
usb_init();
busses = usb_find_busses();
fprintf(stdout, "usb_find_busses: %d\n", busses);
busses1 = usb_find_busses();
fprintf(stdout, "usb_find_busses: %d\n", busses1);
devices = usb_find_devices();
fprintf(stdout, "usb_find_devices: %d\n", devices);
devices1 = usb_find_devices();
fprintf(stdout, "usb_find_devices: %d\n", devices1);
my_busses = usb_get_busses();
fprintf(stdout, "usb_get_busses:\n");
fprint_usb_bus(stdout, my_busses);
return 0;
}
More information about the Nut-upsdev
mailing list