I am having trouble getting interface 0/alternate 1 to be selected. I have set up my descriptors as follows:
interface 0/alternate 0:
ep 1 isoch in / 0 bytes
ep 2 int in / 32 bytes
ep 3 int out / 32 bytes
ep 4 isoch out / 0 bytes
interface 0/alternate 1:
ep 1 isoch in / 16 bytes
ep 2 int in / 32 bytes
ep 3 int in / 32 bytes
ep 4 isoch out / 16 bytes
Using a software bus analyzer called USBTrace, I was able to prove to myself that the continuous endpoint reader from the osrusbfx2 WDF sample worked as advertised on interface 0/alternate 0. I set up a 16 bit incrementing counter on the endpoint and dumped out 32 bytes at a time and it never had a gap in the data.
Switching to alternate setting 1 on interface 0 has been giving me some trouble:
Here is the code snippet I have been using (in the SelectedInterfaces routine in Device.c):
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS configParams;
NTSTATUS status;
PDEVICE_CONTEXT pDeviceContext;
WDF_USB_INTERFACE_SELECT_SETTING_PARAMS selectSettingParams;
WDFUSBPIPE pipe;
WDF_USB_PIPE_INFORMATION pipeInfo;
UCHAR index;
UCHAR numberConfiguredPipes;
WDFUSBINTERFACE UsbInterface;
pDeviceContext = GetDeviceContext(Device);
WDF_USB_INTERFACE_SELECT_SETTING_PARAMS_INIT_SETTING(&selectSettingParams,1);
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_MULTIPLE_INTERFACES(&configParams, 1, selectSettingParams);
status = WdfUsbTargetDeviceSelectConfig(pDeviceContext->UsbDevice, WDF_NO_OBJECT_ATTRIBUTES, &configParams);
if(!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, “WdfUsbTargetDeviceSelectConfig failed %!STATUS!\n”, status);
return status;
}
pDeviceContext->UsbInterface = configParams.Types.SingleInterface.ConfiguredUsbInterface;
UsbInterface = WdfUsbTargetDeviceGetInterface(pDeviceContext->UsbDevice, 0);
status = WdfUsbInterfaceSelectSetting(UsbInterface,WDF_NO_OBJECT_ATTRIBUTES,&selectSettingParams);
if(!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, “WdfUsbInterfaceSelectSetting failed %!STATUS!\n”, status);
return status;
}
numberConfiguredPipes = WdfUsbInterfaceGetNumEndpoints(UsbInterface,0);
//
// Get pipe handles
//
Now this line: configParams.Types.SingleInterface.ConfiguredUsbInterface;
is probably killing me, but I couldn’t find an equivalent union value that returns a ConfiguredUsbInterface for multiple endpoints.
In the Kernel-Mode Driver Framework .chm file, the entry for WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_MULTIPLE_INTERFACES in the sample code snippet refers to a user created function, InitSettingPairs, which is not defined anywhere else in the manual. I think that would be useful to flesh out on that page, as I am not certain how I would create it myself. Any help would be appreciated.