On 31/10/14 14:23, Alan Stern wrote:
On Fri, 31 Oct 2014, Peter Stuge wrote:
Breton M. Saunders wrote:
Are zero length transfers from a device to the PC on a bulk endpoint
sensible?
I don't see how they could be.
If the device has no data to send it responds with a NAK handshake.
If the device has data to send it responds with the data.
But what if the host expects to receive data and the device has no data
to send? In that case the device must send a zero-length packet.
Otherwise the host will hang, waiting for data that the device will
never send.
This is required behavior, for example, during the data phase of a
bulk-only mass-storage transfer. The specification states that under
certain circumstances, the device _must_ send a zero-length packet on
its bulk-IN endpoint.
Hi Alan - thanks for that. Can I ask: have you got a reference for
that? It will help when I arrive back in the office on Monday.
I've briefly skimmed the usb mass storage bulk only document (from 1999)
and am looking at usb-msc-0.2.pdf now; but am not finding details on
zero-length transfers on bulk.
I admit to being unfamiliar with usb mass storage; my work has primarily
been on HID and custom bulk protocols.
I was coming at this from the user side of the problem where what I was
(incorrectly) doing was:
write(fd, buffer, 0);
where buffer is a valid virtual address, and fd is an open file
descriptor on a bulk-in endpoint.
If I read man 2 write (ubuntu 14.04) I find that the return code for
write is undefined for a non-regular file _and_ a count value of zero.
At present I've seen fit to just return -EIO (from gadgetfs) on writes
of zero bytes to a non-control endpoint - however, I'm still trying to
ascertain whether this behavior is correct or not.
A document stating that zero length bulk transfers could allow me to get
permission to investigate the problem further down the chain - into musb.
Cheers,
-Brett
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
--
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