USB data request cancel

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

USB data request cancel

跳至解决方案
1,992 次查看
martindusek
Contributor V

Hi,

I use this function to send data from my USB device to host PC on BULK IN endpoint:

usb_status_t USB_DeviceSendRequest(usb_device_handle handle, uint8_t endpointAddress, uint8_t *buffer, uint32_t length)

Host PC app reads data using libusb. The app can be suddenly switched off with data send request pending. When the app is launched again, it sends command to my USB device to cancel any pending requests (the app doesn't want to receive any old data, as they are invalid). So, my USB device calls:

usb_status_t USB_DeviceCancel(usb_device_handle handle, uint8_t endpointAddress)

on that BULK IN endpoint. It returns success.

However, when I start to send data on my BULK IN endpoint again, I can see that my app receives also old data from that cancelled request. I assume there is something wrong with USB_DeviceCancel.

How to use USB_DeviceCancel to correctly handle my scenario?

标签 (2)
标记 (1)
0 项奖励
回复
1 解答
1,848 次查看
martindusek
Contributor V

Fixed. I called USB_DeviceCancel without specifying endpoint direction on endpointAddress parameter. It is a little confusing that on other USB_DeviceXXX functions one doesn't have to specify the direction, but on USB_DeviceCancel it is needed. I didn't notice that till now...

Correct way is:

USB_DeviceCancel(myClassHandle->handle, myClassHandle->bulkIn.ep | (USB_IN << 7U));

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,849 次查看
martindusek
Contributor V

Fixed. I called USB_DeviceCancel without specifying endpoint direction on endpointAddress parameter. It is a little confusing that on other USB_DeviceXXX functions one doesn't have to specify the direction, but on USB_DeviceCancel it is needed. I didn't notice that till now...

Correct way is:

USB_DeviceCancel(myClassHandle->handle, myClassHandle->bulkIn.ep | (USB_IN << 7U));

0 项奖励
回复
1,848 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Could you provided the chip part number and MCUXpresso SDK version?

Could you share your experience about how to regenerate this issue?

We want to do a test locally. Thank you.


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复