How to abort USB transmit?

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
tsichevski
Posts: 35
Joined: Fri Feb 09, 2018 12:44 am
Has thanked: 2 times
Been thanked: 5 times

How to abort USB transmit?

Postby tsichevski » Tue Apr 17, 2018 10:01 am

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

User avatar
Giovanni
Site Admin
Posts: 13754
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 922 times
Been thanked: 787 times
Contact:

Re: How to abort USB transmit?

Postby Giovanni » Tue Apr 17, 2018 12:06 pm

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

tsichevski
Posts: 35
Joined: Fri Feb 09, 2018 12:44 am
Has thanked: 2 times
Been thanked: 5 times

Re: How to abort USB transmit?

Postby tsichevski » Tue Apr 17, 2018 5:08 pm

Thanks a lot, Giovanni!

User avatar
sabdulqadir
Posts: 48
Joined: Fri Mar 23, 2018 7:29 pm
Has thanked: 12 times
Been thanked: 4 times

Re: How to abort USB transmit?

Postby sabdulqadir » Mon May 24, 2021 9:56 pm

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

User avatar
Giovanni
Site Admin
Posts: 13754
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 922 times
Been thanked: 787 times
Contact:

Re: How to abort USB transmit?

Postby Giovanni » Tue May 25, 2021 5:55 am

Hi,

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

Giovanni

User avatar
sabdulqadir
Posts: 48
Joined: Fri Mar 23, 2018 7:29 pm
Has thanked: 12 times
Been thanked: 4 times

Re: How to abort USB transmit?

Postby sabdulqadir » Mon Jun 14, 2021 10:01 pm

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
Attachments
introduction_timeout_for_usbTransmit_usbReceive.patch.zip
(2.22 KiB) Downloaded 30 times

User avatar
Giovanni
Site Admin
Posts: 13754
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 922 times
Been thanked: 787 times
Contact:

Re: How to abort USB transmit?

Postby Giovanni » Tue Jun 15, 2021 5:09 am

Hi,

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

Giovanni

User avatar
sabdulqadir
Posts: 48
Joined: Fri Mar 23, 2018 7:29 pm
Has thanked: 12 times
Been thanked: 4 times

Re: How to abort USB transmit?

Postby sabdulqadir » Tue Jun 15, 2021 7:47 pm

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

User avatar
Giovanni
Site Admin
Posts: 13754
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 922 times
Been thanked: 787 times
Contact:

Re: How to abort USB transmit?

Postby Giovanni » Tue Jun 15, 2021 7:54 pm

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

User avatar
sabdulqadir
Posts: 48
Joined: Fri Mar 23, 2018 7:29 pm
Has thanked: 12 times
Been thanked: 4 times

Re: How to abort USB transmit?

Postby sabdulqadir » Wed Jun 16, 2021 9:50 pm

Awesome, thanks.
Do I need to do anything on my end to help?

Thanks,
AQ


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 5 guests