Unexpected delay in consecutive USB packets over Bulk In Endpoint

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

cross mob
AvC_4590276
Level 1
Level 1

Dear Readers,

I am using the Streamer application and 'bulk source sink' firmware image for testing.

when I am reading the 32 kb from the application the time taken to read the 32 KB is sometimes is less than 1 millisecond and sometime it is coming 15~ 16 milliseconds.

please find below the log which shows the 100 MB data read from the application and these logs are coming only when BeginDataXfer or WaitForXfer or FinishDataXfer is taking more than 1 milliseconds.

here Total difference:- time taken to execute BeginDataXfer,WaitForXfer and FinishDataXfer function.

begin Diff:- time taken to execute BeginDataXfer

Wait4Xfer:- time taken to execute WaitForXfer

FinishDiff:- time taken to execute FinishDataXfer

0 Likes
1 Solution

Hello,

The time difference for WaitForXfer calculated in your application is not just the time out value.

WaitForXfer internally calls WaitForSingleObject windows API whose return codes are as follows WaitForSingleObject function (synchapi.h) - Win32 apps | Microsoft Docs

CyTrue will be returned by WaitForXfer when WAIT_OBJECT_0 is returned code. So the time that is calculated is complete time for calling the API , the API's execution.

You can check the return value of WaitForSingleObject API to check whether the return code WAIT_TIMEOUT to confirm that the USB transfers do not take more than 1 ms

I tested the bulksrcsink code with the streamer app with the settings mentioned below and didn't see any failures.

Packets per Xfer is 2, Xfer to Queue is 16, and the timeout is 1 ms.

Regards,

Rashi

Regards,
Rashi

View solution in original post

0 Likes
5 Replies
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

when I am reading the 32 kb from the application the time taken to read the 32 KB is sometimes is less than 1 millisecond and sometime it is coming 15~ 16 milliseconds.

>> Please confirm whether the transfer is through Bulk IN or Bulk OUT endpoint (i.e. is it writing to FX3 or reading from FX3)

- Are you using the default bulksrcsink example of the SDK? Which SDK version is used?

- I didn't find the logs. Please share the snippets of the streamer application (for both the condition) for us to check the different fields of the application .

- Please let me know if any modifications are done to streamer application for calculating the time difference?

Regards,

Rashi

Regards,
Rashi
0 Likes

Hi,

Please confirm whether the transfer is through Bulk IN or Bulk OUT endpoint (i.e. is it writing to FX3 or reading from FX3)

>>The transfer is through Bulk IN endpoint.(i.e. reading from FX3)

- Are you using the default bulksrcsink example of the SDK? Which SDK version is used?

>>Yes, I am using default bulksrksink example of the SDK and SDK version is 1.3.4.

Sorry, i have missed the log file please find it below.

pastedImage_0.png

here Total difference:- time taken to execute BeginDataXfer,WaitForXfer and FinishDataXfer function.

begin Diff:- time taken to execute BeginDataXfer

Wait4Xfer:- time taken to execute WaitForXfer

FinishDiff:- time taken to execute FinishDataXfer

I am written a function which read the particular amount of data (i.e. 100 MB, 1GB) and write it to the file.
https://drive.google.com/open?id=1ja35qOnUu6iC8RoakVjHAxHNAPYklU3q

https://drive.google.com/open?id=1ja35qOnUu6iC8RoakVjHAxHNAPYklU3q

Even if i reduced the wait4xfer api  parameter time still sometimes it is taking 16 ms.

0 Likes

Hello,

From the logs that you have shared, I didn't find too much variation in the wait4xfer time. This is as expected. It will take some time to transfer data. Please let me know the value of Packets per Xfer, Xfer to Queue and timeout

In the default streamer application, the time is recorded from the instance when BeginDataXfer is being called and it stops when FinishDataXfer,  similar to your implementation. This time difference is used to calculate the Xfer rate. To increase the Xfer rate by decreasing the time to transfer the data.

Please refer to this application note https://www.cypress.com/documentation/application-notes/an86947-optimizing-usb-30-throughput-ez-usb-...  which mentions different aspects which can be tweaked to increase the xfer rate.

Regards,

Rashi

Regards,
Rashi
0 Likes

Hi,

The value of Packets per Xfer is 2, Xfer to Queue is 16, and the timeout is 1 ms.

The timeout value is 1 ms then why are the begindataxfer and wait4xfer is taking much longer time than 1 ms.

0 Likes

Hello,

The time difference for WaitForXfer calculated in your application is not just the time out value.

WaitForXfer internally calls WaitForSingleObject windows API whose return codes are as follows WaitForSingleObject function (synchapi.h) - Win32 apps | Microsoft Docs

CyTrue will be returned by WaitForXfer when WAIT_OBJECT_0 is returned code. So the time that is calculated is complete time for calling the API , the API's execution.

You can check the return value of WaitForSingleObject API to check whether the return code WAIT_TIMEOUT to confirm that the USB transfers do not take more than 1 ms

I tested the bulksrcsink code with the streamer app with the settings mentioned below and didn't see any failures.

Packets per Xfer is 2, Xfer to Queue is 16, and the timeout is 1 ms.

Regards,

Rashi

Regards,
Rashi
0 Likes