Browse Source

--usb-dump display brief dump if value = 0

nfactor-troky
Kano 12 years ago
parent
commit
6acda9373b
  1. 4
      README
  2. 39
      usbutils.c

4
README

@ -250,8 +250,8 @@ This is useful if you unplug a device then plug it back in the same port, @@ -250,8 +250,8 @@ This is useful if you unplug a device then plug it back in the same port,
it usually reappears with the same bus_number but a different device_address
You can see the list of USB devices on linux with 'sudo lsusb'
Cgminer will list the USB devices with the '--usb-dump 1' option
The '--usb-dump N' option with a value of N greater than 1 will dump a lot
Cgminer will list the USB devices with the '--usb-dump 0' option
The '--usb-dump N' option with a value of N greater than 0 will dump a lot
of details about each USB device
The second version

39
usbutils.c

@ -414,6 +414,8 @@ static bool setgetdes(ssize_t count, libusb_device *dev, struct libusb_device_ha @@ -414,6 +414,8 @@ static bool setgetdes(ssize_t count, libusb_device *dev, struct libusb_device_ha
static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, size_t *len)
{
struct libusb_device_descriptor desc;
uint8_t bus_number;
uint8_t device_address;
struct libusb_device_handle *handle;
struct libusb_config_descriptor *config;
const struct libusb_interface_descriptor *idesc;
@ -432,16 +434,26 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, @@ -432,16 +434,26 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off,
return;
}
sprintf(tmp, EOL ".USB dev %d: Device Descriptor:" EOL "\tLength: %d" EOL
bus_number = libusb_get_bus_number(dev);
device_address = libusb_get_device_address(dev);
if (opt_usbdump == 0) {
sprintf(tmp, EOL ".USB dev %d: Bus %d Device %d ID: %04x:%04x",
(int)count, (int)bus_number, (int)device_address,
desc.idVendor, desc.idProduct);
} else {
sprintf(tmp, EOL ".USB dev %d: Bus %d Device %d Device Descriptor:" EOL "\tLength: %d" EOL
"\tDescriptor Type: %s" EOL "\tUSB: %04x" EOL "\tDeviceClass: %d" EOL
"\tDeviceSubClass: %d" EOL "\tDeviceProtocol: %d" EOL "\tMaxPacketSize0: %d" EOL
"\tidVendor: %04x" EOL "\tidProduct: %04x" EOL "\tDeviceRelease: %x" EOL
"\tNumConfigurations: %d",
(int)count, (int)(desc.bLength), destype(desc.bDescriptorType),
(int)count, (int)bus_number, (int)device_address,
(int)(desc.bLength), destype(desc.bDescriptorType),
desc.bcdUSB, (int)(desc.bDeviceClass), (int)(desc.bDeviceSubClass),
(int)(desc.bDeviceProtocol), (int)(desc.bMaxPacketSize0),
desc.idVendor, desc.idProduct, desc.bcdDevice,
(int)(desc.bNumConfigurations));
}
append(buf, tmp, off, len);
err = libusb_open(dev, &handle);
@ -451,6 +463,21 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, @@ -451,6 +463,21 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off,
return;
}
err = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, man, STRBUFLEN);
if (err < 0)
sprintf((char *)man, "** err(%d)", err);
err = libusb_get_string_descriptor_ascii(handle, desc.iProduct, prod, STRBUFLEN);
if (err < 0)
sprintf((char *)prod, "** err(%d)", err);
if (opt_usbdump == 0) {
libusb_close(handle);
sprintf(tmp, EOL " Manufacturer: '%s'" EOL " Product: '%s'", man, prod);
append(buf, tmp, off, len);
return;
}
if (libusb_kernel_driver_active(handle, 0) == 1) {
sprintf(tmp, EOL " * dev %d: kernel attached", (int)count);
append(buf, tmp, off, len);
@ -516,14 +543,6 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, @@ -516,14 +543,6 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off,
libusb_free_config_descriptor(config);
config = NULL;
err = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, man, STRBUFLEN);
if (err < 0)
sprintf((char *)man, "** err(%d)", err);
err = libusb_get_string_descriptor_ascii(handle, desc.iProduct, prod, STRBUFLEN);
if (err < 0)
sprintf((char *)prod, "** err(%d)", err);
err = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, ser, STRBUFLEN);
if (err < 0)
sprintf((char *)ser, "** err(%d)", err);

Loading…
Cancel
Save