Some USB devices fail if a string is requested with language id 0. So read the langid from string descriptor 0 first.
comments? ok? Index: Makefile =================================================================== RCS file: /cvs/ports/sysutils/usbutil/Makefile,v retrieving revision 1.15 diff -u -r1.15 Makefile --- Makefile 15 Sep 2007 21:14:03 -0000 1.15 +++ Makefile 15 Dec 2007 00:01:14 -0000 @@ -3,6 +3,7 @@ COMMENT= USB developer utilities DISTNAME= usbutil-0.5 +PKGNAME= ${DISTNAME}p0 CATEGORIES= sysutils MASTER_SITES= ftp://ftp.augustsson.net/pub/netbsd/ Index: patches/patch-usbctl_c =================================================================== RCS file: patches/patch-usbctl_c diff -N patches/patch-usbctl_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-usbctl_c 15 Dec 2007 00:01:14 -0000 @@ -0,0 +1,47 @@ +$OpenBSD$ +--- usbctl.c.orig Mon Feb 25 01:50:55 2002 ++++ usbctl.c Sat Dec 15 00:55:00 2007 +@@ -65,12 +65,33 @@ + + int num = 0; + +-static int usbf, usbaddr; ++static int usbf, usbaddr, langid; + void + setupstrings(int f, int addr) + { ++ struct usb_ctl_request req; ++ int r; ++ usb_string_descriptor_t us; ++ + usbf = f; + usbaddr = addr; ++ ++ req.ucr_addr = usbaddr; ++ req.ucr_request.bmRequestType = UT_READ_DEVICE; ++ req.ucr_request.bRequest = UR_GET_DESCRIPTOR; ++ req.ucr_data = &us; ++ USETW2(req.ucr_request.wValue, UDESC_STRING, 0); ++ USETW(req.ucr_request.wIndex, 0); ++ USETW(req.ucr_request.wLength, 4); ++ req.ucr_flags = 0; ++ ++ r = ioctl(usbf, USB_REQUEST, &req); ++ if (r < 0) { ++ fprintf(stderr, "get langid failed (error=%d)\n", errno); ++ langid = 0; ++ } else { ++ langid = UGETW(us.bString[0]); ++ } + } + + void +@@ -90,7 +111,7 @@ getstring(int si, char *s) + req.ucr_request.bRequest = UR_GET_DESCRIPTOR; + req.ucr_data = &us; + USETW2(req.ucr_request.wValue, UDESC_STRING, si); +- USETW(req.ucr_request.wIndex, 0); ++ USETW(req.ucr_request.wIndex, langid); + #ifdef NSTRINGS + USETW(req.ucr_request.wLength, sizeof(usb_string_descriptor_t)); + req.ucr_flags = USBD_SHORT_XFER_OK;