# HG changeset patch # User Mychaela Falconia # Date 1695845757 0 # Node ID 3bde280f0986b4f741c43adebd283bcfddd0ff66 # Parent cddf60418f98dea7dae6658fdec1b5b59d813bed cp2102-decode-ee-desc: decode string descriptor 0 diff -r cddf60418f98 -r 3bde280f0986 cp2102/decode_usb_desc.c --- a/cp2102/decode_usb_desc.c Wed Sep 27 20:00:56 2023 +0000 +++ b/cp2102/decode_usb_desc.c Wed Sep 27 20:15:57 2023 +0000 @@ -95,6 +95,33 @@ printf(" bInterval: %u\n", desc[6]); } +static void +print_string_desc_0(desc) + u_char *desc; +{ + printf(" bLength: %u", desc[0]); + if (desc[0] > 8) + fputs(" (too long!)", stdout); + else if (desc[0] < 2) + fputs(" (too short!)", stdout); + else if (desc[0] & 1) + fputs(" (odd bogon!)", stdout); + putchar('\n'); + printf(" bDescriptorType: 0x%02X", desc[1]); + if (desc[1] != 0x03) + fputs(" (WRONG!)", stdout); + putchar('\n'); + if (desc[0] < 4) + return; + printf(" wLANGID[0]: 0x%04X\n", desc[2] | (desc[3] << 8)); + if (desc[0] < 6) + return; + printf(" wLANGID[1]: 0x%04X\n", desc[4] | (desc[5] << 8)); + if (desc[0] < 8) + return; + printf(" wLANGID[2]: 0x%04X\n", desc[6] | (desc[7] << 8)); +} + main(argc, argv) char **argv; { @@ -113,6 +140,8 @@ print_endpoint_desc(eeprom + 0x3AC); printf("USB endpoint descriptor at 0x39B3:\n"); print_endpoint_desc(eeprom + 0x3B3); - /* decoding of string descriptors remains to be implemented */ + printf("USB string descriptor 0 at 0x3800:\n"); + print_string_desc_0(eeprom + 0x200); + /* decoding of other string descriptors remains to be implemented */ exit(0); }