Skip to main content
Sebastian G.
Associate II
December 6, 2016
Question

USB CDC VCP device flow control?

  • December 6, 2016
  • 9 replies
  • 2872 views

Posted on December 06, 2016 at 15:36

The function CDC_Receive_HS() is not meant to be exited until all data is copied from the USB stack.

Is there a way to not do this? I am not using an operating system, so not leaving the function means blocking every way to empty the buffers to copy into!? This makes transferring a firmware via VCP impossible, because there is no way to implement client/device side flow control.

<LINK NO LONGER ACTIVE>

 mentioned the same issue in his last post here: '

<LINK NO LONGER ACTIVE>

This topic has been closed for replies.

9 replies

Tesla DeLorean
Guru
December 6, 2016
Posted on December 06, 2016 at 16:34

>>

This makes transferring a firmware via VCP impossible, because there is no way to implement client/device side flow control.

Use something like X-MODEM which inherently has flow control and integrity checking to do firmware updates. The writing/erasing of Flash can stall the processor to a point that real-time operation is impossible unless everything is running from RAM.

You'd need to virtualize the CTS/RTS or DTR/DSR pins to implement flow control.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Sebastian G.
Associate II
December 6, 2016
Posted on December 06, 2016 at 16:46

Yes I have implemented Y-Modem in my old system. It is painfully slow compared to what is possible with US, is at least another 1k of code size and adds an extra layer to everything.

AKA: considering USB spec it should not be needed, but until now it is a solution

USB CDC has enough flow control built in for the purpose (-> NAK until buffer empty). The limitation is the named function 

CDC_Receive_HS() that I don't know how not to leave without an RTOS..

Tesla DeLorean
Guru
December 6, 2016
Posted on December 06, 2016 at 17:58

Without an RTOS you'd need to copy the data to another buffer, leave, and handle the data in a worker task, for the old SPL examples this could be the main() while loop

Beyond a basic demo most of the ST code would need to be tailored to handle anything remotely complicated.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Walid FTITI_O
Visitor II
December 7, 2016
Posted on December 07, 2016 at 16:42

Hi

Gessler.Sebastia

,

Check the response submitted today in the other

https://community.st.com/0D50X00009XkewpSAB

. It seems useful for tou

-Hannibal-

If aresponse is useful, you would mention that by clicking the correct button. Thank you for the contribution

mario basanta
Associate
April 26, 2017
Posted on April 26, 2017 at 09:09

I have a similar question about this , can I use flow control (xon xoff, dts rts , etc)? When I use the CDC usb virtual com.

this feature it's included with the CDC usb library or examples . 

Thanks in advance .