tools/atrf-id/atrf-id.c |
112 | 112 | } |
113 | 113 | |
114 | 114 | |
| 115 | static void do_dump_debug(struct atrf_dsc *dsc) |
| 116 | { |
| 117 | usb_dev_handle *dev; |
| 118 | uint8_t buf[1024]; |
| 119 | int res; |
| 120 | struct log { |
| 121 | uint16_t n; |
| 122 | uint8_t bmRequestType; |
| 123 | uint8_t bRequest; |
| 124 | uint16_t wValue; |
| 125 | uint16_t wIndex; |
| 126 | uint16_t wLength; |
| 127 | } *p; |
| 128 | |
| 129 | dev = atrf_usb_handle(dsc); |
| 130 | if (!dev) |
| 131 | return; |
| 132 | |
| 133 | res = usb_control_msg(dev, FROM_DEV, ATUSB_READ_LOG, 0, 0, |
| 134 | (void *) buf, sizeof(buf), 1000); |
| 135 | if (res < 0) { |
| 136 | fprintf(stderr, "ATUSB_READ_LOG: %s\n", usb_strerror()); |
| 137 | return; |
| 138 | } |
| 139 | |
| 140 | printf("Number\tbmRequestType\tbRequest\twValue\twIndex\twLength\n"); |
| 141 | for (p = (void *) buf; (uint8_t *) (p+1) <= buf+res; p++) { |
| 142 | printf("%u\t", p->n); |
| 143 | printf("0x%02x\t\t", p->bmRequestType); |
| 144 | printf("0x%02x\t\t", p->bRequest); |
| 145 | printf("0x%04x\t", p->wValue); |
| 146 | printf("0x%04x\t", p->wIndex); |
| 147 | printf("0x%04x\n", p->wLength); |
| 148 | |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | |
115 | 153 | #else /* HAVE_USB */ |
116 | 154 | |
117 | 155 | |
... | ... | |
120 | 158 | } |
121 | 159 | |
122 | 160 | |
| 161 | static void do_dump_debug(struct atrf_dsc *dsc) |
| 162 | { |
| 163 | } |
| 164 | |
| 165 | |
123 | 166 | #endif /* !HAVE_USB */ |
124 | 167 | |
125 | 168 | |
... | ... | |
161 | 204 | fprintf(stderr, |
162 | 205 | "usage: %s [-d driver[:arg]] [-s [-s]]\n\n" |
163 | 206 | " -d driver[:arg] use the specified driver (default: %s)\n" |
| 207 | " -D dump atusb debug buffer\n" |
164 | 208 | " -s print only the local driver specification\n" |
165 | 209 | " -s -s print only the remote driver specification\n" |
166 | 210 | , name, atrf_default_driver_name()); |
... | ... | |
173 | 217 | const char *driver = NULL; |
174 | 218 | struct atrf_dsc *dsc; |
175 | 219 | int spec_only = 0; |
| 220 | int dump_debug = 0; |
176 | 221 | int c; |
177 | 222 | |
178 | | while ((c = getopt(argc, argv, "d:s")) != EOF) |
| 223 | while ((c = getopt(argc, argv, "d:Ds")) != EOF) |
179 | 224 | switch (c) { |
180 | 225 | case 'd': |
181 | 226 | driver = optarg; |
182 | 227 | break; |
| 228 | case 'D': |
| 229 | dump_debug = 1; |
| 230 | break; |
183 | 231 | case 's': |
184 | 232 | spec_only++; |
185 | 233 | break; |
... | ... | |
205 | 253 | } else { |
206 | 254 | show_info(dsc); |
207 | 255 | } |
| 256 | if (dump_debug) |
| 257 | do_dump_debug(dsc); |
208 | 258 | |
209 | 259 | atrf_close(dsc); |
210 | 260 | |