Changeset 051f96b in mainline


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

Another option for usbinfo

Location:
uspace/app/usbinfo
Files:
3 edited

Legend:

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

    re9c02b7 r051f96b  
    4444#define BYTES_PER_LINE 20
    4545
     46typedef enum {
     47        HID_DUMP_RAW,
     48        HID_DUMP_USAGES
     49} hid_dump_type_t;
     50
    4651typedef struct {
    4752        usbinfo_device_t *dev;
     53        hid_dump_type_t dump_type;
    4854        usb_standard_interface_descriptor_t *last_iface;
    4955} descriptor_walk_context_t;
     
    8591}
    8692
    87 /** Dumps HID report in pseudo human-readable format.
     93/** Dumps usages in HID report.
    8894 *
    8995 * @param iface_no USB interface the report belongs to.
    9096 * @param report Parsed report descriptor.
    9197 */
    92 static void dump_hid_report_brief(int iface_no, usb_hid_report_t *report)
     98static void dump_hid_report_usages(int iface_no, usb_hid_report_t *report)
    9399{
    94100        printf("%sParsed HID report descriptor for interface %d\n",
     
    110116/** Retrieves HID report from given USB device and dumps it.
    111117 *
     118 * @param dump_type In which format to dump the report.
    112119 * @param ctrl_pipe Default control pipe to the device.
    113120 * @param iface_no Interface number.
    114121 * @param report_size Size of the report descriptor.
    115122 */
    116 static void retrieve_and_dump_hid_report(usb_pipe_t *ctrl_pipe,
    117     uint8_t iface_no, size_t report_size)
     123static void retrieve_and_dump_hid_report(hid_dump_type_t dump_type,
     124    usb_pipe_t *ctrl_pipe, uint8_t iface_no, size_t report_size)
    118125{
    119126        assert(report_size > 0);
     
    146153        }
    147154
    148         dump_hid_report_raw(iface_no, raw_report, report_size);
    149         dump_hid_report_brief(iface_no, &report);
     155        switch (dump_type) {
     156        case HID_DUMP_RAW:
     157                dump_hid_report_raw(iface_no, raw_report, report_size);
     158                break;
     159        case HID_DUMP_USAGES:
     160                dump_hid_report_usages(iface_no, &report);
     161                break;
     162        default:
     163                assert(false && "unreachable code apparently reached");
     164        }
    150165
    151166        free(raw_report);
     
    195210        }
    196211
    197         retrieve_and_dump_hid_report(&context->dev->ctrl_pipe,
    198             context->last_iface->interface_number, report_size);
    199 }
    200 
    201 
    202 void dump_hidreport(usbinfo_device_t *dev)
     212        retrieve_and_dump_hid_report(context->dump_type,
     213            &context->dev->ctrl_pipe, context->last_iface->interface_number,
     214            report_size);
     215}
     216
     217
     218void dump_hidreport_raw(usbinfo_device_t *dev)
    203219{
    204220        descriptor_walk_context_t context = {
    205221                .dev = dev,
     222                .dump_type = HID_DUMP_RAW,
    206223                .last_iface = NULL
    207224        };
     
    213230}
    214231
     232void dump_hidreport_usages(usbinfo_device_t *dev)
     233{
     234        descriptor_walk_context_t context = {
     235                .dev = dev,
     236                .dump_type = HID_DUMP_USAGES,
     237                .last_iface = NULL
     238        };
     239
     240        usb_dp_walk_simple(dev->full_configuration_descriptor,
     241            dev->full_configuration_descriptor_size,
     242            usb_dp_standard_descriptor_nesting,
     243            descriptor_walk_callback, &context);
     244}
     245
    215246/** @}
    216247 */
  • uspace/app/usbinfo/main.c

    re9c02b7 r051f96b  
    6868        _OPTION("-S --status", "Get status of the device.");
    6969        _OPTION("-r --hid-report", "Dump HID report descriptor.");
     70        _OPTION("-r --hid-report-usages", "Dump usages of HID report.");
    7071
    7172        printf("\n");
     
    8687        {"status", no_argument, NULL, 'S'},
    8788        {"hid-report", no_argument, NULL, 'r'},
     89        {"hid-report-usages", no_argument, NULL, 'R'},
    8890        {0, 0, NULL, 0}
    8991};
    90 static const char *short_options = "himtTsSr";
     92static const char *short_options = "himtTsSrR";
    9193
    9294static usbinfo_action_t actions[] = {
     
    123125        {
    124126                .opt = 'r',
    125                 .action = dump_hidreport,
     127                .action = dump_hidreport_raw,
     128                .active = false
     129        },
     130        {
     131                .opt = 'R',
     132                .action = dump_hidreport_usages,
    126133                .active = false
    127134        },
  • uspace/app/usbinfo/usbinfo.h

    re9c02b7 r051f96b  
    8585void dump_strings(usbinfo_device_t *);
    8686void dump_status(usbinfo_device_t *);
    87 void dump_hidreport(usbinfo_device_t *);
     87void dump_hidreport_raw(usbinfo_device_t *);
     88void dump_hidreport_usages(usbinfo_device_t *);
    8889
    8990
Note: See TracChangeset for help on using the changeset viewer.