About USB device timeout

Hi All
I use Interrupt Transfer for receiving data from our USB device.
But I don’t know how can I restore exchange in case of device
time-out
I have investigated this problem using USB Bus & Protocol Analyzer.
After timeout I observe that low level driver don’t translate to USB
device
packets to EndPoint1 and IoCallDriver returns error stauus.

There is code :
status = IoCallDriver(pdx->Header.LowerDeviceObject, Irp);
if (status == STATUS_PENDING) {
status = KeWaitForSingleObject(&pdx->UsbReadEvent,
Executive,KernelMode,FALSE, &timeout);
if (status == STATUS_TIMEOUT) {
IoCancelIrp(Irp);
// And wait event from CompletionRoutine until the
cancel completes
KeWaitForSingleObject(&pdx->UsbReadEvent,Executive,
KernelMode, FALSE,NULL);
}

I tried to use after timeout
URB_FUNCTION_RESET_PIPE,IOCTL_INTERNAL_USB_RESET_PORT but
it didn’t help
Thanks for any help
Best regards
Mark


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hello ,

MS> status = IoCallDriver(pdx->Header.LowerDeviceObject, Irp);
MS> if (status == STATUS_PENDING) {
MS> status = KeWaitForSingleObject(&pdx->UsbReadEvent,
MS> Executive,KernelMode,FALSE, &timeout);
MS> if (status == STATUS_TIMEOUT) {
MS> IoCancelIrp(Irp);
MS> // And wait event from CompletionRoutine until the
MS> cancel completes
MS> KeWaitForSingleObject(&pdx->UsbReadEvent,Executive,
MS> KernelMode, FALSE,NULL);

Why do you use a synchroneous read for a interrupt pipe read? Use a IO completion
proc an works always async. The second thing, you can use KeWaitForSingleObject
only at IRQL > 0 for a timeout value Zero.

Better is a async read and start a normal timer to have the control.
Normaly here is no problem or your USB adapter is wrong. When the
timer is expired you can cancel the read and reset the pipe.

Do you use the USB_SHORT_TRANSFER_OK flag ?

elli


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi,
Thank you very mush for you replay.
It is only part of may code execute in PASSIVE_LEVEL(!) and I can to use
KeWaitForSingleObject with timeout value !=0.

I use async read and first KeWaitForSingleObject wait event from
CompletionRoutine and only in case timeout = 5sec.
second KeWaitForSingleObject get event from CompletionRoutine after
IoCancelrp
In function UsbBuildInterruptOrBulkTransferReques I use flags
USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK
It code work properly and passed many tests except case of timeout .
I tried to use the reset pipe but it didn’t help and low level driver don’t
pass my requests to Endpoint1 to device…
Mark

Mathias Ellinger wrote:

Hello ,

MS> status = IoCallDriver(pdx->Header.LowerDeviceObject, Irp);
MS> if (status == STATUS_PENDING) {
MS> status = KeWaitForSingleObject(&pdx->UsbReadEvent,
MS> Executive,KernelMode,FALSE, &timeout);
MS> if (status == STATUS_TIMEOUT) {
MS> IoCancelIrp(Irp);
MS> // And wait event from CompletionRoutine until the
MS> cancel completes
MS> KeWaitForSingleObject(&pdx->UsbReadEvent,Executive,
MS> KernelMode, FALSE,NULL);

Why do you use a synchroneous read for a interrupt pipe read? Use a IO completion
proc an works always async. The second thing, you can use KeWaitForSingleObject
only at IRQL > 0 for a timeout value Zero.

Better is a async read and start a normal timer to have the control.
Normaly here is no problem or your USB adapter is wrong. When the
timer is expired you can cancel the read and reset the pipe.

Do you use the USB_SHORT_TRANSFER_OK flag ?

elli


You are currently subscribed to ntdev as: xxxxx@arx.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com