Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: general OS X user-space GET_DESCRIPTOR device request?



At 9:26 PM +0000 3/15/02, hotblack wrote:

IOUSBLib has nice friendly calls such as GetDevice<whatever> but what about more generalised usage of bRequest fields for obtaining other info. Using the example of USBGetManufacturerStringIndex, how can you, in the user-space, issue a GET_DESCRIPTOR call to retrieve the relevant info, specifying the bRequest, wValue, wIndex fields etc. I guess you'd use something along the lines of kUSBRqGetDescriptor (or kUSBRqGetStatus or whatever) I'm just not entirely sure how to do this, or if ot's possible to, from the user-space in

Nano has mentioned which API to use, if you're confused about what the parameters should be, this is documented in the USB spec, chapter 9.


9.4.3 Get Descriptor

bmRequestType bRequest       wValue       wIndex       wLength     Data
10000000B     GET_DESCRIPTOR Descriptor   Zero or      Descriptor  Desc
                             Type and     Language ID  Length
                             Descriptor   (refer to
                             Index        Section 9.6.7)

So in the param structure:

typedef struct {
UInt8 bmRequestType; 0x80 (10000000B)
UInt8 bRequest; kUSBRqGetDescriptor (GET_DESCRIPTOR)
UInt16 wValue; (kUSBStringDesc<<8)+index
UInt16 wIndex; 0x409 (English)
UInt16 wLength; void * pData; // data pointer
UInt32 wLenDone; // # bytes transferred
} IOUSBDevRequest;


bRequest is defined in table 9-4, kUSBRqGetDescriptor is in USBSpec.h.

The index mixed into the wValue is the number you got from USBGetManufacturerStringIndex. The string descriptor type is defined in table 9-5, kUSBStringDesc is also in USBSpec.h.

The Language ID is a magic number, there's a list of them <http://www.usb.org/developers/data/USB_LANGIDs.pdf>, but I've only ever seen English.

The wLength you supply is however long you expect the string to be. You could supply 255, the maximum. However there is a common bug in which devices can hang on this, so the normal way of doing this is to ask for 2 bytes, which tells you the length of the descriptor (the first byte). Then you ask for exactly the right number of bytes.
--
Barry Twycross
email@hidden
---
USB, it's not a Dyslexic BUS. (Thanks to TC.)
_______________________________________________
usb mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/usb
Do not post admin requests to the list. They will be ignored.

References: 
 >general OS X user-space GET_DESCRIPTOR device request? (From: hotblack <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.