# HG changeset patch # User Mychaela Falconia # Date 1695844856 0 # Node ID cddf60418f98dea7dae6658fdec1b5b59d813bed # Parent ea7b411aad270ff294fcc4860cc9e85b2af8dc4d cp2102-decode-ee-desc: decode endpoint descriptors diff -r ea7b411aad27 -r cddf60418f98 cp2102/decode_usb_desc.c --- a/cp2102/decode_usb_desc.c Wed Sep 27 19:39:44 2023 +0000 +++ b/cp2102/decode_usb_desc.c Wed Sep 27 20:00:56 2023 +0000 @@ -77,6 +77,24 @@ printf(" iInterface: %u\n", desc[8]); } +static void +print_endpoint_desc(desc) + u_char *desc; +{ + printf(" bLength: %u", desc[0]); + if (desc[0] != 7) + fputs(" (WRONG!)", stdout); + putchar('\n'); + printf(" bDescriptorType: 0x%02X", desc[1]); + if (desc[1] != 0x05) + fputs(" (WRONG!)", stdout); + putchar('\n'); + printf(" bEndpointAddress: 0x%02X\n", desc[2]); + printf(" bmAttributes: 0x%02X\n", desc[3]); + printf(" wMaxPacketSize: %u\n", desc[4] | (desc[5] << 8)); + printf(" bInterval: %u\n", desc[6]); +} + main(argc, argv) char **argv; { @@ -91,6 +109,10 @@ 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 */ + printf("USB endpoint descriptor at 0x39AC:\n"); + 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 */ exit(0); }