From owner-freebsd-usb@FreeBSD.ORG Tue Jun 30 20:11:36 2009 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E365106564A for ; Tue, 30 Jun 2009 20:11:36 +0000 (UTC) (envelope-from bsdfan@nurfuerspam.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id 7CDE88FC0C for ; Tue, 30 Jun 2009 20:11:35 +0000 (UTC) (envelope-from bsdfan@nurfuerspam.de) Received: (qmail invoked by alias); 30 Jun 2009 20:11:34 -0000 Received: from dslb-092-073-081-027.pools.arcor-ip.net (EHLO [192.168.1.100]) [92.73.81.27] by mail.gmx.net (mp066) with SMTP; 30 Jun 2009 22:11:34 +0200 X-Authenticated: #931807 X-Provags-ID: V01U2FsdGVkX1+XR4V4TQiXP09nUOA0AKXipiZMHai44rIoyow2Wx qbJVxJ49uhNnvz Message-ID: <4A4A7183.2060700@nurfuerspam.de> Date: Tue, 30 Jun 2009 22:11:47 +0200 From: Markus Dolze User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: freebsd-usb@freebsd.org References: <4A4A5D7E.70708@nurfuerspam.de> In-Reply-To: <4A4A5D7E.70708@nurfuerspam.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.47 Subject: Re: Failing controls transfers in VMware X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jun 2009 20:11:36 -0000 Markus Dolze wrote: > To repeat run the attached program: > > 1. Fill in some vendor / product ID of a device detected as ugen device > 2. Compile and run the code (devel/libusb must be installed). > > The result will look like this: > > The mailing list didn't send the attachment. Here is the code, put together from different example programs: /* * A program to test USB control messages */ #include #include #include #define USBASP_SHARED_VID 0x16C0 #define USBASP_SHARED_PID 0x05DC #define TIMEOUT 5000 #define LANGID 0x0409 /* english */ char* usbStringToAscii(char *buffer, int len) { char buf[256]; int i; printf("%02x %02x\n", buffer[0], buffer[1]); if(buffer[1] != USB_DT_STRING){ *buf = 0; return 0; } if((unsigned char)buffer[0] < len) len = (unsigned char)buffer[0]; len /= 2; /* lossy conversion to ISO Latin1: */ for(i=1;i sizeof(buf)) /* destination buffer overflow */ break; buf[i-1] = buffer[2 * i]; if(buffer[2 * i + 1] != 0) /* outside of ISO Latin1 range */ buf[i-1] = '?'; } buf[i-1] = 0; return strdup(buf); } int main(int argc, char *argv[]) { struct usb_bus *bus; struct usb_device *dev; usb_dev_handle *handle = NULL; char string[255]; int len; usb_init(); usb_find_busses(); usb_find_devices(); for(bus = usb_get_busses(); bus; bus = bus->next) { for(dev = bus->devices; dev; dev = dev->next) { if((dev->descriptor.idVendor == USBASP_SHARED_VID && dev->descriptor.idProduct == USBASP_SHARED_PID) { printf("Found AVR-USB device\n"); handle = usb_open(dev); if(!handle) { printf("Warning: cannot open USB device: %s\n", usb_strerror()); continue; } memset(string, 0, sizeof(string)); len = usb_control_msg(handle, USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) + dev->descriptor.iManufacturer, LANGID, string, sizeof(string), TIMEOUT); printf("USB_control_msg result: %d\n", len); if(len < 0) printf("Warning: cannot query manufacturer for device: %s\n", usb_strerror()); else printf("Found device from vendor: %s\n", usbStringToAscii(string, len)); memset(string, 0, sizeof(string)); len = usb_control_msg(handle, USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) + dev->descriptor.iProduct, LANGID, string, sizeof(string), TIMEOUT); printf("USB_control_msg result: %d\n", len); if(len < 0) printf("Warning: cannot query product: %s\n", usb_strerror()); else printf("Found device: %s\n", usbStringToAscii(string, len)); usb_close(handle); handle = NULL; } } } return 0; }