Hi,
Need some suggestions on handing zero length packet with Bulk transfer.
Some protocols which use USB require an extra zero length data packet to signal end-of-transfer on bulk endpoints, if the last data packet is exactly wMaxPacketSize bytes long. (e.g. VCP)
Others, where the transfer size is known do not need ZLP (e.g. Mass storage)
To come up with USB device stack which can support both the requirements, I plan to provide a flag which indicates if ZLP should be sent or not, when the last data packet is exactly wMaxPacketSize bytes long.
This flag allows applications/class drivers to inform about this requirement, so that the underlying USB stack can handle the issue transparently.
Question: Is this a good approach for this situation? or please recommend other/better options.
If I go with this approach, I would like to know, what time is appropriate to inform the underlying driver about this flag.
It can be done at the configuration time, when ENDPOINT is being configured. That makes it a one time activity, meaning all the transfers will use ZLP (when required) if the flag was set at the EP configuration time.
Or the flag can be provided everytime when data buffer is provided to the driver. underlying driver will decide on the fly if the ZLP should be sent or not.
Question: I would like to know, Is there a possibility with Bulk transfers that the ENDPOINT needs to use ZLP or does not need to use zlp on the fly.
My understanding is that on the device side once the EP is configured for particular class/protocol, the configuration will remain same throughout.
If the same implementation need to be done on the USB stack for the host side, I guess the Indication flag to use ZLP or not use ZLP should be done everytime when data buffer is provided.
Question: Is this a good approach for Host stack?
Thanks and regards,
NVD