Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > FinishDataXfer() returns false when removing a USB thumbdrive in Windows 7

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



FinishDataXfer() returns false when removing a USB thumbdrive in Windows 7
Moderator:
RSKV

Post Reply
Follow this topic



FinishDataXfer() returns false when removing a USB thumbdrive in Windows 7

brandovino posted on 22 Feb 2011 5:21 PM PST

1 Forum Post

Hi,

Is anybody else experiencing this problem?  It only happens in Windows 7.  I tried it in Windows XP and could not reproduce there.  Basically I have a C++ app that recieves streaming data from our firmware.  In a separate thread I have a loop that calls BeginDataXfer() and when the event is signaled it calls FinishDataXfer().  Everything is working fine until a user inserts a thumbdrive to do other stuff and when he pulled it out I get this error from FinishDataXfer().  This happens 50% of the time, so I think it's a timing issue but I don't know how to work around it.

Here's my environment:

MS Visual Studio 2010

32-bit Windows 7 Professional,

Cypress driver 3.04.0002.00,

The chip we are using is the Cypress Chip CY7C68001-56PVC.

The application is as a high speed USB interface to the DSP processor.

Here's a code snippet within the thread:

case WAIT_OBJECT_0+2:  //overlapped read operation done

{
   if(pInContext!=NULL && BulkInEpt!=NULL)
   {
       nLength=nBufferSize;
 
        ::ResetEvent(t_osRead.hEvent);
         if(BulkInEpt->FinishDataXfer(szReceiveBuffer, nLength, &t_osRead,pInContext))
         {
                szReceiveBuffer[nLength]=0;
                pThis->UpdateTotalXFerBytes(nLength);
                pThis->ApppendToReplyProcessQueue(szReceiveBuffer, nLength);
 
                //Start an async. read again
                 nLength=nBufferSize;
 
                 pInContext=BulkInEpt->BeginDataXfer(szReceiveBuffer,nLength,&t_osRead);
 
                  // be nice and make sure giving time to ReplyProcessThread
                  Sleep(0);                                                  
          }
          else
          {
                  DWORD dwLastError=::GetLastError();
                  MessageBox.Show(  "Reply-receive failed, reconnecting...error code"+dwLastError);
 
           }
       }
 }
 
break;
Any insight would be appreciated.
BTW, the GetLastError always returns  ERROR_IO_PENDING even before the user removes a thumbdrive.

Thank you.  




Re: FinishDataXfer() returns false when removing a USB thumbdrive in Windows 7

aasi posted on 25 Feb 2011 01:01 AM PST
Cypress Employee
1090 Forum Posts

Brandovino,

Windows 7 seems to faster USB capability and stringent time constraints compared to the other flavors of Windows. Quite possibly you are cutting your timeout value too close. Have you tried increasing it to see what happens?

Regards,

Anand






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20