title: When do USB Hosts require a zero-length IN packet at the end of a Control Read Transfer?
body: <p>I am writing code for a USB device.  Suppose the USB host starts a control read transfer to read some data from the device, and the amount of data requested (wLength in the Setup Packet) is a multiple of the Endpoint 0 max packet size.  Then after the host has received all the data (in the form of several IN transactions with maximum-sized data packets), will it initiate another IN transaction to see if there is more data even though there can't be more?</p>
  
  <p>Here's an example sequence of events that I am wondering about:</p>
  
  <ol>
  <li>USB enumeration process: max packet size on endpoint 0 is reported to be 64.</li>
  <li>SETUP-DATA-ACK transaction starts a control read transfer, wLength = 128.</li>
  <li>IN-DATA-ACK transaction delivers first 64 bytes of data to host.</li>
  <li>IN-DATA-ACK transaction delivers last 64 bytes of data to host.</li>
  <li>IN-DATA-ACK with zero-length DATA packet?  Does this transaction ever happen?</li>
  <li>OUT-DATA-ACK transaction completes Status Phase of the transfer; transfer is over.</li>
  </ol>
  
  <p>I tested this on my computer (Windows Vista, if it matters) and the answer was <strong>no</strong>: the host was smart enough to know that no more data can be received from the device, even though all the packets sent by the device were full (maximum size allowed on Endpoint 0).  I'm wondering if there are any hosts that are <em>not</em> smart enough, and will try to perform another IN transaction and expect to receive a zero-length data packet.</p>
  
  <p>I think I read the relevant parts of the USB 2.0 and USB 3.0 specifications from usb.org but I did not find this issue addressed.  I would appreciate it if someone can point me to the right section in either of those documents.</p>
  
  <p>I know that a zero-length packet can be necessary if the device chooses to send less data than the host requested in wLength.</p>
  
  <p>I know that I could make my code flexible enough to handle either case, but I'm hoping I don't have to.</p>
  
  <p>Thanks to anyone who can answer this question!</p>