Re: [linux-minidisc] "netmdcli send" does not break on errors


Am 22/09/2011 22:02, schrieb Michael Karcher:
Why do you add a netmd_receive_track function stub to session.c? We already have a corecctly working track receiption code in secure.c

Are you sure that it is working correctly?
This is the main code for the bulk transfer in netmd_secure_real_recv_track(...) :
.
.
.
read = libusb_bulk_transfer((libusb_device_handle*)dev, 0x81, data, (int)chunksize, &transferred, 10000);
        if (read >= 0) {
            done += (uint32_t)read;
            fwrite(data, (uint32_t)read, 1, file);
.
.
.

read is the return code from libusb_bulk_transfer. So if return code is 0 which means no error, 
data size of 0 will be written to the file and 0 will be added to the "done" variable.
We have to use the variable "transferred" to check the data size. So the code must look like this:

read = libusb_bulk_transfer((libusb_device_handle*)dev, 0x81, data, (int)chunksize, &transferred, 10000);
        if (read >= 0) {
            done += (uint32_t)transferred;
            fwrite(data, (uint32_t)transferred, 1, file);

This works, please change this. I do not make a patch because i am working on other changes and do not want to rebase yet.

Thomas