changeset 88:ea7b411aad27

cp2102-decode-ee-desc: decode interface descriptor
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 27 Sep 2023 19:39:44 +0000
parents 4393e1b4b245
children cddf60418f98
files cp2102/decode_usb_desc.c
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/cp2102/decode_usb_desc.c	Wed Sep 27 19:15:29 2023 +0000
+++ b/cp2102/decode_usb_desc.c	Wed Sep 27 19:39:44 2023 +0000
@@ -56,6 +56,27 @@
 	printf("  bMaxPower:           0x%02X (%u mA)\n", desc[8], desc[8] * 2);
 }
 
+static void
+print_interf_desc(desc)
+	u_char *desc;
+{
+	printf("  bLength:            %u", desc[0]);
+	if (desc[0] != 9)
+		fputs(" (WRONG!)", stdout);
+	putchar('\n');
+	printf("  bDescriptorType:    0x%02X", desc[1]);
+	if (desc[1] != 0x04)
+		fputs(" (WRONG!)", stdout);
+	putchar('\n');
+	printf("  bInterfaceNumber:   %u\n", desc[2]);
+	printf("  bAlternateSetting:  0x%02X\n", desc[3]);
+	printf("  bNumEndpoints:      %u\n", desc[4]);
+	printf("  bInterfaceClass:    0x%02X\n", desc[5]);
+	printf("  bInterfaceSubClass: 0x%02X\n", desc[6]);
+	printf("  bInterfaceProtocol: 0x%02X\n", desc[7]);
+	printf("  iInterface:         %u\n", desc[8]);
+}
+
 main(argc, argv)
 	char **argv;
 {
@@ -68,6 +89,8 @@
 	print_device_desc(eeprom + 0x388);
 	printf("USB configuration descriptor at 0x399A:\n");
 	print_config_desc(eeprom + 0x39A);
+	printf("USB interface descriptor at 0x39A3:\n");
+	print_interf_desc(eeprom + 0x3A3);
 	/* decoding of other descriptors remains to be implemented */
 	exit(0);
 }