Hi All,
I am writing a UMDF2.0 based usb driver, following the umdf2_fx2 sample driver provided in MSDN.
I have configured the TransferLength of the Interrupt pipe and the continuous reader as follows :
{
WDF_USB_CONTINUOUS_READER_CONFIG contReaderConfig;
WDF_USB_CONTINUOUS_READER_CONFIG_INIT(&contReaderConfig,
OsrFxEvtUsbInterruptPipeReadComplete,
DeviceContext, // Context
2048); // TransferLength
contReaderConfig.EvtUsbTargetPipeReadersFailed = OsrFxEvtUsbInterruptReadersFailed;
contReaderConfig.HeaderLength = 0;
contReaderConfig.TrailerLength = 0;
contReaderConfig.NumPendingReads = 2;
status = WdfUsbTargetPipeConfigContinuousReader(DeviceContext->InterruptPipe,
&contReaderConfig);
}
My continuous reader is as follows :
VOID OsrFxEvtUsbInterruptPipeReadComplete(
WDFUSBPIPE Pipe,
WDFMEMORY Buffer,
size_t NumBytesTransferred,
WDFCONTEXT Context
)
{
PVOID requestBuffer;
requestBuffer = WdfMemoryGetBuffer(Buffer, NULL);
if (Pipe == pDeviceContext->InterruptPipe)
{
TraceEvents(TRACE_LEVEL_WARNING, DBG_INIT,"OsrFxEvtUsbInterruptPipeReadComplete Byte Read %d ", NumBytesTransferred);
}
}
The issue that I am facing is that, NumBytesTransferred is always set to max TransferLength configured, i.e 2048. , even though the pipe is transferring only few bytes of data.
I was expecting this value to be actual Number of Bytes transferred on the Pipe.
Similar is the case when a control setup packet is transferred from Device to Host, using below APi?s
{
WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&memDesc,
(PVOID)msg,//(PVOID)test,
msg_size);
status = WdfUsbTargetDeviceSendControlTransferSynchronously(
DevContext->UsbDevice,
WDF_NO_HANDLE, // Optional WDFREQUEST
&sendOptions,
&controlSetupPacket,
&memDesc,
&bytesTransferred);
}
bytesTransferred is always reported as the TransferLength configured on this pipe. However as per MSDN it should be
BytesTransferred [out, optional]
A pointer to a location that receives the number of bytes that are transferred.
Could you please help/ suggest , how to debug this further ? Am I missing any configuration.
Note : When I capture the USB traffic using Wireshark, I could see the actual number of Bytes transferred over the pipe, which is way less than reported value.