Re: First bulk write often doesn't seem to reach device.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 24 Mar 2009, Dave Mielke wrote:

> [quoted lines by Alan Stern on 2009/03/24 at 12:02 -0400]
> 
> Thank you for having been patient with my attempts to understand and deisre to 
> learn. I have a couple more questions raised by my own curiosity and one for 
> enhancing code robustness.
> 
> A zero-length write has proven to be a way to try to get an output endpoint's 
> toggle synchronized, althouygh I suppose even that isn't guaranteed if the 
> device wants to continue to ignore packets and, therefore, flips its toggle 
> even when ignoring a packet.

If it does that then it really has got a serious bug.  The USB spec is 
extremely clear about how this is supposed to work.

> Is there a similar way to try to synchronize an 
> input endpoint's toggle?

All of the methods I mentioned before are supposed to set the toggle 
back to 0.  Most of them are rather heavy-handed -- you might not want 
to reset the entire device just to fix a toggle problem.  (On the other 
hand, maybe you don't mind resetting the entire device... and for buggy
devices, a full reset is more likely to work.)

> Does doing a read into a zero-length buffer make any 
> sense?

No.  It's more likely either to time out or cause an overflow error
when the device tries to send you more than 0 bytes of data.  It's a
little safer to do a read into a buffer whose length is the endpoint's 
maxpacket size; then you can't get an overflow.  But you still can time 
out if the device doesn't have any data to send.

> Is there a way to query the toggle state for an endpoint without altering it?

There's no way to query the toggle state at all!

> >Each control, bulk, and interrupt endpoint has its own toggle.  
> >Isochronous endpoints don't have toggles.
> 
> Since the control endpoint supports both input and output transfers, does it 
> actually have two toggles? Does the setup packet count as a separate packet?

Control endpoints work in a special way.  The toggle value sent in a
Setup packet is always 0, and the device _must_ accept it.  The 
following packets making up the Data stage of the control transfer then 
begin with toggle = 1 and alternate toggle values as usual.  The toggle 
value sent during the Status stage of the transfer is always 1.

This is explained very nicely in section 8.6 of the USB 2.0 
specification, with extra material in sections 5.7.5 and 5.8.5.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux