libftdi Archives

Subject: Re: Suggested patch for adding ftdi_transfer_data_cancel

From: "Eugene Hutorny" <eugene@xxxxxxxxxxxxx>
To: <libftdi@xxxxxxxxxxxxxxxxxxxxxxx>, "Thomas Jarosch" <thomas.jarosch@xxxxxxxxxxxxx>
Date: Mon, 28 Mar 2016 17:22:39 +0300
Hi Thomas,

In the existing code tc->completed is used as boolean.
Definitely it is not an error. Perhaps it would make sense to use TRUE/FALSE,
but I am not sure if it worth refactoring.

Best Regards

Eugene


-----Original Message----- From: Thomas Jarosch
Sent: Saturday, March 26, 2016 14:09
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx ; eugene@xxxxxxxxxxxxx
Subject: Re: Suggested patch for adding ftdi_transfer_data_cancel

Hi Eugene,

Am 25.01.2016 um 08:35 schrieb Eugene Hutorny:
I have met a problem with a submitted read request – it never ends if
there is no input data.
When application calls ftdi_transfer_data_done it never returns.
libusb logs indicate that the transfer completes with status word only
and then unconditionally resubmitted.
Exit from the app with no call to ftdi_transfer_data_done causes random
crashes.

Suggested patch implements a cancelation routine and solves the problem
I’ve described.

thanks for the patch, applied! I've massaged the code indentation a bit,
since libftdi uses spaces for indentation instead of tabs.

While reviewing your changes, I wonder if
the existing libftdi code does the wrong thing:

+            if (ret < 0)
+                tc->completed = 1;



shouldn't that rather read:

if (ret <0)
   tc->completed = LIBUSB_TRANSFER_ERROR;

instead of hardcoding the enum value directly?

Cheers,
Thomas


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
Current Thread