#include #include #include #include #include #include #include #include #include #include void hexdump(unsigned char *p, int len) { int i, a; a = 0; while (len > 0) { printf("%04x ", a); for (i = 0; i < 16; i++) { if (i < len) printf(" %02x", p[i]); else printf(" "); if (i == 7) printf(" "); } printf(" "); for (i = 0; i < 16; i++) { if (i >= len) printf(" "); else if (p[i] >= 0x20 && p[i] < 0x80) printf("%c", p[i]); else printf("."); } printf("\n"); a += 16; p += 16; len -= 16; } } int main(int argc, char **argv) { char *ugendev; int ctlpipe, outpipe, inpipe, intrpipe; char buf[100]; int i, n; struct usb_ctl_request ur; struct scsi_inquiry inq; if (argc < 2) errx(1, "Usage: %s []", argv[0]); ugendev = argv[1]; snprintf(buf, sizeof(buf), "%s", ugendev); if ((ctlpipe = open(buf, O_RDWR)) < 0) err(1, "%s: open", buf); i = 1; if (argc > 2) i = atoi(argv[2]); if (ioctl(ctlpipe, USB_SET_TIMEOUT, &i) < 0) err(1, "USB_SET_TIMEOUT"); bzero(&ur, sizeof(ur)); ur.ucr_addr = 0; ur.ucr_request.bmRequestType = UT_WRITE_ENDPOINT; ur.ucr_request.bRequest = UR_CLEAR_FEATURE; USETW(ur.ucr_request.wValue, UF_ENDPOINT_HALT); USETW(ur.ucr_request.wIndex, 0); USETW(ur.ucr_request.wLength, 0); ur.ucr_data = buf; ur.ucr_flags = 0; ur.ucr_actlen = 0; if (ioctl(ctlpipe, USB_DO_REQUEST, &ur) < 0) err(1, "USB_DO_REQUEST"); hexdump(buf, 0); }