Changeset c9d5577 in mainline


Ignore:
Timestamp:
2011-01-14T14:55:19Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ff8ed06
Parents:
4989d73
Message:

`usbinfo' dumps interface descriptor nicely

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/usbinfo/dump.c

    r4989d73 rc9d5577  
    4343#include <usb/usb.h>
    4444#include <usb/descriptor.h>
     45#include <usb/classes/classes.h>
    4546
    4647#include "usbinfo.h"
     
    4849
    4950#define INDENT "  "
    50 #define PRINTLINE(indent, fmt, ...) printf("%s" fmt, get_indent(indent), __VA_ARGS__)
     51#define PRINTLINE(indent, fmt, ...) printf("%s - " fmt, get_indent(indent), __VA_ARGS__)
    5152#define BYTES_PER_LINE 12
    5253
     
    200201void dump_descriptor_interface(size_t indent, uint8_t *descr, size_t size)
    201202{
    202         dump_descriptor_generic(indent, descr, size);
     203        usb_standard_interface_descriptor_t *d
     204            = (usb_standard_interface_descriptor_t *) descr;
     205        if (size != sizeof(*d)) {
     206                return;
     207        }
     208       
     209        PRINTLINE(indent, "bLength = %d\n", d->length);
     210        PRINTLINE(indent, "bDescriptorType = 0x%02x\n", d->descriptor_type);
     211        PRINTLINE(indent, "bInterfaceNumber = %d\n", d->interface_number);
     212        PRINTLINE(indent, "bAlternateSetting = %d\n", d->alternate_setting);
     213        PRINTLINE(indent, "bNumEndpoints = %d\n", d->endpoint_count);
     214        PRINTLINE(indent, "bInterfaceClass = %s\n", d->interface_class == 0
     215            ? "reserved (0)" : usb_str_class(d->interface_class));
     216        PRINTLINE(indent, "bInterfaceSubClass = %d\n", d->interface_subclass);
     217        PRINTLINE(indent, "bInterfaceProtocol = %d\n", d->interface_protocol);
     218        PRINTLINE(indent, "iInterface = %d\n", d->str_interface);
    203219}
    204220
     
    212228        usb_standard_endpoint_descriptor_t *d
    213229           = (usb_standard_endpoint_descriptor_t *) descr;
     230        if (size != sizeof(*d)) {
     231                return;
     232        }
    214233       
    215234        int endpoint = d->endpoint_address & 15;
Note: See TracChangeset for help on using the changeset viewer.