FreeCalypso > hg > fc-usbser-tools
changeset 91:f4a7ac90cf39
cp2102-decode-ee-desc: decode textual ID strings
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 27 Sep 2023 20:46:30 +0000 |
parents | 3bde280f0986 |
children | 915a6fa7723e |
files | cp2102/decode_usb_desc.c |
diffstat | 1 files changed, 32 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/cp2102/decode_usb_desc.c Wed Sep 27 20:15:57 2023 +0000 +++ b/cp2102/decode_usb_desc.c Wed Sep 27 20:46:30 2023 +0000 @@ -122,6 +122,35 @@ printf(" wLANGID[2]: 0x%04X\n", desc[6] | (desc[7] << 8)); } +static void +print_string_desc(headline, desc, maxlen) + char *headline; + u_char *desc; + unsigned maxlen; +{ + u_char *sp, *endp; + unsigned uni; + + if (desc[0] < 2 || desc[0] > maxlen || desc[0] & 1 || desc[1] != 0x03) { + printf("%s INVALID\n", headline); + return; + } + printf("%s \"", headline); + endp = desc + desc[0]; + for (sp = desc + 2; sp < endp; sp += 2) { + uni = sp[0] | (sp[1] << 8); + if (uni < 0x20 || uni > 0x7E) { + printf("\\u%04X", uni); + continue; + } + if (uni == '"' || uni == '\\') + putchar('\\'); + putchar(uni); + } + putchar('"'); + putchar('\n'); +} + main(argc, argv) char **argv; { @@ -142,6 +171,8 @@ print_endpoint_desc(eeprom + 0x3B3); printf("USB string descriptor 0 at 0x3800:\n"); print_string_desc_0(eeprom + 0x200); - /* decoding of other string descriptors remains to be implemented */ + print_string_desc("Manuf string: ", eeprom + 0x3C3, 60); + print_string_desc("Product string:", eeprom + 0x208, 254); + print_string_desc("Serial# string:", eeprom + 0x307, 128); exit(0); }