Using uninitialized readpktcount variable in comparison causes miss of a submission of BulkOut transfer, that later causes timeout in BulkIn transfer:
$ ./ch341eeprom -s 24c64 -r 2.bin
Read [128] of [8192] bytes
cbBulkIn: error : 2
ret from libusb_handle_timeout = 0
getnextpkt = -1
USB read error : Success
Read [8192] bytes from [24c64] EEPROM
Wrote [8192] bytes to file [2.bin]
2nd:
Not checking for byteoffset < bytestoread at a proper place causes submission of superfluous BulkIn transfer after the last block of data is received:
$ ./ch341eeprom -s 24c64 -r 2.bin
Read [8192] bytes from [24c64] EEPROM
Wrote [8192] bytes to file [2.bin]
libusbx: error [do_close] Device handle closed while transfer was still being processed, but the device is still connected as far as we know
libusbx: error [do_close] A cancellation hasn't even been scheduled on the transfer for which the device is closing
1st:
Using uninitialized
readpktcount
variable in comparison causes miss of a submission of BulkOut transfer, that later causes timeout in BulkIn transfer:2nd:
Not checking for
byteoffset < bytestoread
at a proper place causes submission of superfluous BulkIn transfer after the last block of data is received: