<?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>USBD CDC seems too slow</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68632/usbd-cdc-seems-too-slow</link><description>Hi, 
 I am trying to make a USB to BLE (central) device with nRF52840. I have removed the end character check from the &amp;quot;usbd_ble_uart&amp;quot; example and used a 50ms timeout instead. However, when sending about 240 bytes of data, the timer reaches the timeout</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 26 Nov 2020 12:44:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68632/usbd-cdc-seems-too-slow" /><item><title>RE: USBD CDC seems too slow</title><link>https://devzone.nordicsemi.com/thread/282059?ContentTypeID=1</link><pubDate>Thu, 26 Nov 2020 12:44:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1780c27e-6ca1-4ab6-a9f7-e0f18ad55f2c</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know if this is really answering the question, but in order to figure out a good way to do buffering of the incoming CDC data I made a small example that uses the nrf_queue library to organize a &amp;#39;fifo of buffers&amp;#39;, each 64 bytes in size.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The trick is to pre-load two buffers for the CDC driver when the&amp;nbsp;APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN event occurs, and then provide one more buffer every time the&amp;nbsp;&lt;span&gt;APP_USBD_CDC_ACM_USER_EVT_RX_DONE event occurs.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then you ensure that the CDC driver will always have a buffer in spare, in addition to the buffer currently being written to, so that you don&amp;#39;t get any data slow downs caused by application processing.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You can find my code example here:&lt;br /&gt;&lt;a href="https://github.com/too1/usbd-ble-uart-c/tree/throughput_testing"&gt;https://github.com/too1/usbd-ble-uart-c/tree/throughput_testing&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It only writes the incoming data to the log, but this can be replaced with BLE transfers quite easily.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;br /&gt;Torbjørn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD CDC seems too slow</title><link>https://devzone.nordicsemi.com/thread/281916?ContentTypeID=1</link><pubDate>Wed, 25 Nov 2020 23:22:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ef007e0-4405-4823-a3de-8f5e70eea026</guid><dc:creator>Ros</dc:creator><description>&lt;p&gt;I am using Realterm with Winows10 to send data from a file of 240 bytes long.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Could you please answer the second question?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD CDC seems too slow</title><link>https://devzone.nordicsemi.com/thread/281728?ContentTypeID=1</link><pubDate>Wed, 25 Nov 2020 09:01:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed7395bd-ec4c-4a10-ab84-317b768d89d9</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I will try to do some testing on my end to see if I can reproduce the issue you are seeing. 240 bytes in more than 50ms sounds very slow indeed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How are you sending the data from the host side?&lt;/p&gt;
&lt;p&gt;Are you using some standard terminal software, or a custom application?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD CDC seems too slow</title><link>https://devzone.nordicsemi.com/thread/281478?ContentTypeID=1</link><pubDate>Tue, 24 Nov 2020 09:49:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3dd89da-eddc-4b8e-951e-248ba74124a4</guid><dc:creator>Ros</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the reply. Yes, I am trying to get higher data rate for receiving part. I didn&amp;#39;t show whole code here, the idea is:&lt;/p&gt;
&lt;p&gt;1. The first transfer is setup on APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN event&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;case APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN:
        {
            /*Set up the first transfer*/
            ret_code_t ret = app_usbd_cdc_acm_read_any(&amp;amp;m_app_cdc_acm,
                                                   rx_bytes,
                                                   READ_SIZE);
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is the reason for incrementing rx_buffer pointer as I am trying to setup &amp;quot;app_usbd_cdc_acm_read_any&amp;quot; for next transaction.&lt;/p&gt;
&lt;p&gt;2. For each &amp;quot;APP_USBD_CDC_ACM_USER_EVT_RX_DONE&amp;quot; event, set buffer for next transaction and clear timer. The code is posted in my first post.&lt;/p&gt;
&lt;p&gt;3. On timer timeout event, sends the received data through BLE, and set the buffer pointer for &amp;quot;app_usbd_cdc_acm_read_any&amp;quot; to the beginning.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void timer1_event_handler(nrf_timer_event_t event_type, void * p_context)
{
    // Copy the data and initialize BLE data transmission
    uint16_t len = get_rx_data_len();
    reset_rx_buf_ptr();
    
    memcpy(ble_buffer, rx_buffer, len);
    ble_nus_c_send_data(ble_buffer, len);
    
    /* Set buffer pointer to the beginning */
    ret_code_t ret = app_usbd_cdc_acm_read_any(&amp;amp;m_app_cdc_acm,
                                                   rx_buffer,
                                                   READ_SIZE);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In my testing, the function call to reset the buffer pointer to the beginning is not working. The next data write to the location set by the step 2.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD CDC seems too slow</title><link>https://devzone.nordicsemi.com/thread/281473?ContentTypeID=1</link><pubDate>Tue, 24 Nov 2020 09:30:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0748918-65cb-44c2-8da3-b04688eac7da</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Ras&lt;/p&gt;
&lt;p&gt;It should definitely be possible to get higher data throughput than what you are experiencing.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To be clear, is the problem receiving data from the USB host, or sending it?&lt;br /&gt;The code you attach is showing the receiving part.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, why are you incrementing the rx_buffer before receiving the data?&lt;br /&gt;In the original example the rx_buffer pointer is pointing to an empty buffer, and there is no need to increment this buffer until after the data has been transferred into it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>