minimize waiting time in API WaitForXfer

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

cross mob
kjlee_2215711
Level 2
Level 2
5 questions asked 10 replies posted 10 sign-ins

Hello,

We are using  CYUSB3014-BZXI  (EZ-USB® FX3: SuperSpeed USB Controller) and communicate  with 4 BULK endpoint to Windows PC.

If we use  WaitForXfer with TimeOut over 1000msec, there is no issue but we have about 300msec response time.

But, we need to get 1msec response time.

If we use WaitForXfer with TimeOut around 100 msec, we can get from 1msec to 310msec response time or get errors.

What is the minimum waiting time?

How to make to get minimum response time in USB communication?

Thanks for your prompt help in advance.

KJ

 

0 Likes
1 Solution
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello KJ,

As per my understanding, you are using one Begin, Wait and Finish APIs for transferring one packet of 1024 bytes. Please correct me if my understanding is wrong. If my understanding is correct, can you please try to queue up multiple transfers as done in the streamer Application? Please let me know if you find any improvement (change in transaction time) after making this modification. In addition to this, please try changing the size of the transfer from 1024 to 1023 and let me know if there are any changes with this modification on both the default code and the modification mentioned above.

Also, please confirm that you are using the latest version of cyusb3 driver (1.2.3.20). Also, please confirm that you are using CyAPI.lib that comes along with FX3 SDK.

Best Regards,
Jayakrishna

View solution in original post

0 Likes
11 Replies
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello KJ,

Please let me know what exactly was meant by "response time"? Is it the time for the transaction to get complete?

As mentioned in  the CyAPI.pdf, the timeout parameter is used to limit the waiting time for the transaction to complete. If the transaction is not complete within the timeout specified, then the transaction will fail.

If the number of bytes to be transferred is large, then it is likely to have a greater transaction time. In this case, if you configure the timeout to a smaller value, then it is more likely to see failures. So, we recommend to use a greater value for timeout parameter in the API WaitForXfer. Can you please try using a timeout of 500ms and let me know if you are seeing any failures?

Best Regards,
Jayakrishna
0 Likes

Hi Jayakrishna,

Thank you for your reply.

I would like to clarify my question why the transaction time is affected by the value of TimeOut. 

The "response time" meant  the time for the transfer to complete. Yes, you're right.

1. I tested the TimeOut value using the synchronous XferData method and the asynchronous BeginDataXfer/WaitForXfer/FinishDataXfer method.

2. The result is same. The TimeOut number gets smaller, the shorter the transaction time. 

3. I can't find the explanation of the reason in CyAPI.pdf.  I guess the TimeOut is not connected with waiting but also connected with processing way.

4. Is there any way or method to get shortest (fastest) transaction time?

Thanks,

KJ

 

0 Likes

Hello KJ,

Please let me know the following details:

1. Which endpoint is used for the transfer?

2. What is the size of the transfer?

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

Please refer below.

1. Which endpoint is used for the transfer? 

--> We use bulk endpoint.

2. What is the size of the transfer?

-->  1024 Bytes

If you have any more questions, please let me know.

Thanks,

KJ

 

 

0 Likes

Hello KJ,

Please let me know if the size of transfer is always 1024. That is, are you transferring 1024 bytes always and find that the transaction time is varying with the timeout? Or are you changing the transfer size also during testing?

Is it possible to share the project for us to understand better? 

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

Yes, the transfer data is in the same buffer and always 1024 bytes and the transaction time is varying with the TimeOut.  

All of the source of the project is not allowed to disclosure by company policy.  Below is some code snippet.

cs.Format("%s_UMSG_OUT_%d", BOARD_MODEL, nBoard);
outOvLap.hEvent = CreateEvent(NULL, false, false, cs);

TimeOut = 2000;

UCHAR *outContext = pOutEndpt->BeginDataXfer((PUCHAR)bufData,1024, &outOvLap);
bRet = pOutEndpt->WaitForXfer(&outOvLap, TimeOut );
if(bRet == TRUE)
{
bRet = pOutEndpt->FinishDataXfer((PUCHAR)bufData, length, &outOvLap, outContext);
}
else
{
pOutEndpt->Abort();
pOutEndpt->Reset();
}

 

We can get transaction time around 300msec, but If we test same code as above (except changing TimeOut = 100;) we can get transaction time  below 1msec.

Hope this helps for your understanding.

 

Best Regards,

KJ

 

 

0 Likes

Hello KJ,

Thank you for the detailed description of the problem. I am able to understand the issue from your previous response. Can you please let me know how the transaction time is measured?

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

We measured it in 2 ways as below.

1. We measured it in our board. Actually, our board receive the signal from USB and generate UART sinal, we measured from UART signal.

Actually, above code snippet continuous 5 times test.

2. We measured it from the source code in Windows PC (from the begining  above code snippet and after it using  std::chrono::system_clock::now() )

The result 1 and 2 are same.

Best Regards,

KJ

 

0 Likes
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello KJ,

As per my understanding, you are using one Begin, Wait and Finish APIs for transferring one packet of 1024 bytes. Please correct me if my understanding is wrong. If my understanding is correct, can you please try to queue up multiple transfers as done in the streamer Application? Please let me know if you find any improvement (change in transaction time) after making this modification. In addition to this, please try changing the size of the transfer from 1024 to 1023 and let me know if there are any changes with this modification on both the default code and the modification mentioned above.

Also, please confirm that you are using the latest version of cyusb3 driver (1.2.3.20). Also, please confirm that you are using CyAPI.lib that comes along with FX3 SDK.

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

It was api version issue(CyAPI.lib).

Thank you very much for your help.

Best Regards,

KJ

0 Likes

Hello KJ,

Thank you for the update. We are glad to hear that the issue is resolved.

Best Regards,
Jayakrishna
0 Likes