<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>USB CDC ACM how to do flow control for RX data - nrf5340</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102915/usb-cdc-acm-how-to-do-flow-control-for-rx-data---nrf5340</link><description>Hello, 
 
 I am having an esp32 connected to nrf5340 and I am doing firmware update for the esp32 by bypassing the UART of esp32 via the USB CDC ACM of nrf5340. 
 So basically esp32 is connected to nrf5340 via UART and the usb of nrf5340 is connected</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 04 Oct 2023 06:47:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102915/usb-cdc-acm-how-to-do-flow-control-for-rx-data---nrf5340" /><item><title>RE: USB CDC ACM how to do flow control for RX data - nrf5340</title><link>https://devzone.nordicsemi.com/thread/448742?ContentTypeID=1</link><pubDate>Wed, 04 Oct 2023 06:47:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec9aba1c-4fe0-44b2-982e-0ec251b18ab2</guid><dc:creator>Kyrre Aalerud</dc:creator><description>&lt;p&gt;Our issue is actually the other way. The Host has troubles not corrupting our data.&lt;br /&gt;We can see classic signs of data being overwritten by newer data in the resulting datastream with unique sequences of data 32-64k further on in &amp;quot;time&amp;quot; appearing at an earlier time in the resulting data.&lt;/p&gt;
&lt;p&gt;At first we though we were overfilling the virtual uart but it&amp;#39;s circular buffer does not allow for that to happen. The error happens later in the chain. Correct amount of bytes usually arrive (We transmit 32-64Mbyte size files) but data has been garbled. (On very rare occasions&amp;nbsp;some bytes do get lost and&amp;nbsp;total transmission received is a bit shorter.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM how to do flow control for RX data - nrf5340</title><link>https://devzone.nordicsemi.com/thread/448485?ContentTypeID=1</link><pubDate>Mon, 02 Oct 2023 10:39:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a80e3c7-abce-48f8-91ea-3b5235214d24</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I do not believe that virtual com port (UART over USB) support flow control the same way as UART over an actual hardware COM port, instead for USB it&amp;#39;s intended that the peer NACK communicaton if it&amp;#39;s not able to handle the incomming data (this is done by for instance not calling &lt;span&gt;uart_fifo_read() until it&amp;#39;s able to handle the data). Alternatively you can add some overhead to the communication where you have bidirectional data to ensure that this does not happen in the first place&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM how to do flow control for RX data - nrf5340</title><link>https://devzone.nordicsemi.com/thread/448275?ContentTypeID=1</link><pubDate>Fri, 29 Sep 2023 08:37:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:023e3843-c74e-4813-b523-d5f445a692b3</guid><dc:creator>Kyrre Aalerud</dc:creator><description>&lt;p&gt;I would also very much like to know the answer to this.&lt;/p&gt;
&lt;p&gt;There appears to be line control handling in the uart layer and cdc_acm but I cannot find&amp;nbsp;out how to receive any callback on the state of the RTS/CTS virtual linkup. I also can not find any code of this&amp;nbsp;being handled in the stack and on the transmit side the tx interrupt of cdc_acm seems to be only reliant on the ring buffer being able to accept more data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM how to do flow control for RX data - nrf5340</title><link>https://devzone.nordicsemi.com/thread/442208?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2023 07:47:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3c780c9-8bff-4fb9-b1b8-1f730487fc4c</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Can you try to increase the buffer sizes?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For instance try to increase&amp;nbsp;RING_BUF_SIZE in main.c and/or increase&amp;nbsp;CDC_ACM_BUFFER_SIZE in cdc_acm.c to see if that affect the problem? I can see that&amp;nbsp;CDC_ACM_BUFFER_SIZE is by default set to&amp;nbsp;CONFIG_CDC_ACM_BULK_EP_MPS, but try to instead set &lt;span&gt;CDC_ACM_BUFFER_SIZE&amp;nbsp;&lt;/span&gt;to a larger value.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM how to do flow control for RX data - nrf5340</title><link>https://devzone.nordicsemi.com/thread/441994?ContentTypeID=1</link><pubDate>Fri, 18 Aug 2023 05:07:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5036a52b-e664-4ebe-8787-4b310759f072</guid><dc:creator>vinodsdw</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;I foud the real issue.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When I am trying to send more bytes (more than 500 bytes)&amp;nbsp; from PC to the device via USB, then the device is getting stuck. I am trying the same exapmle of echo. From PC I am sending using pyserial and if I decrease the single packet size to around 300bytes, it is working non-stop without any issue. If I increase&amp;nbsp; to 400 it starts getting stuck very fast with in few ping-pong.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM how to do flow control for RX data - nrf5340</title><link>https://devzone.nordicsemi.com/thread/441764?ContentTypeID=1</link><pubDate>Thu, 17 Aug 2023 07:21:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a39fe4dd-1a65-4942-9746-6cd257910b52</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi again,&lt;/p&gt;
[quote user="vinodsdw"]&lt;p&gt;So are you suggesting to skip reading from fifo inside the irq ?&lt;/p&gt;
&lt;p&gt;If so, the IRQ will git again and again&lt;/p&gt;[/quote]
&lt;p&gt;At least for test I am suggesting to skip reading from fifo inside the irq yes.&lt;/p&gt;
&lt;p&gt;Looking at the implementation I am not sure the IRQ will trigger again and again, are you sure of this? Have you tried it?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM how to do flow control for RX data - nrf5340</title><link>https://devzone.nordicsemi.com/thread/441751?ContentTypeID=1</link><pubDate>Thu, 17 Aug 2023 06:23:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:674e838c-68ff-460e-bc52-ef43ab185ea2</guid><dc:creator>vinodsdw</dc:creator><description>&lt;p&gt;The uart_fifo_read is inside interrupt_handler.&lt;/p&gt;
&lt;p&gt;So are you suggesting to skip reading from fifo inside the irq ?&lt;/p&gt;
&lt;p&gt;If so, the IRQ will git again and again&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM how to do flow control for RX data - nrf5340</title><link>https://devzone.nordicsemi.com/thread/441684?ContentTypeID=1</link><pubDate>Wed, 16 Aug 2023 15:10:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:769b9a4c-7a34-48f6-a334-0e5a802ab267</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Looking at the main.c of cdc_acm example, I am wondering if just delaying&amp;nbsp;uart_fifo_read() will solve the problem here. I do get the impression that the USB will stall incomming data if the fifo is not &amp;quot;unloaded&amp;quot; fast enough.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>