micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

usb-device-cdc: Fix lost data in read() path if short reads happened.

Open projectgus opened this issue 1 year ago • 0 comments

If the CDC receive buffer was full and some code read less than 64 bytes (wMaxTransferSize), the CDC code would submit an OUT transfer with N<64 bytes length to fill the buffer back up.

However if the host had more than N bytes to send then it would still send the full 64 bytes (correctly) in the transfer. The remaining (64-N) bytes would be lost.

Fix is to not send a new transfer until 64 bytes is free. Adds the restriction that CDCInterface rxbuf has to be at least 64 bytes.

Closes #885.

This work was funded through GitHub Sponsors.

projectgus avatar Jun 18 '24 07:06 projectgus