From owner-freebsd-usb@FreeBSD.ORG Mon Jun 8 17:38:18 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 8DF59106566B for ; Mon, 8 Jun 2009 17:38:18 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe04.swip.net [212.247.154.97]) by mx1.freebsd.org (Postfix) with ESMTP id 21A918FC12 for ; Mon, 8 Jun 2009 17:38:17 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=W-YcfUTv09kA:10 a=1qBssEImBScA:10 a=MXw7gxVQKqGXY79tIT8aFQ==:17 a=6JYyhQExQF3KtNFEpkYA:9 a=uMqWIRWS66zg22fMVdjJp7ZUzy4A:4 Received: from [62.113.132.61] (account mc467741@c2i.net HELO laptop.adsl.tele2.no) by mailfe04.swip.net (CommuniGate Pro SMTP 5.2.13) with ESMTPA id 1255552234; Mon, 08 Jun 2009 19:38:16 +0200 From: Hans Petter Selasky To: Jack Twilley Date: Mon, 8 Jun 2009 19:42:24 +0200 User-Agent: KMail/1.11.4 (FreeBSD/8.0-CURRENT; KDE/4.2.4; i386; ; ) References: <4A2B29C0.7020709@twilley.org> <200906080030.53822.hselasky@c2i.net> <4A2D47FF.8040209@twilley.org> In-Reply-To: <4A2D47FF.8040209@twilley.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200906081942.26220.hselasky@c2i.net> Cc: freebsd-usb@freebsd.org Subject: Re: How to retrieve iManufacturer/iProduct information from libusb20? 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: Mon, 08 Jun 2009 17:38:18 -0000 On Monday 08 June 2009 19:18:55 Jack Twilley wrote: > Hans Petter Selasky wrote: > > On Sunday 07 June 2009 04:45:20 Jack Twilley > > > > wrote: > >> I have been looking through the source to > > > > usbconfig and other tools > > > >> trying to figure out how to retrieve the > > > > iManufacturer and iProduct > > > >> strings. The libusb20 man page describes the > >> libusb20_dev_get_device_desc() function but > > > > there's no useful > > > >> information on the struct it returns. The > > > > include file looks as if the > > > >> struct is automagically generated by macros > > > > within macros which is too > > > >> complicated for me to figure out without > > > > help. Any ideas? There's > > > >> gotta be a better way than using > > > > LIBUSB20_DEVICE_DESC()... > > > > After you find the string index, you can use the > > following function to get strings: > > > > int > > libusb20_dev_req_string_simple_sync(struct > > libusb20_device *pdev, > > uint8_t index, void *ptr, uint16_t len); > > Finding the string index was harder than I expected, since I can't get > anything useful out of what libusb20_dev_get_device_desc() returns. > Heck, I even tried a short for loop from 0 to 15 just to see if the > values I saw in usbconfig were magic values pointing to the string. > > How do I find the string index? > struct LIBUSB20_DEVICE_DESC_DECODED *pdesc; pdesc = libusb20_dev_get_device_desc(pdev); printf("Vendor string is %u\n", pdesc->iVendor); if zero, the string is not present. --HPS