Changeset aad3587 in mainline
- Timestamp:
- 2011-03-17T23:10:26Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2d6787b
- Parents:
- 7b13d8e
- Location:
- uspace/app/usbinfo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/info.c
r7b13d8e raad3587 200 200 } 201 201 202 void dump_strings(usbinfo_device_t *dev) 203 { 204 /* Get supported languages. */ 205 l18_win_locales_t *langs; 206 size_t langs_count; 207 int rc = usb_request_get_supported_languages(&dev->ctrl_pipe, 208 &langs, &langs_count); 209 if (rc != EOK) { 210 fprintf(stderr, 211 NAME ": failed to get list of supported languages: %s.\n", 212 str_error(rc)); 213 return; 214 } 215 216 printf("%sString languages (%zu):", get_indent(0), langs_count); 217 size_t i; 218 for (i = 0; i < langs_count; i++) { 219 printf(" 0x%04x", (int) langs[i]); 220 } 221 printf(".\n"); 222 223 /* Get all strings and dump them. */ 224 for (i = 0; i < langs_count; i++) { 225 l18_win_locales_t lang = langs[i]; 226 227 printf("%sStrings for language 0x%04x:\n", get_indent(0), 228 (int) lang); 229 /* 230 * Try only the first 15 strings 231 * (typically, device will not have much more anyway). 232 */ 233 size_t idx; 234 for (idx = 1; idx < 0x0F; idx++) { 235 char *string; 236 rc = usb_request_get_string(&dev->ctrl_pipe, idx, lang, 237 &string); 238 if (rc != EOK) { 239 continue; 240 } 241 printf("%sString #%zu: \"%s\"\n", get_indent(1), 242 idx, string); 243 free(string); 244 } 245 } 246 } 247 202 248 int dump_device(devman_handle_t hc_handle, usb_address_t address) 203 249 { -
uspace/app/usbinfo/main.c
r7b13d8e raad3587 134 134 _OPTION("-m --match-ids", "Print match ids generated for the device."); 135 135 _OPTION("-t --descriptor-tree", "Print descriptor tree."); 136 _OPTION("-s --strings", "Try to print all string descriptors."); 136 137 137 138 printf("\n"); … … 148 149 {"match-ids", no_argument, NULL, 'm'}, 149 150 {"descriptor-tree", no_argument, NULL, 't'}, 151 {"strings", no_argument, NULL, 's'}, 150 152 {0, 0, NULL, 0} 151 153 }; 152 static const char *short_options = "himt ";154 static const char *short_options = "himts"; 153 155 154 156 int main(int argc, char *argv[]) … … 162 164 bool action_print_match_ids = false; 163 165 bool action_print_descriptor_tree = false; 166 bool action_print_strings = false; 164 167 165 168 /* … … 189 192 action_print_descriptor_tree = true; 190 193 break; 194 case 's': 195 action_print_strings = true; 196 break; 191 197 default: 192 198 assert(false && "unreachable code"); … … 198 204 if (!action_print_match_ids 199 205 && !action_print_short_identification 206 && !action_print_strings 200 207 && !action_print_descriptor_tree) { 201 208 action_print_short_identification = true; … … 239 246 dump_descriptor_tree_brief(dev); 240 247 } 248 if (action_print_strings) { 249 dump_strings(dev); 250 } 241 251 242 252 /* Destroy the control pipe (close the session etc.). */ -
uspace/app/usbinfo/usbinfo.h
r7b13d8e raad3587 76 76 void dump_device_match_ids(usbinfo_device_t *); 77 77 void dump_descriptor_tree_brief(usbinfo_device_t *); 78 void dump_strings(usbinfo_device_t *); 78 79 79 80
Note:
See TracChangeset
for help on using the changeset viewer.