ConnectionFTDI: change abort reading/sending
Attemp to complete tranfers normally before cancelling
avoids lost USB packet problem on RPi, that can occur on next run after cancel.
@@ -550,14 +550,18 @@ void ConnectionFT601::AbortReading(int ep)
for(int i = 0; i<USB_MAX_CONTEXTS; ++i)
{
if(contexts[i].used)
+ {
+ if (WaitForReading(i, 100))
+ FinishDataReading(nullptr, 0, i);
+ else
libusb_cancel_transfer(contexts[i].transfer);
}
- FT_FlushPipe(streamRdEp);
+ }
for(int i=0; i<USB_MAX_CONTEXTS; ++i)
{
if(contexts[i].used)
{
- WaitForReading(i, 250);
+ WaitForReading(i, 100);
FinishDataReading(nullptr, 0, i);
}
}
@@ -696,13 +700,18 @@ void ConnectionFT601::AbortSending(int ep)
for(int i = 0; i<USB_MAX_CONTEXTS; ++i)
{
if(contextsToSend[i].used)
+ {
+ if (WaitForSending(i, 100))
+ FinishDataSending(nullptr, 0, i);
+ else
libusb_cancel_transfer(contextsToSend[i].transfer);
}
+ }
for (int i = 0; i<USB_MAX_CONTEXTS; ++i)
{
if(contextsToSend[i].used)
{
- WaitForSending(i, 250);
+ WaitForSending(i, 100);
FinishDataSending(nullptr, 0, i);
}
}
