Description
I am trying to get the CCID driver to work with a bit finicky industrial device. Occasionally the communication with the device fails with error LIBUSB_TRANSFER_OVERFLOW
, and then things stop working. The reason for this error is described here: https://libusb.sourceforge.io/api-1.0/libusb_packetoverflow.html
As described in the libusb doc, I was able to resolve the problem by tweaking the buffer sizes that CCID is passing to ReadPort
(AKA ReadUSB
) in the commands.c
file. In principle, the needed tweak is to make the buffer sizes a multiple of the endpoint's wMaxPacketSize
. This value can be queried from libusb. In all CCID readers I have, the value is always 64 bytes, however in the latest USB version (3.2, very unlikely to actually be used by CCID readers) it can go up to 1024 bytes if I understand correctly. So we can avoid dealing with wMaxPacketSize
and just assume 1024.
Therefore, I'd like to propose rounding all buffer sizes used for USB bulk transfers to a multiple of 1024, or even just 64 if we want to use a lower value while still handling most devices, although 1024 doesn't seem high enough to me. I can send a PR if the idea is accepted.