USB data request cancel

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB data request cancel

Jump to solution
1,018 Views
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?

Labels (2)
Tags (1)
0 Kudos
1 Solution
874 Views
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));

View solution in original post

0 Kudos
2 Replies
875 Views
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 Kudos
874 Views
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 Kudos