I'm trying to understand the need for Zero packets in USB-CDC transmissions. From what I gather, this seems to touch upon some grey areas of the USB spec or in differences in implementation of host USB drivers. I'm interested in both the 'correct' behavior (as per the USB spec) and typical behavior as far as regular USB hosts are concerned (Linux, Windows, OSX). Any relevant insight would be appreciated.
A hypothetical example of a USB device would be one which is transmitting over a single USB-CDC endpoint, simply continuously generating and transmitting bytes infinitely. For this example, assume that the generation of data is considerably slower than USB-CDC transmission. The approach I would like to use is collect 64 bytes of data (device packet size), and when 64 bytes are ready, transmit a single packet. No zero packets will ever be sent, no short packets will ever sent. Any host-initiated polling will be NAKed when there is no complete packet ready.
Is this a valid way to transmit CDC data?
Are there any USB hosts that are known to have issues with this approach?
If the USB device is a composite USB device, and one of the provided endpoints is a CDC endpoint as described, is there any change to the answers of a. and b.?
In the device of 1., if, instead of sending NAKs when there is nothing to send, the device were to send back a 0 packet, is it likely to still work? How does the overall transmission change - in terms of how it is interpreted by a serial port emulator and/or the effective bandwidth?
If the device, instead, transmits a few bytes, waits for a response. The length of these 'few' bytes is not known apriori. The host must be able to receive, process, and respond to these few bytes - they can't just sit in a hardware / driver buffer waiting for the entire transmission to end. Assume for the moment that USB-CDC recieve-by-the-device is somehow working and stable. All I'm interested in in zero packet transmission from the device.
If the number of bytes to be sent out is not a multiple of 64 bytes (packet size), then simply ending with the 'short' packet would be enough to mark end of transmission, yes?
If the number of bytes to be sent is a multiple of 64 (packet size), then what happens if a zero packet is not sent after the last transmitted packet to mark end of transmission?