On Thu, Oct 25, 2012 at 12:49 AM, Markus <li...@neuronenwerk.de> wrote:
> Hi list,
>
> I'm having a device here, that amongst others, features some
> descriptors within the configuration descriptor, that are not
> explicitely available via the libusbx API. These are:
>
> - Interface Association Descriptor
> - Device Class Specific Descriptors
> - Super Speed Companion Descriptor
>
> While I can, for instance, read the IAD via the "extra" field, I
> can't do arbitrary reads - as it looks. If I consider the memory
> contiguous, it will fail. So I'm unable to parse anything that's
> not been wrapped by libusbx, like my Device Class Specific
> Descriptors.
>
> Though the IAD is living directly after the 8 byte configuration
> descriptor head in the config descriptor (within the device),
> the address of "extra" is nearly 7k away from its end.
>
> If the configuration descriptor would be contiguous, it would
> easily be possible to parse the descriptor.
>
> Am I missing something? If not, would you be willing to change
> this, as it would enable a lot more applications with libusbX.
>


We don't use "extra". Not sure what that is for. Sorry!

Here are some copy and pasted sections from our code... Anything that
starts with "u" is our own structs. Sorry if it's a bit cryptic...but
hopefully you get the idea. Just loop through all the descriptors in
the configuration and look for descriptors that have the type
USB_DT_INTERFACE_ASSOCIATION (0x0b).

UINT32                  total_length_cfg_desc;
UINT8                   *cfg_desc_buffer;
UINT32                  config_descriptor_return_length;
UINT8                   *cfg_desc_ptr;
UINT8                   *interface_assocation_ptr;
BOOL                    interface_assoc_parsing_done;

UINT32                  desc_len;
UINT32                  desc_type;
UINT32                  next_assoc;
UINT32                  rv;
total_length_cfg_desc = ucfg->cfg_desc->wTotalLength;
cfg_desc_buffer = (UINT8 *) malloc( total_length_cfg_desc );
rv = tera_usb_host_stack_configuration_descriptor_get(udev->device_id,
            ucfg->cfg_desc->bConfigurationValue,
            cfg_desc_buffer,
            total_length_cfg_desc,
            &config_descriptor_return_length);
cfg_desc_ptr = cfg_desc_buffer;
interface_assoc_parsing_done = FALSE;
ucfg->nr_interface_assocations = 0;

while (!interface_assoc_parsing_done)
{
        next_assoc = ucfg->nr_interface_assocations;
        if ( next_assoc >= USB_MAX_INTERFACE_ASSOCIATIONS )
        {
            // ERROR
            ucfg->nr_interface_assocations = 0;
            return ERROR;
        }
        desc_len = *cfg_desc_ptr;
        desc_type = *(cfg_desc_ptr + 1);
        if (desc_type == USB_DT_INTERFACE_ASSOCIATION)
        {
            // Found an interface association, parse it out
            interface_assocation_ptr = cfg_desc_ptr;
            uiface_assoc = &ucfg->interface_associations[next_assoc];
            uiface_assoc->bLength = *interface_assocation_ptr++;
            uiface_assoc->bDescriptorType = *interface_assocation_ptr++;
            uiface_assoc->bFirstInterface = *interface_assocation_ptr++;
            uiface_assoc->bInterfaceCount = *interface_assocation_ptr++;
            uiface_assoc->bFunctionClass = *interface_assocation_ptr++;
            uiface_assoc->bFunctionSubClass = *interface_assocation_ptr++;
            uiface_assoc->bFunctionProtocol = *interface_assocation_ptr++;
            uiface_assoc->iFunction = *interface_assocation_ptr++;

            ucfg->nr_interface_assocations++;
        }
        cfg_desc_ptr += desc_len;
        if (cfg_desc_ptr >= total_length_cfg_desc + cfg_desc_buffer)
        {
            interface_assoc_parsing_done = TRUE;
        }

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to