Can I check if the endpoint buffer is empty after the XferData API returns?

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

cross mob
user_2585021
Level 1
Level 1
10 sign-ins 5 sign-ins First reply posted

I have a question about Bulk Out transfer.


Currently I am using Bulk Out transfer to stream data into our logic.

The data to be sent is 0x80100 bytes for each Bulk Out transfer.


The source code of the application is shown below.


int MyXferBulkOut(unsigned char *dt, int length)
{

CCyUSBDevice *USBDevice;
CCyUSBEndPoint *OutEndpt;
bool success;
ULONG ret;
int instance;


USBDevice = s_USBDevice; // USB Device Object, when we are get on initialization.

OutEndpt = USBDevice->EndPointOf(0x02); // BulkOut EP2, Auto DMA, Buffer Count = 4
if (OutEndpt == NULL) {
return(-1);
}

OutEndpt->TimeOut = 5000;
success = OutEndpt->XferData( dt, length ); // length = 0x80100;

if (success) {
ret = 0;
}
else{
ret = -1;
}

return ret;
}

 


I have some problem.

After executing 0x80 100byte Bulk Out transfer with the XferData function in the above source code, immediately after the function returns
Bulk Out transfer the next 0x80 100byte data.

At this time, the length of data transmitted to our logic circuit is often shorter than expected.

The cause is completely from the EndPoint Buffer of EP2 to our logic circuit immediately after the XferData function returns.
Since it has not been flushed and the XferData function is called again in the above source code in that state,
This is because the previous data remains in the End Point Buffer of EP2 and the next Bulk Out transfer is instructed.
I'm guessing.

I have a few questions.

Q1. Is there any data left in the Endpoint Buffer immediately after the XferData function (BulkOut) returns?

Or does calling the XferData function transfer to EP2-> EP2's Buffer is completely flushed before returning?

Q2. If there is any data left in the EP2 Endpoint Buffer when the XferData function (BulkOut) returns, that is
How to check if it is empty?

Best regards.

0 Likes
1 Solution

Hello,

However, there is a very low probability that the expected number of data will be shorter than expected by initiating EP2 porting before sending it out.

>> By this you mean that the issue is seen very rarely. Is that correct?

Ans. TRUE is returned even if the data is shorter than expected. I think the porting to EP2 is because it is complete

>> Can you please share the USB traces using Wireshark (.pcap file) . This will help us to understand the issue better.

/if you have a hardware analyzer like Lecroy you can capture the USB traces using that or else you can use software analyzer like Wireshark

It will always be 0x80100byte after the second transfer. Porting to EP2 will never fail.

>> Please track the producer and consumer events on the firmware side just to confirm if the DMA buffers are available to get the data sent from host.

Please let me know the BULK OUT endpoint size (EP 02 size) and the  FX3 SDK version used.

Regards,
Rashi

View solution in original post

0 Likes
3 Replies