Hi,

Included herein is a patch to lsusb to correctly parse the DFU descriptor.
Everything according to the USB DFU spec. It may need some work with
regards to the formatting, but apart from that it should suffice.
It's against the latest usbutils I know of, and works for me...

Regards,

Bas Vermeulen

-- 
"God, root, what is difference?"
        -- Pitr, User Friendly

"God is more forgiving."
        -- Dave Aronson
--- usbutils-0.7/lsusb.c.orig   Fri Nov  3 17:51:09 2000
+++ usbutils-0.7/lsusb.c        Thu Jun 28 15:41:03 2001
@@ -63,6 +63,7 @@
 #define USB_DT_CS_STRING               0x23
 #define USB_DT_CS_INTERFACE            0x24
 #define USB_DT_CS_ENDPOINT             0x25
+#define USB_DFU_FUNCTIONAL             0x21
 
 static const char *procbususb = "/proc/bus/usb";
 static unsigned int verblevel = 1;
@@ -881,6 +882,23 @@
        dump_junk(buf, "        ", 6+3*buf[5]);
 }
 
+static void dump_dfu_functional_descriptor(int fd, unsigned char *buf)
+{
+       if (buf[1] != USB_DFU_FUNCTIONAL)
+            printf("      Warning: Invalid Descriptor\n");
+       else if (buf[0] < 7)
+            printf("      Warning: Descriptor too short\n");
+       printf("        DFU Functional Descriptor:\n"
+               "          bLength                 %5u\n"
+               "          bDescriptorType         %5xh\n"
+               "          bmAttributes             0x%02x\n"
+               "          wDetachTimeOut          %5d ms\n"
+               "          wTransferSize           %5d bytes\n",
+               buf[0], buf[1], buf[2], 
+               (buf[3] | (buf[4] << 8)),
+               (buf[5] | (buf[6] << 8)));
+}
+
 /* ---------------------------------------------------------------------- */
 
 static void do_config(int fd, unsigned int nr)
@@ -940,6 +958,10 @@
                case USB_DT_CS_DEVICE:
                        if (curclass == 3) {
                                dump_hid_device(fd, p);
+                               break;
+                       }
+                       if (curclass == 0xfe) {
+                               dump_dfu_functional_descriptor(fd, p);
                                break;
                        }
                        printf("  unknown descriptor type:");

Reply via email to