阅读:1361回复:1
USB驱动的多接口选择问题
在处理设备启动时需要选择usb设备的接口,在
SelectInterfaces(IN PDEVICE_OBJECT IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor)函数里获得了一个接口信息链表结构,也就是说它保存了从配置描述符下属的一系列接口描述符信息,如果一个配置有不止1个接口,后面程序调用USBD_CreateConfigurationRequestEx()创建1个URB的时候,根据什么来选择到底用哪个接口呢? 具体源代码如下: PUSBD_INTERFACE_LIST_ENTRY interfaceList, tmp; PUSBD_INTERFACE_INFORMATION Interface; tmp = interfaceList =ExAllocatePool(NonPagedPool, sizeof(USBD_INTERFACE_LIST_ENTRY) * (numberOfInterfaces + 1)); if(!tmp) { return STATUS_INSUFFICIENT_RESOURCES; } while(interfaceNumber < numberOfInterfaces) { interfaceDescriptor = USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor, ConfigurationDescriptor, interfaceindex, 0, -1, -1, -1); if(interfaceDescriptor) { interfaceList->InterfaceDescriptor = interfaceDescriptor; interfaceList->Interface = NULL; interfaceList++; interfaceNumber++; } interfaceindex++; } interfaceList->InterfaceDescriptor = NULL; interfaceList->Interface = NULL; urb = USBD_CreateConfigurationRequestEx(ConfigurationDescriptor, tmp); if(urb) { Interface = &urb->UrbSelectConfiguration.Interface; for(i=0; i<Interface->NumberOfPipes; i++) { // // perform pipe initialization here // set the transfer size and any pipe flags we use // USBD sets the rest of the Interface struct members // Interface->Pipes.MaximumTransferSize = DEFAULT_SIZE; } |
|
沙发#
发布于:2004-10-28 16:14
设哪个interface或configuration应该根据你需要的功能来设定的吧,否则usb协议中要setConfiguration和setInterface命令何用?
|
|