Re: Why receiving USB_ERR_CANCELLED error during initial Rx transfer

From: Hans Petter Selasky <hps_at_selasky.org>
Date: Tue, 29 Mar 2022 20:30:06 UTC
On 3/29/22 20:10, Farhan Khan wrote:
> Hi all,
> 
> I am trying to send the initial "wakeup" USB Rx interrupt packet via usbd_transfer_start(), but after running the callback with USB_ST_SETUP, I receive another callback with USB_ERR_CANCELLED as the value of usb_error_t. What might be causing the cancellation?
> 
> Detailed explanation:
> I am opening the pipes, then immediately running usbd_transfer_start() on the Rx Interrupt with this:
> usbd_transfer_start(usc->usc_xfer[ATHN_RX_INTR]);
> 
> The callback function runs this:
> 
> 	case USB_ST_SETUP:
> 		usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
> 		usbd_transfer_submit(xfer);
> 		break;
> 
> The next time the callback is invoked, the USB_GET_STATE macro reports USB_ST_ERROR with the value being USB_ERR_CANCELLED. The manual page suggests that this is the result of a transfer currently happening, but I am not clear on the issue. I have both set and disabled pipe_bof on the Rx Interrupt with the same result.
> 
> I borrowed the above code from the otus(4) driver.

> Please assist. Thanks!

Something in your code is calling usbd_transfer_stop() or unsetup().

--HPS