Changeset dec55ce in mainline for uspace/app/usbinfo/hid.c
- Timestamp:
- 2011-06-17T20:32:22Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e9c02b7
- Parents:
- 54d4b9e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/hid.c
r54d4b9e rdec55ce 61 61 } 62 62 63 /** Dumps HID report in raw format. 64 * 65 * @param iface_no USB interface the report belongs to. 66 * @param report Report descriptor. 67 * @param size Size of the @p report in bytes. 68 */ 69 static void dump_hid_report_raw(int iface_no, uint8_t *report, size_t size) 70 { 71 printf("%sHID report descriptor for interface %d", get_indent(0), 72 iface_no); 73 for (size_t i = 0; i < size; i++) { 74 size_t line_idx = i % BYTES_PER_LINE; 75 if (line_idx == 0) { 76 printf("\n%s", get_indent(1)); 77 } 78 printf("%02X", (int) report[i]); 79 if (line_idx + 1 < BYTES_PER_LINE) { 80 printf(" "); 81 } 82 } 83 printf("\n"); 84 } 85 63 86 /** Retrieves HID report from given USB device and dumps it. 64 87 * … … 72 95 assert(report_size > 0); 73 96 74 uint8_t *r eport = malloc(report_size);75 if (r eport == NULL) {97 uint8_t *raw_report = malloc(report_size); 98 if (raw_report == NULL) { 76 99 usb_log_warning( 77 100 "Failed to allocate %zuB, skipping interface %d.\n", … … 84 107 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_INTERFACE, 85 108 USB_DESCTYPE_HID_REPORT, 0, iface_no, 86 r eport, report_size, &actual_report_size);109 raw_report, report_size, &actual_report_size); 87 110 if (rc != EOK) { 88 111 usb_log_error("Failed to retrieve HID report descriptor: %s.\n", 89 112 str_error(rc)); 90 free(r eport);113 free(raw_report); 91 114 return; 92 115 } 93 116 94 printf("%sHID report descriptor for interface %d", get_indent(0), 95 (int) iface_no); 96 for (size_t i = 0; i < report_size; i++) { 97 size_t line_idx = i % BYTES_PER_LINE; 98 if (line_idx == 0) { 99 printf("\n%s", get_indent(1)); 100 } 101 printf("%02X", (int) report[i]); 102 if (line_idx + 1 < BYTES_PER_LINE) { 103 printf(" "); 104 } 105 } 106 printf("\n"); 117 dump_hid_report_raw(iface_no, raw_report, report_size); 107 118 108 free(r eport);119 free(raw_report); 109 120 } 110 121
Note:
See TracChangeset
for help on using the changeset viewer.