Changeset e9c02b7 in mainline


Ignore:
Timestamp:
2011-06-17T20:42:13Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
051f96b
Parents:
dec55ce
Message:

More human-readable HID report printing

Location:
uspace/app/usbinfo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/usbinfo/Makefile

    rdec55ce re9c02b7  
    3131
    3232LIBS = \
     33        $(LIBUSBHID_PREFIX)/libusbhid.a \
    3334        $(LIBUSBDEV_PREFIX)/libusbdev.a \
    3435        $(LIBUSB_PREFIX)/libusb.a \
     
    3738        -I$(LIBUSB_PREFIX)/include \
    3839        -I$(LIBUSBDEV_PREFIX)/include \
     40        -I$(LIBUSBHID_PREFIX)/include \
    3941        -I$(LIBDRV_PREFIX)/include
    4042
  • uspace/app/usbinfo/hid.c

    rdec55ce re9c02b7  
    3838#include <usb/classes/classes.h>
    3939#include <usb/dev/request.h>
     40#include <usb/hid/hidparser.h>
    4041#include <errno.h>
    4142#include "usbinfo.h"
     
    8485}
    8586
     87/** Dumps HID report in pseudo human-readable format.
     88 *
     89 * @param iface_no USB interface the report belongs to.
     90 * @param report Parsed report descriptor.
     91 */
     92static void dump_hid_report_brief(int iface_no, usb_hid_report_t *report)
     93{
     94        printf("%sParsed HID report descriptor for interface %d\n",
     95            get_indent(0), iface_no);
     96        list_foreach(report->reports, report_it) {
     97                usb_hid_report_description_t *description = list_get_instance(report_it, usb_hid_report_description_t, link);
     98                printf("%sReport %d (type %d)\n", get_indent(1),
     99                    (int) description->report_id,
     100                    (int) description->type);
     101                list_foreach(description->report_items, item_it) {
     102                        usb_hid_report_field_t *field = list_get_instance(item_it, usb_hid_report_field_t, link);
     103                        printf("%sUsage page = 0x%04x    Usage = 0x%04x\n",
     104                            get_indent(2),
     105                            (int) field->usage_page, (int) field->usage);
     106                }
     107        }
     108}
     109
    86110/** Retrieves HID report from given USB device and dumps it.
    87111 *
     
    115139        }
    116140
     141        usb_hid_report_t report;
     142        rc = usb_hid_parse_report_descriptor(&report, raw_report, report_size);
     143        if (rc != EOK) {
     144                usb_log_error("Failed to part report descriptor: %s.\n",
     145                    str_error(rc));
     146        }
     147
    117148        dump_hid_report_raw(iface_no, raw_report, report_size);
     149        dump_hid_report_brief(iface_no, &report);
    118150
    119151        free(raw_report);
     152        usb_hid_free_report(&report);
    120153}
    121154
Note: See TracChangeset for help on using the changeset viewer.