command-tab / ch341eeprom

A libusb based programming tool for 24Cxx serial EEPROMs using the WinChipHead CH341A IC
GNU General Public License v3.0
149 stars 58 forks source link

Fix some bugs in ch341readEEPROM() #1

Closed lorf closed 9 years ago

lorf commented 9 years ago

1st:

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
command-tab commented 9 years ago

These are great! Thanks!