From: Bhavik on
Hello,

I am working on a USB device and a PC application to communicate to
the device.
I have one OUT end point and one IN endpoint on my device.

I am continuously reading data on the IN endpoint in a separate thread
inside my application.
My application connects to the device using CreateFile function, and
the read/write operations are done by ReadFile and WriteFile
functions.

After connecting to my device, the device sends some preliminary
information to my application.
Everything is working fine till this point.

Now my Reader thread continues trying to read data from my device, but
my device does not have any data to send.
In this case my device should respond with a NAK to the IN request,
but sometimes it does not respond at all to the IN request (I have no
idea why!!).

So the PC driver considers this as an incomplete transaction, and
continues with the next try to read data.

The problem is that the when the Windows driver encounters 6
incomplete transactions, it stops reading any data from my device.

Is there any way to increase the number of incomplete transactions
before Windows stops any communication to the device?

Any help or suggestion to solve this problem are welcome.

Thanks for help in advance.

Bhavik
From: Tim Roberts on
Bhavik <bhavik.patel(a)gmail.com> wrote:
>
>I am working on a USB device and a PC application to communicate to
>the device.
>I have one OUT end point and one IN endpoint on my device.
>...
>Now my Reader thread continues trying to read data from my device, but
>my device does not have any data to send.
>In this case my device should respond with a NAK to the IN request,
>but sometimes it does not respond at all to the IN request (I have no
>idea why!!).

Well, you need to find OUT why. That's part of the protocol.

>So the PC driver considers this as an incomplete transaction, and
>continues with the next try to read data.
>
>The problem is that the when the Windows driver encounters 6
>incomplete transactions, it stops reading any data from my device.

Are you sure it's Windows that stops, and not the hub or the host
controller? Not that it matters, I guess...

>Is there any way to increase the number of incomplete transactions
>before Windows stops any communication to the device?

No.

>Any help or suggestion to solve this problem are welcome.

The suggestion is to fix your device. USB is a protocol bus, and devices
on the bus must follow the protocol.
--
Tim Roberts, timr(a)probo.com
Providenza & Boekelheide, Inc.
From: Bhavik on
Hi,

Thanks for the reply.

I tried to see the activity on the USB bus using Ellisys USB protocol
analyzer, and found one strange thing.

I have a separate thread to read from my USB device, and the writing
occurs from my main application thread.
Now if I write something to my device before there are 6 incomplete
transactions in the read, the read operation continues successfully.

If my application stops writing to the device, the read continues till
the time there are 6 consecutive incomplete transactions again.

So it seems that if there is any successful transaction to the device,
the Windows driver resets the error counter internally to 0.

Can you give me some idea how to work around this problem?

Thanks,

Bhavik



On Jan 30, 6:08 am, Tim Roberts <t...(a)probo.com> wrote:
> Bhavik <bhavik.pa...(a)gmail.com> wrote:
>
> >I am working on a USB device and a PC application to communicate to
> >the device.
> >I have one OUT end point and one IN endpoint on my device.
> >...
> >Now my Reader thread continues trying to read data from my device, but
> >my device does not have any data to send.
> >In this case my device should respond with a NAK to the IN request,
> >but sometimes it does not respond at all to the IN request (I have no
> >idea why!!).
>
> Well, you need to find OUT why.  That's part of the protocol.
>
> >So the PC driver considers this as an incomplete transaction, and
> >continues with the next try to read data.
>
> >The problem is that the when the Windows driver encounters 6
> >incomplete transactions, it stops reading any data from my device.
>
> Are you sure it's Windows that stops, and not the hub or the host
> controller?  Not that it matters, I guess...
>
> >Is there any way to increase the number of incomplete transactions
> >before Windows stops any communication to the device?
>
> No.
>
> >Any help or suggestion to solve this problem are welcome.
>
> The suggestion is to fix your device.  USB is a protocol bus, and devices
> on the bus must follow the protocol.
> --
> Tim Roberts, t...(a)probo.com
> Providenza & Boekelheide, Inc.

From: Tim Roberts on
Bhavik <bhavik.patel(a)gmail.com> wrote:
>
>I tried to see the activity on the USB bus using Ellisys USB protocol
>analyzer, and found one strange thing.
>
>I have a separate thread to read from my USB device, and the writing
>occurs from my main application thread.
>Now if I write something to my device before there are 6 incomplete
>transactions in the read, the read operation continues successfully.
>
>If my application stops writing to the device, the read continues till
>the time there are 6 consecutive incomplete transactions again.
>
>So it seems that if there is any successful transaction to the device,
>the Windows driver resets the error counter internally to 0.
>
>Can you give me some idea how to work around this problem?

Yes. Fix your device so that it properly responds with a NAK when it has
no data to transfer. That's the only way. This is a hardware protocol
violation, and you won't be able to work around it with a mere software
driver.
--
Tim Roberts, timr(a)probo.com
Providenza & Boekelheide, Inc.
From: Bhavik on
Hello,

It is not the case that the device does not respond at all.
The device is responding with NAK for the IN request. But it misses to
respond for once in a while.
So the host increments its error counter till the 6 errors. and then

The error code I am getting in my driver is: 0xC0000001
(USBD_STATUS_CRC).
I have tried to reset the pipe using URB_FUNCTION_RESET_PIPE.

But this also responds with the error code 0xC0000001.

Can you please tell me why this error is given?

Regards,

Bhavik

On Feb 1, 12:49 am, Tim Roberts <t...(a)probo.com> wrote:
> Bhavik <bhavik.pa...(a)gmail.com> wrote:
>
> >I tried to see the activity on the USB bus using Ellisys USB protocol
> >analyzer, and found one strange thing.
>
> >I have a separate thread to read from my USB device, and the writing
> >occurs from my main application thread.
> >Now if I write something to my device before there are 6 incomplete
> >transactions in the read, the read operation continues successfully.
>
> >If my application stops writing to the device, the read continues till
> >the time there are 6 consecutive incomplete transactions again.
>
> >So it seems that if there is any successful transaction to the device,
> >the Windows driver resets the error counter internally to 0.
>
> >Can you give me some idea how to work around this problem?
>
> Yes.  Fix your device so that it properly responds with a NAK when it has
> no data to transfer.  That's the only way.  This is a hardware protocol
> violation, and you won't be able to work around it with a mere software
> driver.
> --
> Tim Roberts, t...(a)probo.com
> Providenza & Boekelheide, Inc.