Page 1 of 2

How to abort USB transmit?

Posted: Tue Apr 17, 2018 10:01 am
by tsichevski
Hi all,

I use hal_usb driver in ChibiOS_17.6.3 to transmit data from a STM32 device to host computer.
I start transfer with the usbStartTransmitI(), and wait for the "data transmitted" interrupt.
The question is: how can I prematurely abort the transfer which is already started?

Regards,
Vladimir

Re: How to abort USB transmit?

Posted: Tue Apr 17, 2018 12:06 pm
by Giovanni
Hi,

The driver is not able to interrupt ongoing transactions, you may split transaction in smaller ones and check an "abort" flag before starting the next one.

Giovanni

Re: How to abort USB transmit?

Posted: Tue Apr 17, 2018 5:08 pm
by tsichevski
Thanks a lot, Giovanni!

Re: How to abort USB transmit?

Posted: Mon May 24, 2021 9:56 pm
by sabdulqadir
Hi Giovanni,
If we need a for-sure way to abort a transaction (or time it out), no matter how small, how would you think we should proceed?
I am guessing this would mean "getting under the hood".

Thanks,
AQ

Re: How to abort USB transmit?

Posted: Tue May 25, 2021 5:55 am
by Giovanni
Hi,

You should find a way to reset the endpoint at register level then stop the driver to clean up everything.

Giovanni

Re: How to abort USB transmit?

Posted: Mon Jun 14, 2021 10:01 pm
by sabdulqadir
Hi Giovanni,
Attached is a patch I did to timeout on USB transactions. Can you check it out and help provide some feedback?
Any red flags, any concerns etc.

Thanks,
AQ

Re: How to abort USB transmit?

Posted: Tue Jun 15, 2021 5:09 am
by Giovanni
Hi,

The only concern is that it would break other USB implementations some of which I don't manage.

Giovanni

Re: How to abort USB transmit?

Posted: Tue Jun 15, 2021 7:47 pm
by sabdulqadir
So which implementation are you talking about?
We are not changing any of the existing code. So existing implementation should not be affected. If they start using the new API, you are worried it would break?
Any way to get them on board?


Thanks,
AQ

Re: How to abort USB transmit?

Posted: Tue Jun 15, 2021 7:54 pm
by Giovanni
Hi,

There are the STM32 USBv1 and the AVR official drivers (which I don't even handle), some others are not in the official repository.

This is the problem with changes that break the LLD API, it needs a way to fit on top of current, unmodified LLDs. LLDs could export something like USB_LLD_SUPPORTS_TIMEOUTS, other drivers do this, see SPI and circular API support, not all LLDs support that.

It is not a big deal if handled properly.

Moving this topic in "change requests".

Giovanni

Re: How to abort USB transmit?

Posted: Wed Jun 16, 2021 9:50 pm
by sabdulqadir
Awesome, thanks.
Do I need to do anything on my end to help?

Thanks,
AQ