[c377bc50] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Vojtech Horky
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[632ed68] | 29 | /** @addtogroup usbinfo
|
---|
[c377bc50] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /**
|
---|
| 33 | * @file
|
---|
[632ed68] | 34 | * Dumping of generic device properties.
|
---|
[c377bc50] | 35 | */
|
---|
| 36 | #include <stdio.h>
|
---|
| 37 | #include <str_error.h>
|
---|
| 38 | #include <errno.h>
|
---|
[06f9a9c9] | 39 | #include <usb/debug.h>
|
---|
[7d521e24] | 40 | #include <usb/dev/pipes.h>
|
---|
| 41 | #include <usb/dev/recognise.h>
|
---|
| 42 | #include <usb/dev/request.h>
|
---|
[e160da4d] | 43 | #include <usb/classes/classes.h>
|
---|
[eece178] | 44 | #include <usb/classes/hub.h>
|
---|
[c377bc50] | 45 | #include "usbinfo.h"
|
---|
| 46 |
|
---|
[06f9a9c9] | 47 | void dump_short_device_identification(usb_device_t *usb_dev)
|
---|
[3100ebe] | 48 | {
|
---|
| 49 | printf("%sDevice 0x%04x by vendor 0x%04x\n", get_indent(0),
|
---|
[e2dfa86] | 50 | usb_device_descriptors(usb_dev)->device.product_id,
|
---|
| 51 | usb_device_descriptors(usb_dev)->device.vendor_id);
|
---|
[3100ebe] | 52 | }
|
---|
| 53 |
|
---|
[8a121b1] | 54 | static void dump_match_ids_from_interface(
|
---|
| 55 | const uint8_t *descriptor, size_t depth, void *arg)
|
---|
[7b13d8e] | 56 | {
|
---|
| 57 | if (depth != 1) {
|
---|
| 58 | return;
|
---|
| 59 | }
|
---|
| 60 | size_t descr_size = descriptor[0];
|
---|
| 61 | if (descr_size < sizeof(usb_standard_interface_descriptor_t)) {
|
---|
| 62 | return;
|
---|
| 63 | }
|
---|
| 64 | int descr_type = descriptor[1];
|
---|
| 65 | if (descr_type != USB_DESCTYPE_INTERFACE) {
|
---|
| 66 | return;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[06f9a9c9] | 69 | usb_device_t *usb_dev = arg;
|
---|
| 70 | assert(usb_dev);
|
---|
[7b13d8e] | 71 |
|
---|
[3bacee1] | 72 | usb_standard_interface_descriptor_t *iface =
|
---|
| 73 | (usb_standard_interface_descriptor_t *) descriptor;
|
---|
[7b13d8e] | 74 |
|
---|
| 75 | printf("%sInterface #%d match ids (%s, 0x%02x, 0x%02x)\n",
|
---|
| 76 | get_indent(0),
|
---|
| 77 | (int) iface->interface_number,
|
---|
| 78 | usb_str_class(iface->interface_class),
|
---|
| 79 | (int) iface->interface_subclass,
|
---|
| 80 | (int) iface->interface_protocol);
|
---|
| 81 |
|
---|
| 82 | match_id_list_t matches;
|
---|
| 83 | init_match_ids(&matches);
|
---|
[06f9a9c9] | 84 | usb_device_create_match_ids_from_interface(
|
---|
[e2dfa86] | 85 | &usb_device_descriptors(usb_dev)->device, iface, &matches);
|
---|
[7b13d8e] | 86 | dump_match_ids(&matches, get_indent(1));
|
---|
| 87 | clean_match_ids(&matches);
|
---|
| 88 | }
|
---|
| 89 |
|
---|
[06f9a9c9] | 90 | void dump_device_match_ids(usb_device_t *usb_dev)
|
---|
[3100ebe] | 91 | {
|
---|
| 92 | match_id_list_t matches;
|
---|
| 93 | init_match_ids(&matches);
|
---|
[e2dfa86] | 94 | usb_device_create_match_ids_from_device_descriptor(
|
---|
[58563585] | 95 | &usb_device_descriptors(usb_dev)->device, &matches);
|
---|
[7b13d8e] | 96 | printf("%sDevice match ids (0x%04x by 0x%04x, %s)\n", get_indent(0),
|
---|
[e2dfa86] | 97 | usb_device_descriptors(usb_dev)->device.product_id,
|
---|
| 98 | usb_device_descriptors(usb_dev)->device.vendor_id,
|
---|
| 99 | usb_str_class(usb_device_descriptors(usb_dev)->device.device_class));
|
---|
[7b13d8e] | 100 | dump_match_ids(&matches, get_indent(1));
|
---|
| 101 | clean_match_ids(&matches);
|
---|
| 102 |
|
---|
[e2dfa86] | 103 | usb_dp_walk_simple(
|
---|
| 104 | usb_device_descriptors(usb_dev)->full_config,
|
---|
| 105 | usb_device_descriptors(usb_dev)->full_config_size,
|
---|
| 106 | usb_dp_standard_descriptor_nesting,
|
---|
[06f9a9c9] | 107 | dump_match_ids_from_interface, usb_dev);
|
---|
[3100ebe] | 108 | }
|
---|
| 109 |
|
---|
[e160da4d] | 110 | static void dump_descriptor_tree_brief_device(const char *prefix,
|
---|
| 111 | usb_standard_device_descriptor_t *descriptor)
|
---|
| 112 | {
|
---|
[8373f53] | 113 | printf("%sDevice (0x%04x by 0x%04x, %s, %zu configurations)\n", prefix,
|
---|
[e160da4d] | 114 | (int) descriptor->product_id,
|
---|
| 115 | (int) descriptor->vendor_id,
|
---|
[8373f53] | 116 | usb_str_class(descriptor->device_class),
|
---|
| 117 | (size_t) descriptor->configuration_count);
|
---|
[e160da4d] | 118 | }
|
---|
| 119 |
|
---|
| 120 | static void dump_descriptor_tree_brief_configuration(const char *prefix,
|
---|
| 121 | usb_standard_configuration_descriptor_t *descriptor)
|
---|
| 122 | {
|
---|
[eece178] | 123 | printf("%sConfiguration #%d (%zu interfaces, total %zuB)\n", prefix,
|
---|
[8373f53] | 124 | (int) descriptor->configuration_number,
|
---|
[eece178] | 125 | (size_t) descriptor->interface_count,
|
---|
| 126 | (size_t) descriptor->total_length);
|
---|
[e160da4d] | 127 | }
|
---|
| 128 |
|
---|
| 129 | static void dump_descriptor_tree_brief_interface(const char *prefix,
|
---|
| 130 | usb_standard_interface_descriptor_t *descriptor)
|
---|
| 131 | {
|
---|
[8373f53] | 132 | printf("%sInterface #%d (%s, 0x%02x, 0x%02x), alternate %d\n", prefix,
|
---|
[e160da4d] | 133 | (int) descriptor->interface_number,
|
---|
| 134 | usb_str_class(descriptor->interface_class),
|
---|
| 135 | (int) descriptor->interface_subclass,
|
---|
[8373f53] | 136 | (int) descriptor->interface_protocol,
|
---|
| 137 | (int) descriptor->alternate_setting);
|
---|
[e160da4d] | 138 | }
|
---|
| 139 |
|
---|
| 140 | static void dump_descriptor_tree_brief_endpoint(const char *prefix,
|
---|
| 141 | usb_standard_endpoint_descriptor_t *descriptor)
|
---|
| 142 | {
|
---|
| 143 | usb_endpoint_t endpoint_no = descriptor->endpoint_address & 0xF;
|
---|
| 144 | usb_transfer_type_t transfer = descriptor->attributes & 0x3;
|
---|
[3bacee1] | 145 | usb_direction_t direction = descriptor->endpoint_address & 0x80 ?
|
---|
| 146 | USB_DIRECTION_IN : USB_DIRECTION_OUT;
|
---|
[e160da4d] | 147 | printf("%sEndpoint #%d (%s %s, %zu)\n", prefix,
|
---|
| 148 | endpoint_no, usb_str_transfer_type(transfer),
|
---|
| 149 | direction == USB_DIRECTION_IN ? "in" : "out",
|
---|
| 150 | (size_t) descriptor->max_packet_size);
|
---|
| 151 | }
|
---|
| 152 |
|
---|
[7f70d1c] | 153 | static void dump_descriptor_tree_brief_superspeed_endpoint_companion(const char *prefix,
|
---|
| 154 | usb_superspeed_endpoint_companion_descriptor_t *descriptor)
|
---|
| 155 | {
|
---|
| 156 | printf("%sSuperspeed endpoint companion\n", prefix);
|
---|
| 157 | }
|
---|
| 158 |
|
---|
[8865087] | 159 | static void dump_descriptor_tree_brief_hid(const char *prefix,
|
---|
| 160 | usb_standard_hid_descriptor_t *descriptor)
|
---|
| 161 | {
|
---|
| 162 | printf("%sHID (country %d, %d descriptors)\n", prefix,
|
---|
| 163 | (int) descriptor->country_code,
|
---|
| 164 | (int) descriptor->class_desc_count);
|
---|
| 165 | }
|
---|
| 166 |
|
---|
[eece178] | 167 | static void dump_descriptor_tree_brief_hub(const char *prefix,
|
---|
| 168 | usb_hub_descriptor_header_t *descriptor)
|
---|
| 169 | {
|
---|
| 170 | printf("%shub (%d ports)\n", prefix,
|
---|
| 171 | (int) descriptor->port_count);
|
---|
| 172 | }
|
---|
| 173 |
|
---|
[8a121b1] | 174 | static void dump_descriptor_tree_callback(
|
---|
| 175 | const uint8_t *descriptor, size_t depth, void *arg)
|
---|
[e160da4d] | 176 | {
|
---|
[bf58895] | 177 | const char *indent = get_indent(depth + 1);
|
---|
[e160da4d] | 178 |
|
---|
| 179 | int descr_type = -1;
|
---|
| 180 | size_t descr_size = descriptor[0];
|
---|
| 181 | if (descr_size > 0) {
|
---|
| 182 | descr_type = descriptor[1];
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | switch (descr_type) {
|
---|
| 186 |
|
---|
| 187 | #define _BRANCH(type_enum, descriptor_type, callback) \
|
---|
| 188 | case type_enum: \
|
---|
| 189 | if (descr_size >= sizeof(descriptor_type)) { \
|
---|
| 190 | callback(indent, (descriptor_type *) descriptor); \
|
---|
[e387d0f] | 191 | if (arg != NULL) { \
|
---|
| 192 | usb_dump_standard_descriptor(stdout, \
|
---|
| 193 | get_indent(depth +2), "\n", \
|
---|
| 194 | descriptor, descr_size); \
|
---|
| 195 | } \
|
---|
[e160da4d] | 196 | } else { \
|
---|
| 197 | descr_type = -1; \
|
---|
| 198 | } \
|
---|
| 199 | break;
|
---|
| 200 |
|
---|
| 201 | _BRANCH(USB_DESCTYPE_DEVICE,
|
---|
| 202 | usb_standard_device_descriptor_t,
|
---|
| 203 | dump_descriptor_tree_brief_device);
|
---|
| 204 | _BRANCH(USB_DESCTYPE_CONFIGURATION,
|
---|
| 205 | usb_standard_configuration_descriptor_t,
|
---|
| 206 | dump_descriptor_tree_brief_configuration);
|
---|
| 207 | _BRANCH(USB_DESCTYPE_INTERFACE,
|
---|
| 208 | usb_standard_interface_descriptor_t,
|
---|
| 209 | dump_descriptor_tree_brief_interface);
|
---|
| 210 | _BRANCH(USB_DESCTYPE_ENDPOINT,
|
---|
| 211 | usb_standard_endpoint_descriptor_t,
|
---|
| 212 | dump_descriptor_tree_brief_endpoint);
|
---|
[7f70d1c] | 213 | _BRANCH(USB_DESCTYPE_SSPEED_EP_COMPANION,
|
---|
| 214 | usb_superspeed_endpoint_companion_descriptor_t,
|
---|
| 215 | dump_descriptor_tree_brief_superspeed_endpoint_companion);
|
---|
[8865087] | 216 | _BRANCH(USB_DESCTYPE_HID,
|
---|
| 217 | usb_standard_hid_descriptor_t,
|
---|
| 218 | dump_descriptor_tree_brief_hid);
|
---|
[eece178] | 219 | /*
|
---|
| 220 | * Probably useless, hub descriptor shall not be part of
|
---|
| 221 | * configuration descriptor.
|
---|
| 222 | */
|
---|
| 223 | _BRANCH(USB_DESCTYPE_HUB,
|
---|
| 224 | usb_hub_descriptor_header_t,
|
---|
| 225 | dump_descriptor_tree_brief_hub);
|
---|
[e160da4d] | 226 |
|
---|
[3bacee1] | 227 | default:
|
---|
| 228 | break;
|
---|
[e160da4d] | 229 | }
|
---|
| 230 |
|
---|
| 231 | if (descr_type == -1) {
|
---|
| 232 | printf("%sInvalid descriptor.\n", indent);
|
---|
| 233 | }
|
---|
| 234 | }
|
---|
| 235 |
|
---|
[06f9a9c9] | 236 | void dump_descriptor_tree_brief(usb_device_t *usb_dev)
|
---|
[e160da4d] | 237 | {
|
---|
[06f9a9c9] | 238 | dump_descriptor_tree_callback(
|
---|
[58563585] | 239 | (const uint8_t *) &usb_device_descriptors(usb_dev)->device,
|
---|
[bf58895] | 240 | (size_t) -1, NULL);
|
---|
[06f9a9c9] | 241 |
|
---|
[e2dfa86] | 242 | usb_dp_walk_simple(
|
---|
| 243 | usb_device_descriptors(usb_dev)->full_config,
|
---|
| 244 | usb_device_descriptors(usb_dev)->full_config_size,
|
---|
| 245 | usb_dp_standard_descriptor_nesting,
|
---|
[06f9a9c9] | 246 | dump_descriptor_tree_callback, NULL);
|
---|
[e160da4d] | 247 | }
|
---|
| 248 |
|
---|
[06f9a9c9] | 249 | void dump_descriptor_tree_full(usb_device_t *usb_dev)
|
---|
[e387d0f] | 250 | {
|
---|
[06f9a9c9] | 251 | dump_descriptor_tree_callback(
|
---|
[58563585] | 252 | (const uint8_t *) &usb_device_descriptors(usb_dev)->device,
|
---|
[06f9a9c9] | 253 | (size_t) -1, usb_dev);
|
---|
| 254 |
|
---|
[e2dfa86] | 255 | usb_dp_walk_simple(
|
---|
| 256 | usb_device_descriptors(usb_dev)->full_config,
|
---|
| 257 | usb_device_descriptors(usb_dev)->full_config_size,
|
---|
| 258 | usb_dp_standard_descriptor_nesting,
|
---|
[06f9a9c9] | 259 | dump_descriptor_tree_callback, usb_dev);
|
---|
[e387d0f] | 260 | }
|
---|
| 261 |
|
---|
[8a121b1] | 262 | static void find_string_indexes_callback(
|
---|
| 263 | const uint8_t *descriptor, size_t depth, void *arg)
|
---|
[e51a514] | 264 | {
|
---|
| 265 | size_t descriptor_length = descriptor[0];
|
---|
| 266 | if (descriptor_length <= 1) {
|
---|
| 267 | return;
|
---|
| 268 | }
|
---|
| 269 |
|
---|
| 270 | #define SET_STRING_INDEX(descr, mask, descr_type, descr_struct, descr_item) \
|
---|
| 271 | do { \
|
---|
| 272 | if ((descr)[1] == (descr_type)) { \
|
---|
| 273 | descr_struct *__type_descr = (descr_struct *) (descr); \
|
---|
| 274 | size_t __str_index = __type_descr->descr_item; \
|
---|
| 275 | if ((__str_index > 0) && (__str_index < 64)) { \
|
---|
| 276 | mask = (mask) | (1 << __str_index); \
|
---|
| 277 | } \
|
---|
| 278 | } \
|
---|
| 279 | } while (0)
|
---|
| 280 |
|
---|
| 281 | uint64_t *mask = arg;
|
---|
| 282 |
|
---|
| 283 | #define SET_STR(descr_type, descr_struct, descr_item) \
|
---|
| 284 | SET_STRING_INDEX(descriptor, (*mask), descr_type, descr_struct, descr_item)
|
---|
| 285 |
|
---|
| 286 | SET_STR(USB_DESCTYPE_DEVICE, usb_standard_device_descriptor_t,
|
---|
| 287 | str_manufacturer);
|
---|
| 288 | SET_STR(USB_DESCTYPE_DEVICE, usb_standard_device_descriptor_t,
|
---|
| 289 | str_product);
|
---|
| 290 | SET_STR(USB_DESCTYPE_DEVICE, usb_standard_device_descriptor_t,
|
---|
| 291 | str_serial_number);
|
---|
| 292 | SET_STR(USB_DESCTYPE_CONFIGURATION, usb_standard_configuration_descriptor_t,
|
---|
| 293 | str_configuration);
|
---|
| 294 | SET_STR(USB_DESCTYPE_INTERFACE, usb_standard_interface_descriptor_t,
|
---|
| 295 | str_interface);
|
---|
| 296 | }
|
---|
| 297 |
|
---|
[06f9a9c9] | 298 | void dump_strings(usb_device_t *usb_dev)
|
---|
[aad3587] | 299 | {
|
---|
[d1582b50] | 300 | /* Find used indexes. Devices with more than 64 strings are very rare. */
|
---|
[b25199bc] | 301 | uint64_t str_mask = 0;
|
---|
[06f9a9c9] | 302 | find_string_indexes_callback(
|
---|
[58563585] | 303 | (const uint8_t *) &usb_device_descriptors(usb_dev)->device, 0,
|
---|
[b25199bc] | 304 | &str_mask);
|
---|
[06f9a9c9] | 305 |
|
---|
[e2dfa86] | 306 | usb_dp_walk_simple(
|
---|
| 307 | usb_device_descriptors(usb_dev)->full_config,
|
---|
| 308 | usb_device_descriptors(usb_dev)->full_config_size,
|
---|
| 309 | usb_dp_standard_descriptor_nesting,
|
---|
[06f9a9c9] | 310 | find_string_indexes_callback, &str_mask);
|
---|
[b25199bc] | 311 |
|
---|
| 312 | if (str_mask == 0) {
|
---|
| 313 | printf("Device does not support string descriptors.\n");
|
---|
| 314 | return;
|
---|
| 315 | }
|
---|
| 316 |
|
---|
[aad3587] | 317 | /* Get supported languages. */
|
---|
| 318 | l18_win_locales_t *langs;
|
---|
| 319 | size_t langs_count;
|
---|
[5a6cc679] | 320 | errno_t rc = usb_request_get_supported_languages(
|
---|
[06f9a9c9] | 321 | usb_device_get_default_pipe(usb_dev), &langs, &langs_count);
|
---|
[aad3587] | 322 | if (rc != EOK) {
|
---|
| 323 | fprintf(stderr,
|
---|
| 324 | NAME ": failed to get list of supported languages: %s.\n",
|
---|
| 325 | str_error(rc));
|
---|
| 326 | return;
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | printf("%sString languages (%zu):", get_indent(0), langs_count);
|
---|
| 330 | size_t i;
|
---|
| 331 | for (i = 0; i < langs_count; i++) {
|
---|
| 332 | printf(" 0x%04x", (int) langs[i]);
|
---|
| 333 | }
|
---|
| 334 | printf(".\n");
|
---|
| 335 |
|
---|
| 336 | /* Get all strings and dump them. */
|
---|
| 337 | for (i = 0; i < langs_count; i++) {
|
---|
| 338 | l18_win_locales_t lang = langs[i];
|
---|
| 339 |
|
---|
[b8e2f93] | 340 | printf("%sStrings in %s:\n", get_indent(0),
|
---|
| 341 | str_l18_win_locale(lang));
|
---|
[e51a514] | 342 |
|
---|
[aad3587] | 343 | size_t idx;
|
---|
[e51a514] | 344 | for (idx = 1; idx < 64; idx++) {
|
---|
| 345 | if ((str_mask & ((uint64_t)1 << idx)) == 0) {
|
---|
| 346 | continue;
|
---|
| 347 | }
|
---|
| 348 | char *string = NULL;
|
---|
[06f9a9c9] | 349 | rc = usb_request_get_string(
|
---|
| 350 | usb_device_get_default_pipe(usb_dev), idx, lang,
|
---|
[aad3587] | 351 | &string);
|
---|
[e51a514] | 352 | if ((rc != EOK) && (rc != EEMPTY)) {
|
---|
| 353 | printf("%sWarn: failed to retrieve string #%zu: %s.\n",
|
---|
| 354 | get_indent(1), idx, str_error(rc));
|
---|
[aad3587] | 355 | continue;
|
---|
| 356 | }
|
---|
| 357 | printf("%sString #%zu: \"%s\"\n", get_indent(1),
|
---|
[e51a514] | 358 | idx, rc == EOK ? string : "");
|
---|
| 359 | if (string != NULL) {
|
---|
| 360 | free(string);
|
---|
| 361 | }
|
---|
[aad3587] | 362 | }
|
---|
| 363 | }
|
---|
| 364 | }
|
---|
| 365 |
|
---|
[06f9a9c9] | 366 | void dump_status(usb_device_t *usb_dev)
|
---|
[cb61e8f] | 367 | {
|
---|
[5a6cc679] | 368 | errno_t rc;
|
---|
[7d20461] | 369 | uint16_t status = 0;
|
---|
[cb61e8f] | 370 |
|
---|
| 371 | /* Device status first. */
|
---|
[06f9a9c9] | 372 | rc = usb_request_get_status(usb_device_get_default_pipe(usb_dev),
|
---|
[7d20461] | 373 | USB_REQUEST_RECIPIENT_DEVICE, 0, &status);
|
---|
[cb61e8f] | 374 | if (rc != EOK) {
|
---|
| 375 | printf("%sFailed to get device status: %s.\n",
|
---|
| 376 | get_indent(0), str_error(rc));
|
---|
[7d20461] | 377 | } else {
|
---|
| 378 | printf("%sDevice status 0x%04x: power=%s, remote-wakeup=%s.\n",
|
---|
| 379 | get_indent(0), status,
|
---|
| 380 | status & USB_DEVICE_STATUS_SELF_POWERED ? "self" : "bus",
|
---|
| 381 | status & USB_DEVICE_STATUS_REMOTE_WAKEUP ? "yes" : "no");
|
---|
[cb61e8f] | 382 | }
|
---|
| 383 |
|
---|
| 384 | /* Interface is not interesting, skipping ;-). */
|
---|
| 385 |
|
---|
| 386 | /* Control endpoint zero. */
|
---|
[7d20461] | 387 | status = 0;
|
---|
[06f9a9c9] | 388 | rc = usb_request_get_status(usb_device_get_default_pipe(usb_dev),
|
---|
[7d20461] | 389 | USB_REQUEST_RECIPIENT_ENDPOINT, 0, &status);
|
---|
[cb61e8f] | 390 | if (rc != EOK) {
|
---|
| 391 | printf("%sFailed to get control endpoint status: %s.\n",
|
---|
| 392 | get_indent(0), str_error(rc));
|
---|
[7d20461] | 393 | } else {
|
---|
| 394 | printf("%sControl endpoint zero status %04X: halted=%s.\n",
|
---|
| 395 | get_indent(0), status,
|
---|
| 396 | status & USB_ENDPOINT_STATUS_HALTED ? "yes" : "no");
|
---|
[cb61e8f] | 397 | }
|
---|
| 398 | }
|
---|
| 399 |
|
---|
[c377bc50] | 400 | /** @}
|
---|
| 401 | */
|
---|