Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Send data failed by USB3.0

Anonymous
Not applicable

 Hello, I'm wrting a very simple program to send file to USB as follows:

   

 

   
... LONG count;
while(!feof(fp)){
count=fread(buffer,1,BUFSIZE,fp);
USBDevice->BulkOutEndPt->XferData(buffer, count,NULL);
} ...
   


#define BUFSIZE 0x100000

   

and I also use asynchonous method :

   

...

   

   

LONG count;

   

while(!feof(fp)){

   

count=fread(buffer,1,BUFSIZE,fp);

   

UCHAR  *outContext = USBDevice->BulkOutEndPt->BeginDataXfer(buffer, count, &outOvLap);

   

USBDevice->BulkOutEndPt->WaitForXfer(&outOvLap,100);

   

USBDevice->BulkOutEndPt->FinishDataXfer(buffer, count, &outOvLap,outContext);

   

}

   

...

   

The two methods both  run OK By USB2.0, but By USB3.0, They can only send a little data  and then fail.

   

Please help me!

   

Thanks & Best Regards,

   

Shakaqrj

   

 

   
        
0 Likes
3 Replies
ShopithamR_26
Employee
Employee
25 replies posted 10 replies posted 5 replies posted

Hello Shakaqrj,

   

Your code snippet looks fine. This can be an issue in your firmware or in your board too

   

In order to isolate . Please do the following

   

1) Program the device with Bulk loop example project and test with our Control Center and Streamer applications. Ensure device has enumerated as USB3.0 .If this work there is no issue in your board .

   

2) Program the device with your project . Ensure device is in USB3.0. Try sending the data using Control Center and see if you are seeing any issue . If there is no issue then it is not your FX3 firmware issue.

   

3) Program the device with Bulk Loop project and try using your host application and see if it work.  

Try to figure which among the above 3 cases cause failure . A USB traces would help you in resolving this issue faster.

   

 

   

-sobi

0 Likes
Anonymous
Not applicable

 Hello Sobi,

   

If I use Control Center to send data less then 16KB, it runs OK, But If I send data with large size, it fails both in USB2.0 and USB3,0.

   

If I use my tool to send data, there is no problem both in USB2.0 and USB3.0 unless data size. But In USB 3.0, I can't send data even more than 8KB

0 Likes
Anonymous
Not applicable

 Hello,

   

 

   

Now I program USBBulkLoopManualInOut.img to RAM, and write code like this,

   

 

   

#define BUFSIZE 0x1000

   

   

void CTestUSBDlg::OnBnClickedButtonSend()

   

{

   

// TODO: Add your control notification handler code here

   

CFileDialog dlg(TRUE);

   

if(dlg.DoModal()==IDOK){

   

   

 

   

FILE* fp=_tfopen(dlg.GetPathName(),_T("rb"));

   

FILE* fw=_tfopen(_T("READBUFFER"),_T("wb"));

   

   

fseek(fp,0,SEEK_SET);

   

   

 

   

unsigned char* buffer=new unsigned char[BUFSIZE];

   

 

   

LONG count;

   

while(!feof(fp)){

   

 

   

count=fread(buffer,1,BUFSIZE,fp);

   

USBDevice->BulkOutEndPt->XferData(buffer, count,NULL);

   

   

memset(buffer,0,BUFSIZE);

   

USBDevice->BulkInEndPt->XferData(buffer,count,NULL);

   

fwrite(buffer,1,count,fw);

   

   

}

   

fclose(fw);

   

fclose(fp);

   

 

   

delete[] buffer;

   

   

}

   
    }   
   
        
   
    In USB2.0, it runs OK. but in USB3.0, the program blocks in a while and only less than 300KB data has been sent.   
0 Likes