How to recover when error occured

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

cross mob
qiko_3575871
Level 3
Level 3

Could somebody give me a help.

I have some problems.

1. When there is data in the buffer, for example 32 Bytes. But I set the length to 16 Bytes(shorter than the data in the buffer) when transfer data in by using BulkInEndpoint. But it fails.

Then I can't transfer any data in by using BulkInEndpoint. How to solve this?

2. If this happens, how to recover? Now I have to pull the USB out and then plug it in. Is there any other methold?

Thanks!

0 Likes
1 Solution

Hello,

1. FX3 commits data in buffers (buffer size is 32 bytes in your case). When the host requests for data that is less than this size, say 16 bytes, the device sends the entire buffer data to the host which will cause mismatch in the requested data length and the transferred data length. This will cause the endpoint to stall and the XferData fails.

To recover from this, the endpoint stall has to be removed. This is done by the 'Reset Pipe' option in the Control Center.

2. When the 'Reset Pipe' option in the Control Center is clicked, it calls the CyUSBEndPoint.Reset() API which in turn calls the IOCTL_ADAPT_RESET_PIPE in the CYUSB3 driver. This clears the stall condition in the endpoint and enables it for further data communication. When the host driver issues this command, the FX3 firmware must handle the request. This is what I mentioned that it is handled in the CyFxBulkLpApplnUSBSetupCB() function.

Best regards,

Srinath S

View solution in original post

0 Likes
4 Replies
SrinathS_16
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hello,

I assume that you are using FX3 device.

Under such cases, the 'Reset Pipe' option in the USB Control Center can be used to flush the endpoint and reset the buffers in the device. Please refer to the CyFxBulkLpApplnUSBSetupCB() function in FX3 SDK examples.

Best regards,

Srinath S

0 Likes

Thanks!

Yes, I am using FX3 device. And the Reset Pipe works.

But My questions are: 1. Why will this happen? Is it a bug?

                                    2. How could I recover this like Reset Pipe in the USB Control Center? I can not find the functions in CyAPI.                                         And I think the CyFxBulkLpApplnUSBSetupCB()  funtion is in a firmware example, not SDK examples.

0 Likes

Hello,

1. FX3 commits data in buffers (buffer size is 32 bytes in your case). When the host requests for data that is less than this size, say 16 bytes, the device sends the entire buffer data to the host which will cause mismatch in the requested data length and the transferred data length. This will cause the endpoint to stall and the XferData fails.

To recover from this, the endpoint stall has to be removed. This is done by the 'Reset Pipe' option in the Control Center.

2. When the 'Reset Pipe' option in the Control Center is clicked, it calls the CyUSBEndPoint.Reset() API which in turn calls the IOCTL_ADAPT_RESET_PIPE in the CYUSB3 driver. This clears the stall condition in the endpoint and enables it for further data communication. When the host driver issues this command, the FX3 firmware must handle the request. This is what I mentioned that it is handled in the CyFxBulkLpApplnUSBSetupCB() function.

Best regards,

Srinath S

0 Likes

Thank you very much!

For question 2, I had tested CyUSBEnpoint.Reset() yesterday, but it did not work. I will verify it later. If it still doesn't work, I will ask you for help again.

0 Likes