<?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: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/104441/usb-cdc-acm-rx-data-gets-overwritten-in-app_usbd_cdc_acm_read_any-at-end-of-data-transmission</link><description>To handle RX of USB CDC ACM we are polling data using: 
 ret = app_usbd_cdc_acm_read_any(&amp;amp;m_app_cdc_acm, m_rx_buffer, MIN(BUFFER_SIZE,size)); 
 On 
 case NRF_SUCCESS: 
 rx_size = app_usbd_cdc_acm_rx_size(&amp;amp;m_app_cdc_acm); copy_rx_data(buffer, n, m_rx_buffer</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Dec 2023 13:19:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/104441/usb-cdc-acm-rx-data-gets-overwritten-in-app_usbd_cdc_acm_read_any-at-end-of-data-transmission" /><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/458737?ContentTypeID=1</link><pubDate>Mon, 04 Dec 2023 13:19:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a965ea9c-fce5-44b3-a25f-11184a47d755</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;I tried to get Linux working but wasn&amp;#39;t very successful. I admittedly didn&amp;#39;t try&amp;nbsp;that&amp;nbsp;much though, because I decided to fall back to the Python options.&lt;/p&gt;
&lt;p&gt;With Python, I was able to reproduce some problems... The state machine&amp;nbsp;in usb.c resulted in&amp;nbsp;app_usbd_cdc_acm_read_any() being called even when the transmission is over, which leads to an infinite loop where&amp;nbsp;app_usbd_cdc_acm_read_any() would return 8,&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group__nrf__error.html#gaf0aff2ba7864b34a36b4a96986e1851e"&gt;NRF_ERROR_INVALID_STATE&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Furthermore, I see that with both the working_sample and not_working_sample...&lt;/p&gt;
&lt;p&gt;This test was run with &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/104441/usb-cdc-acm-rx-data-gets-overwritten-in-app_usbd_cdc_acm_read_any-at-end-of-data-transmission/451788"&gt;usb-test-packed-2.tgz&lt;/a&gt;&amp;nbsp;with these modifications:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A 5000ms delay after usb_config() in main.c, as discussed &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/104441/usb-cdc-acm-rx-data-gets-overwritten-in-app_usbd_cdc_acm_read_any-at-end-of-data-transmission/452633"&gt;in this reply&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;span&gt;usb.c::usb_read_buf()&lt;/span&gt; to not flush the log, as&amp;nbsp;suggested by my colleague &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/104441/usb-cdc-acm-rx-data-gets-overwritten-in-app_usbd_cdc_acm_read_any-at-end-of-data-transmission/454645"&gt;in this reply&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;span&gt;usb.c::usb_read_buf() to let the debugger stop the execution if&amp;nbsp;app_usbd_cdc_acm_read_any() starts returning 8 too many times.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span&gt;Due to circumstances, I will be away from DevZone for the several weeks. However, I have made sure that&amp;nbsp;another engineer will be arranged to support you.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I am really sorry that it has taken so much time and I&amp;nbsp;essentially hasn&amp;#39;t been able to help at all.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Below are overviews of&amp;nbsp;my work &lt;em&gt;&lt;span style="text-decoration:underline;"&gt;and&lt;/span&gt;&lt;/em&gt; all related files attached, for both your and Susheel&amp;#39;s references.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Python 3 script:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="python"&gt;# Require pyserial ~3.5. Installs with `pip install pyserial`
import serial

working_sample =        &amp;quot;ABC00DEFGHIJKLMNOP;ABC01DEFGHIJKLMNOPQR;ABC02DEFGHIJKLMNOPQR;ABC03DEFGHIJKLMNOPQR;ABC04DEFGHIJKLMNOPQR;ABC05DEFGHIJKLMNOPQR;ABC06DEFGHIJKLMNOP;ABC07DEFGHIJKLMNOPQR;ABC08DEFGHIJKLMNOPQR;ABC09DEFGHIJKLMNOPQR;ABC10DEFGHIJKLMNOPQR;ABC11DEFGHIJKLMNOP;ABC12DEFGHIJKLMNOPQR;ABC13DEFGHIJKLMNOPQR;ABC14DEFGHIJKLMNOPQR;ABC15DEFGHIJKLMNOP;ABC16DEFGHIJKLMNOPQR;ABC17DEFGHIJKLMNOPQR;ABC18DEFGHIJKLMNOPQR;ABC19DEFGHIJKLMNOP;ABC20DEFGHIJKLMNOP;ABC21DEFGHIJKLMNOP;ABC22DEFGHIJKLMNOP;ABC23DEFGHIJKLMNOP;ABC24DEFGHIJKL;ABC26DEFGHIJKL;ABC27DEFGHIJKL;ABC28DEFGHIJKL;ABC29DEFGHIJKL;ABC30DEFGHIJKLM;ABC31DEFGHIJKLM;EOT;&amp;quot;
not_working_sample =    &amp;quot;ABC00DEFGHIJKLMNOP;ABC01DEFGHIJKLMNOPQR;ABC02DEFGHIJKLMNOPQR;ABC03DEFGHIJKLMNOPQR;ABC04DEFGHIJKLMNOPQR;ABC05DEFGHIJKLMNOPQR;ABC06DEFGHIJKLMNOP;ABC07DEFGHIJKLMNOPQR;ABC08DEFGHIJKLMNOPQR;ABC09DEFGHIJKLMNOPQR;ABC10DEFGHIJKLMNOPQR;ABC11DEFGHIJKLMNOP;ABC12DEFGHIJKLMNOPQR;ABC13DEFGHIJKLMNOPQR;ABC14DEFGHIJKLMNOPQR;ABC15DEFGHIJKLMNOP;ABC16DEFGHIJKLMNOPQR;ABC17DEFGHIJKLMNOPQR;ABC18DEFGHIJKLMNOPQR;ABC19DEFGHIJKLMNOP;ABC20DEFGHIJKLMNOP;ABC21DEFGHIJKLMNOP;ABC22DEFGHIJKLMNOP;ABC23DEFGHIJKLMNOP;ABC24DEFGHIJKL;ABC26DEFGHIJKL;ABC27DEFGHIJKL;ABC28DEFGHIJKL;ABC29DEFGHIJKL;ABC30DEFGHIJKLM;EOT;&amp;quot;


def send_message(port, message):
    # Configure serial port
    ser = serial.Serial()
    ser.baudrate = 9600  # Set baud rate to 9600
    ser.timeout = 5  # Set timeout to 1 second
    ser.port = port

    try:
        # Open the serial port
        ser.open()
    except serial.SerialException as e:
        print(&amp;quot;Could not open serial port: {}&amp;quot;.format(str(e)))
        return

    # Write the message to the serial port
    try:
        ser.write(message.encode())
    except Exception as e:
        print(&amp;quot;Could not write to serial port: {}&amp;quot;.format(str(e)))
    finally:
        # Close the serial port
        ser.close()


def main():
    send_message(&amp;quot;COM30&amp;quot;, working_sample)
    # send_message(&amp;quot;COM30&amp;quot;, not_working_sample)


if __name__ == &amp;#39;__main__&amp;#39;:
    main()

&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;One sample RTT log when tested with working_sample string:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app: APP_USBD_EVT_POWER_DETECTED
&amp;lt;info&amp;gt; app: Try NOP command to see if USB is connected ...
.&amp;lt;info&amp;gt; app: APP_USBD_EVT_POWER_READY
&amp;lt;info&amp;gt; app: APP_USBD_EVT_STARTED
..&amp;lt;info&amp;gt; app: APP_USBD_EVT_DRV_SUSPEND
.&amp;lt;info&amp;gt; app: APP_USBD_EVT_DRV_RESUME
..........................................................................................&amp;lt;info&amp;gt; app:
Get items ...
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 29
&amp;lt;info&amp;gt; app: m_rx_buffer: ABC00DEFGHIJKLMNOP;ABC01DEFGH
&amp;lt;info&amp;gt; app: resp: ABC01DEFGH (resp_len: 10)
&amp;lt;info&amp;gt; app: row: ABC00DEFGHIJKLMNOP; (resp_len: 10, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 19
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKLMNOPQR;ABC02DEF
&amp;lt;info&amp;gt; app: resp: ABC02DEF (resp_len: 8)
 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 16
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC
&amp;lt;info&amp;gt; app: resp: ABC (resp_len: 3)
&amp;lt;info&amp;gt; app: row: ABC02DEFGHIJKLMNOPQR; (resp_len: 3, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 26
&amp;lt;info&amp;gt; app: m_rx_buffer: 03DEFGHIJKLMNOPQR;ABC04DEF
&amp;lt;info&amp;gt; app: resp: ABC04DEF (resp_len: 8)
 0)
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 21
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC05DEF
&amp;lt;info&amp;gt; app: resp: ABC05DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC04DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 17
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC0
&amp;lt;info&amp;gt; app: resp: ABC0 (resp_len: 4)
&amp;lt;info&amp;gt; app: row: ABC05DEFGHIJKLMNOPQR; (resp_len: 4, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
_RX_DONE: rx_size = 25
0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 19
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKLMNOPQR;ABC08DEF
&amp;lt;info&amp;gt; app: resp: ABC08DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC07DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 20
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC09DE
&amp;lt;info&amp;gt; app: resp: ABC09DE (resp_len: 7)
&amp;lt;info&amp;gt; app: row: ABC08DEFGHIJKLMNOPQR; (resp_len: 7, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 21
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC11DEF
&amp;lt;info&amp;gt; app: resp: ABC11DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC10DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 21
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOP;ABC12DEFGH
&amp;lt;info&amp;gt; app: resp: ABC12DEFGH (resp_len: 10)
&amp;lt;info&amp;gt; app: row: ABC11DEFGHIJKLMNOP; (resp_len: 10, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 21
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC14DEF
&amp;lt;info&amp;gt; app: resp: ABC14DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC13DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 21
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC15DEF
&amp;lt;info&amp;gt; app: resp: ABC15DEF (resp_len: 8)
 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 3
&amp;lt;info&amp;gt; app: m_rx_buffer: GHI
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 18
&amp;lt;info&amp;gt; app: m_rx_buffer: JKLMNOP;ABC16DEFGH
&amp;lt;info&amp;gt; app: resp: ABC16DEFGH (resp_len: 10)
&amp;lt;info&amp;gt; app: row: ABC15DEFGHIJKLMNOP; (resp_len: 10, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 6
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKL
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 15
&amp;lt;info&amp;gt; app: m_rx_buffer: MNOPQR;ABC19DEF
&amp;lt;info&amp;gt; app: resp: ABC19DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC18DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 21
0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 19
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKLMNOP;ABC21DEFGH
&amp;lt;info&amp;gt; app: resp: ABC21DEFGH (resp_len: 10)
&amp;lt;info&amp;gt; app: row: ABC20DEFGHIJKLMNOP; (resp_len: 10, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 9
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKLMNOP;
&amp;lt;info&amp;gt; app: resp:  (resp_len: 0)
)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 29
&amp;lt;info&amp;gt; app: m_rx_buffer: ABC22DEFGHIJKLMNOP;ABC23DEFGH
&amp;lt;info&amp;gt; app: resp: ABC23DEFGH (resp_len: 10)
&amp;lt;info&amp;gt; app: row: ABC22DEFGHIJKLMNOP; (resp_len: 10, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 19
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKLMNOP;ABC24DEFGH
0)
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 16
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKL;ABC26DEFGHI
&amp;lt;info&amp;gt; app: resp: ABC26DEFGHI (resp_len: 11)
&amp;lt;info&amp;gt; app: row: ABC24DEFGHIJKL; (resp_len: 11, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 18
&amp;lt;info&amp;gt; app: m_rx_buffer: JKL;ABC27DEFGHIJKL
&amp;lt;info&amp;gt; app: row: ABC26DEFGHIJKL; (resp_len: 14, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 15
&amp;lt;info&amp;gt; app: m_rx_buffer: ;ABC28DEFGHIJKL
&amp;lt;info&amp;gt; app: resp: ABC28DEFGHIJKL (resp_len: 14)

&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 15
&amp;lt;info&amp;gt; app: m_rx_buffer: ;ABC29DEFGHIJKL
&amp;lt;info&amp;gt; app: resp: ABC29DEFGHIJKL (resp_len: 14)
&amp;lt;info&amp;gt; app: row: ABC28DEFGHIJKL; (resp_len: 14, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 15
&amp;lt;info&amp;gt; app: m_rx_buffer: ;ABC30DEFGHIJKL
&amp;lt;info&amp;gt; app: resp: ABC30DEFGHIJKL (resp_len: 14)
&amp;lt;info&amp;gt; app: row: ABC29DEFGHIJKL; (resp_len: 14, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: m_rx_buffer: M
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 0
&amp;lt;info&amp;gt; app: m_rx_buffer:
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8

// Breakpoint hit&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;One sample RTT log when tested with not_working_sample string:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app: APP_USBD_EVT_POWER_DETECTED
&amp;lt;info&amp;gt; app: Try NOP command to see if USB is connected ...
.&amp;lt;info&amp;gt; app: APP_USBD_EVT_POWER_READY
&amp;lt;info&amp;gt; app: APP_USBD_EVT_STARTED
..&amp;lt;info&amp;gt; app: APP_USBD_EVT_DRV_SUSPEND
.&amp;lt;info&amp;gt; app: APP_USBD_EVT_DRV_RESUME
......................................................................&amp;lt;info&amp;gt; app:
Get items ...
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 29
&amp;lt;info&amp;gt; app: m_rx_buffer: ABC00DEFGHIJKLMNOP;ABC01DEFGH
&amp;lt;info&amp;gt; app: resp: ABC01DEFGH (resp_len: 10)
&amp;lt;info&amp;gt; app: row: ABC00DEFGHIJKLMNOP; (resp_len: 10, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 19
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKLMNOPQR;ABC02DEF
&amp;lt;info&amp;gt; app: resp: ABC02DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC01DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 16
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC
 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 26
&amp;lt;info&amp;gt; app: m_rx_buffer: 03DEFGHIJKLMNOPQR;ABC04DEF
&amp;lt;info&amp;gt; app: resp: ABC04DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC03DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 17
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC0
&amp;lt;info&amp;gt; app: resp: ABC0 (resp_len: 4)
&amp;lt;info&amp;gt; app: row: ABC05DEFGHIJKLMNOPQR; (resp_len: 4, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 25
&amp;lt;info&amp;gt; app: m_rx_buffer: 6DEFGHIJKLMNOP;ABC07DEFGH
0)
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 19
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKLMNOPQR;ABC08DEF
&amp;lt;info&amp;gt; app: resp: ABC08DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC07DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 20
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC09DE
&amp;lt;info&amp;gt; app: resp: ABC09DE (resp_len: 7)
&amp;lt;info&amp;gt; app: row: ABC08DEFGHIJKLMNOPQR; (resp_len: 7, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 22
&amp;lt;info&amp;gt; app: m_rx_buffer: FGHIJKLMNOPQR;ABC10DEF
&amp;lt;info&amp;gt; app: resp: ABC10DEF (resp_len: 8)
 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 21
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC11DEF
&amp;lt;info&amp;gt; app: resp: ABC11DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC10DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 19
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKLMNOPQR;ABC13DEF
&amp;lt;info&amp;gt; app: resp: ABC13DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC12DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 21
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC14DEF
 0)
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 21
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC15DEF
&amp;lt;info&amp;gt; app: resp: ABC15DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC14DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 3
&amp;lt;info&amp;gt; app: m_rx_buffer: GHI
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 18
&amp;lt;info&amp;gt; app: m_rx_buffer: JKLMNOP;ABC16DEFGH
&amp;lt;info&amp;gt; app: resp: ABC16DEFGH (resp_len: 10)
0)
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 19
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKLMNOPQR;ABC17DEF
&amp;lt;info&amp;gt; app: resp: ABC17DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC16DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 21
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOPQR;ABC18DEF
&amp;lt;info&amp;gt; app: resp: ABC18DEF (resp_len: 8)
&amp;lt;info&amp;gt; app: row: ABC17DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKL
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 15
&amp;lt;info&amp;gt; app: m_rx_buffer: MNOPQR;ABC19DEF
&amp;lt;info&amp;gt; app: row: ABC18DEFGHIJKLMNOPQR; (resp_len: 8, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 21
&amp;lt;info&amp;gt; app: m_rx_buffer: GHIJKLMNOP;ABC20DEFGH
&amp;lt;info&amp;gt; app: resp: ABC20DEFGH (resp_len: 10)
0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 19
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKLMNOP;ABC21DEFGH
&amp;lt;info&amp;gt; app: resp: ABC21DEFGH (resp_len: 10)
&amp;lt;info&amp;gt; app: row: ABC20DEFGHIJKLMNOP; (resp_len: 10, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 9
)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 29
&amp;lt;info&amp;gt; app: m_rx_buffer: ABC22DEFGHIJKLMNOP;ABC23DEFGH
&amp;lt;info&amp;gt; app: resp: ABC23DEFGH (resp_len: 10)
&amp;lt;info&amp;gt; app: row: ABC22DEFGHIJKLMNOP; (resp_len: 10, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 19
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKLMNOP;ABC24DEFGH
&amp;lt;info&amp;gt; app: resp: ABC24DEFGH (resp_len: 10)
0)
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 16
&amp;lt;info&amp;gt; app: m_rx_buffer: IJKL;ABC26DEFGHI
&amp;lt;info&amp;gt; app: resp: ABC26DEFGHI (resp_len: 11)
&amp;lt;info&amp;gt; app: row: ABC24DEFGHIJKL; (resp_len: 11, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT_RX_DONE: rx_size = 18
&amp;lt;info&amp;gt; app: m_rx_buffer: JKL;ABC27DEFGHIJKL
&amp;lt;info&amp;gt; app: resp: ABC27DEFGHIJKL (resp_len: 14)
&amp;lt;info&amp;gt; app: row: ABC26DEFGHIJKL; (resp_len: 14, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 15
&amp;lt;info&amp;gt; app: m_rx_buffer: ;ABC28DEFGHIJKL

&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 15
&amp;lt;info&amp;gt; app: m_rx_buffer: ;ABC29DEFGHIJKL
&amp;lt;info&amp;gt; app: resp: ABC29DEFGHIJKL (resp_len: 14)
&amp;lt;info&amp;gt; app: row: ABC28DEFGHIJKL; (resp_len: 14, usb buffer: 0)
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 15
&amp;lt;info&amp;gt; app: m_rx_buffer: ;ABC30DEFGHIJKL
&amp;lt;info&amp;gt; app: resp: ABC30DEFGHIJKL (resp_len: 14)

&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: NRF_SUCCESS: rx_size = 1
&amp;lt;info&amp;gt; app: m_rx_buffer: M
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): USB_TXRX_STATE_RX
&amp;lt;info&amp;gt; app: APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE
&amp;lt;info&amp;gt; app: cdc_acm_user_ev_handler(): APP_USBD_CDC_ACM_USER_EVT&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any(): other 8
&amp;lt;info&amp;gt; app: app_usbd_cdc_acm_read_any()


// Breakpoint hit&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Modified usb.c::usb_read_buf():&lt;br /&gt;// The changes a bit higher is also just a commented out NRF_LOG_FLUSH().&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1701695636408v4.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Modified main.c:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1701695619123v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Here is my test setup:&lt;/p&gt;
&lt;p&gt;Device side:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/usb_2D00_test_2D00_packed_2D00_2_2D00_hieu_2D00_231204.zip"&gt;devzone.nordicsemi.com/.../usb_2D00_test_2D00_packed_2D00_2_2D00_hieu_2D00_231204.zip&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Host PC side, including logs:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/c315710_5F00_python_5F00_script.zip"&gt;devzone.nordicsemi.com/.../c315710_5F00_python_5F00_script.zip&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Once again, my apology for having been unable to help.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/456128?ContentTypeID=1</link><pubDate>Fri, 17 Nov 2023 10:55:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb0232e8-c019-4449-ba2f-21c83eed8579</guid><dc:creator>PeterLjung</dc:creator><description>&lt;p&gt;Ok no problem. I think it would be good if you could try to reproduce on a Linux machine if possible.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/456086?ContentTypeID=1</link><pubDate>Fri, 17 Nov 2023 08:54:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c7cc219-cf2b-4833-b7fd-501cfc42e573</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;Just letting you know I am still on this case.&amp;nbsp;We have been in a shorthanded situation, and it&amp;#39;s been difficult for me to allocate&amp;nbsp;the amount of time this case deserves.&lt;/p&gt;
&lt;p&gt;I am&amp;nbsp;sorry for the inconvenience. I will try to get to it as soon as I could.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/454664?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2023 12:35:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12998bea-a893-41a0-82a5-ae1f12de4afe</guid><dc:creator>PeterLjung</dc:creator><description>&lt;p&gt;Ok, yes I tried both to comment out all logging in usb.c i.e. in all eventhandlers and also tried to disable in sdk_config (NRF_LOG_ENABLED = 0), but it seems to behave as before.&lt;br /&gt;&lt;br /&gt;When I run this on Ubuntu 20.04 the &amp;quot;working_sample&amp;quot; continues i.e. transmission completes&amp;nbsp;with multiple transmissions.&amp;nbsp;While &amp;quot;not_working_sample&amp;quot; does not.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;This is the code I used in this test.&lt;br /&gt;&lt;a title="usb-test-packed-4.tgz" href="https://drive.google.com/file/d/1bC4FhbKyhVn64lQVXdZbRdjbxgHjSXoh/view?usp=sharing"&gt;usb-test-packed-4.tgz&lt;br /&gt;&lt;br /&gt;&lt;/a&gt;I also tried to detect USB device on a newly installed WIndows 10 Home machine, but that behaves like the previous one. I got a short flash something like &amp;quot;Detected new USB device USB CDC PALOS&amp;quot;, but it is not detected in Device Manager. On a collegues Windows it works though. I don&amp;#39;t know why this differ.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/454645?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2023 11:43:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55230d76-0eaa-4723-9827-0e0877634309</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Another engineer took a quick look and pointed out that you are having NRF_LOG_FLUSH() in the USB event handler, which would cause delay in interrupt execution, potentially caused timing issues.&lt;/p&gt;
&lt;p&gt;Could you please disable logging entirely and run a test?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/454355?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2023 08:27:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9e4ffc1-860c-47a0-9343-ce6e37cd9003</guid><dc:creator>PeterLjung</dc:creator><description>&lt;p&gt;Yes, you are correct. Serial port on windows start from 0 which correspond to COM1.&lt;/p&gt;
&lt;p&gt;So to fix that this row could be changed.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;sp = SerialPort.new(serial_dev.to_i - 1, 115200, 8, 1, SerialPort::NONE)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I looks like at least 2 rows are transmitted in your current windows run. Doesn&amp;#39;t go further than that?&lt;/p&gt;
&lt;p&gt;The issue I see on Linux is just at the end of the transmission. And the issue will be seen as wrong (old) data is received from USB internal buffer.&amp;nbsp;If all rows are transmitted correctly the loop should just continue with another transmission from script after 5 seconds.&lt;/p&gt;
&lt;p&gt;If you want to keep the row handling of the firmware i.e. splitting rows delimited by ; maybe you only replace current content examples by to possibly simplify debugging.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;def working_sample&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; return &amp;quot;ABC00DEFGHIJKLMNOP;ABC01DEFGHIJKLMNOPQR;ABC02DEFGHIJKLMNOPQR;ABC03DEFGHIJKLMNOPQR;ABC04DEFGHIJKLMNOPQR;ABC05DEFGHIJKLMNOPQR;ABC06DEFGHIJKLMNOP;ABC07DEFGHIJKLMNOPQR;ABC08DEFGHIJKLMNOPQR;ABC09DEFGHIJKLMNOPQR;ABC10DEFGHIJKLMNOPQR;ABC11DEFGHIJKLMNOP;ABC12DEFGHIJKLMNOPQR;ABC13DEFGHIJKLMNOPQR;ABC14DEFGHIJKLMNOPQR;ABC15DEFGHIJKLMNOP;ABC16DEFGHIJKLMNOPQR;ABC17DEFGHIJKLMNOPQR;ABC18DEFGHIJKLMNOPQR;ABC19DEFGHIJKLMNOP;ABC20DEFGHIJKLMNOP;ABC21DEFGHIJKLMNOP;ABC22DEFGHIJKLMNOP;ABC23DEFGHIJKLMNOP;ABC24DEFGHIJKL;ABC26DEFGHIJKL;ABC27DEFGHIJKL;ABC28DEFGHIJKL;ABC29DEFGHIJKL;ABC30DEFGHIJKLM;ABC31DEFGHIJKLM;EOT;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;def not_working_sample&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; return &amp;quot;ABC00DEFGHIJKLMNOP;ABC01DEFGHIJKLMNOPQR;ABC02DEFGHIJKLMNOPQR;ABC03DEFGHIJKLMNOPQR;ABC04DEFGHIJKLMNOPQR;ABC05DEFGHIJKLMNOPQR;ABC06DEFGHIJKLMNOP;ABC07DEFGHIJKLMNOPQR;ABC08DEFGHIJKLMNOPQR;ABC09DEFGHIJKLMNOPQR;ABC10DEFGHIJKLMNOPQR;ABC11DEFGHIJKLMNOP;ABC12DEFGHIJKLMNOPQR;ABC13DEFGHIJKLMNOPQR;ABC14DEFGHIJKLMNOPQR;ABC15DEFGHIJKLMNOP;ABC16DEFGHIJKLMNOPQR;ABC17DEFGHIJKLMNOPQR;ABC18DEFGHIJKLMNOPQR;ABC19DEFGHIJKLMNOP;ABC20DEFGHIJKLMNOP;ABC21DEFGHIJKLMNOP;ABC22DEFGHIJKLMNOP;ABC23DEFGHIJKLMNOP;ABC24DEFGHIJKL;ABC26DEFGHIJKL;ABC27DEFGHIJKL;ABC28DEFGHIJKL;ABC29DEFGHIJKL;ABC30DEFGHIJKLM;EOT;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I will also try to reproduce the same issue on Windows later this week.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/454322?ContentTypeID=1</link><pubDate>Mon, 06 Nov 2023 22:13:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07924bba-b0ae-4b3b-a515-0166b6ee8e19</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;I see that you updated your reply today with further information on how to run it on Windows. Thank you so much for the help.&lt;/p&gt;
&lt;p&gt;It seems it has an interesting bug where the real port it runs is always 1 number higher than the port given in argument. I.e., below I connect to COM30 by running &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;ruby .\usb-test.rb 29&lt;/span&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Nonetheless, I tried that, and it seems I can produce some issue... The receiving logs showed a lot of data was missing.&amp;nbsp;That&amp;nbsp;probably was not the one you are describing?&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1699307553439v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I am&amp;nbsp;not very successful with the Linux virtual machine&amp;nbsp;attempt either. It seems the Ruby script cannot communicate with the device for some reason.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1699308505036v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;My Linux colleague can&amp;#39;t go to office, unlike I had hoped.&lt;/p&gt;
&lt;p&gt;If push comes to shove, I think I can cook up something on Python to replicate what&amp;nbsp;your Ruby script should do.&lt;/p&gt;
&lt;p&gt;This issue happens when the PC sends a specific length message to the nRF device, right?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The way I usually attempt to reproduce this kind of issues, I usually setup the TX device to send at a button trigger. In this case, I think I will just setup something simple like when I hit Space, the PC should send &amp;quot;ABCDEFGH00ABCDEFGH01ABCDEFGH02...ABCDEFGH56.&amp;quot;&lt;/p&gt;
&lt;p&gt;On the device end, I&amp;nbsp;can try with either your code or a minimally modified CDC ACM example to use the _read_any() API, then slowly add/remove debug logs, depends on the details.&lt;/p&gt;
&lt;p&gt;Do you think a setup like above would work?&lt;/p&gt;
&lt;p&gt;I will also consider asking if someone from another team can give me a hand with the Linux trial.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/454264?ContentTypeID=1</link><pubDate>Mon, 06 Nov 2023 15:15:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7d312c3-54aa-448b-b5f9-39cd64e42d2d</guid><dc:creator>PeterLjung</dc:creator><description>&lt;p&gt;I did a test on another Windows machine and there USB is detected fine. The one I am using does not work.&amp;nbsp;But I also noticed that serial ports COM ports are rather written as a number rather than a device name as in Linux.&amp;nbsp;&lt;br /&gt;Also I cannot detect if device is connected on Windows which was discussed above. So the RW protocol does not work on Windows.&lt;br /&gt;I made a quick rewrite that possibly could work on Windows. Device is not detected and script is will not be waiting for a command from the nRF device. I will not be able to test this until later this week (I dont have access to this machine) so it may very well have issues.&lt;br /&gt;&lt;a title="usb-test-packed-3-windows.tgz" href="https://drive.google.com/file/d/11txTNhAXHR_ec9-q3UtjPGdmAt2DCd8p/view?usp=sharing"&gt;usb-test-packed-3-windows.tgz&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So it is certainly much easier to try on regular Linux machine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/453656?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2023 10:03:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54d5080a-e418-452d-bbe1-2206fedbb3e4</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;There is one person in my team with a Linux machine, but they are away until next Monday. I will try to get their help then. In the meantime, I&amp;nbsp;will try with a virtual machine.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/453646?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2023 09:26:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df3725f3-5ca6-4470-abdc-4fb46a2dd6f9</guid><dc:creator>PeterLjung</dc:creator><description>&lt;p&gt;I tried Nordic USB CDC ACM sample on another Windows machine and there it is detected&amp;nbsp;fine. &lt;br /&gt;But on the computer that I have access to it doesn&amp;#39;t for some reason.&amp;nbsp;The device is not detected at all.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;1. I looked at BIOS settings to see if devices was disabled&lt;br /&gt;2. I tested another device (USB stick) on the same port to see if that worked. And yes.&lt;br /&gt;3. I tried to install nRF utils tools to see if there still was some driver issue.&lt;br /&gt;4. I tried to power the board through debug USB port to see if power was the issue.&lt;br /&gt;&lt;br /&gt;But it works fine on 3 other machines with different OSes (macOS, OpenBSD and Linux).&lt;br /&gt;Windows is just too strange. If you could try on Linux it would be great.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards / Peter&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/453588?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2023 22:19:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c9db0e6-c318-422d-9631-285b13942849</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;I would like to give you an update.&lt;/p&gt;
&lt;p&gt;I tried Windows again with your suggestion here:&lt;/p&gt;
[quote user="PeterLjung"]I think we had to introduce a delay specifically for Windows compared with Linux in another project.&lt;br /&gt;So you could try to introduce a delay between &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;usb_config()&lt;/span&gt; and &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;usb_write()&lt;/span&gt; and/or include a set of&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;process_usb_events()&lt;/span&gt; between operations.[/quote]
&lt;p&gt;But the result has remained the same.&lt;/p&gt;
&lt;p&gt;I also tried to&amp;nbsp;create another setup with WSL. However, I have been having issue&amp;nbsp;passing the USB port to WSL. It seems there are some firewall issues.&lt;/p&gt;
&lt;p&gt;I will try to pull in some other help, preferably someone&amp;nbsp;who is working with Linux.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/452933?ContentTypeID=1</link><pubDate>Mon, 30 Oct 2023 08:20:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c77b77c3-f4bf-4fab-9f50-6b4e90f20763</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Not recently, but&amp;nbsp;I have worked with the Nordic USB CDC sample on my Windows machine before. The driver should be automatically installed after a few seconds. Could it be that your Windows machine&amp;#39;s driver installation is limited due to enterprise firewall or Windows policy?&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t been successful yet. I&amp;nbsp;will try WSL next, not having a Linux machine to try,&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/452799?ContentTypeID=1</link><pubDate>Fri, 27 Oct 2023 13:20:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbbc26dd-d47c-42f2-954c-f90800c41478</guid><dc:creator>PeterLjung</dc:creator><description>&lt;p&gt;I tried this on a Windows machine ...&lt;br /&gt;&lt;br /&gt;But unfortunately I couldn&amp;#39;t get&amp;nbsp;Nordic USB CDC ACM sample to work on Windows or my sample.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Device was not detected by Device Manager.&lt;br /&gt;&lt;br /&gt;&lt;a title="USB CDC ACM Example" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/usbd_cdc_acm_example.html"&gt;USB CDC ACM Example&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a title="USB CDC ACM Example" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/usbd_cdc_acm_example.html"&gt;&lt;/a&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;I also tried on Linux and there both variants was detected by the OS.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;I tested on a Windows 10 machine and assume that no drivers are needed.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;If you could test on a Linux machine I think it would simplify things, but I will also make a new attempt on Windows next week.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Have you tested the Nordic USB CDC sample on your machine?&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Best regards / Peter&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/452633?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2023 14:22:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0bd4bf6-9912-47c7-93b0-5ddd23540600</guid><dc:creator>PeterLjung</dc:creator><description>&lt;p&gt;Actually I have not tried exactly this sample on Windows. &lt;br /&gt;Question is if the USB device is detected by Windows or not. Can you check?&lt;br /&gt;&lt;br /&gt;On Linux, device may alter between e.g. two devices e.g. &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;ttyACM2&lt;/span&gt; and&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;ttyACM3&lt;/span&gt;.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I think we had to introduce a delay specifically for Windows compared with Linux in another project.&lt;br /&gt;So you could try to introduce a delay between &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;usb_config()&lt;/span&gt; and &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;usb_write()&lt;/span&gt; and/or include a set of&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;process_usb_events()&lt;/span&gt; between operations.&lt;br /&gt;&lt;br /&gt;Hope this helps.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I will also try on a Windows machine tomorrow and compare ...&lt;br /&gt;&lt;br /&gt;Best regards / Peter&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/452598?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2023 13:03:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c5fe294-f900-4a9c-83d3-57e9008a639f</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Thanks for the tip, Peter. I commented out the USB connected check and it seems the script can progress past that now.&lt;/p&gt;
&lt;p&gt;However, it seems the test is not running as expected:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/2110.pastedimage1698324957233v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;When I tried the first project you sent instead,&amp;nbsp;my PC doesn&amp;#39;t even accept the USB device..&lt;/p&gt;
&lt;p&gt;Do you have any idea what is wrong? I will dive into it in a bit, but asking in case something makes sense for you immediately.&lt;/p&gt;
&lt;p&gt;By the way, I am thinking about&amp;nbsp;modifying&amp;nbsp;the projects so that the device just listens, and the Ruby script immediately sends a fixed size packet. Do you think there is any problem with this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/452499?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2023 10:45:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c60f2804-f7a5-4a66-9abc-212d1e6936ea</guid><dc:creator>PeterLjung</dc:creator><description>&lt;p&gt;Aha, so you are on a Windows machine?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;lsusb&lt;/span&gt;&amp;nbsp;is UNIX utility so that could be a problem on Windows.&amp;nbsp;&lt;br /&gt;I am working from Ubuntu 20.04.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;lsusb&lt;/span&gt; and &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;usb_connected?&lt;/span&gt; part is only for robustness of the script and could be removed if neccesary.&lt;br /&gt;&lt;br /&gt; &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;# Open protocol towards serial client&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; loop do&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; if usb_connected? then&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; show &amp;quot;BLE device connected. Connect to USB serial port.&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; sp = SerialPort.new(serial_dev, 115200, 8, 1, SerialPort::NONE)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; break&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; show &amp;quot;BLE device not connected to USB port. Wait ...&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; sleep 10&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; end&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;could be replaced by&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;sp = SerialPort.new(serial_dev, 115200, 8, 1, SerialPort::NONE)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/452486?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2023 09:37:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:297ea869-d6b2-483b-b928-1fc4fd93cdd6</guid><dc:creator>PeterLjung</dc:creator><description>[deleted]&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/452378?ContentTypeID=1</link><pubDate>Wed, 25 Oct 2023 22:20:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:206e1475-dacf-4efa-894e-162f97123cdd</guid><dc:creator>Hieu</dc:creator><description>[quote user="PeterLjung"]It looks like disabling event queue (&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;APP_USBD_CONFIG_EVENT_QUEUE_ENABLE&lt;/span&gt;) removes manual triggering of usb state via&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;app_usbd_event_queue_process()&lt;/span&gt; so it changes the usage of the API a bit.[/quote]
&lt;p&gt;That&amp;#39;s right. If I remember correctly, you probably won&amp;#39;t need &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;app_usbd_event_queue_process()&lt;/span&gt;&amp;nbsp;when the event queue is disabled. This is just a temporary debugging change to help narrow down the issue though.&lt;/p&gt;
[quote user="PeterLjung"]We tried&amp;nbsp;&lt;span&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;app_usbd_cdc_acm_read()&lt;/span&gt;, but ended up using &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;_any()&lt;/span&gt; variant instead. It think we had the same problem with this one.&amp;nbsp;Is really double buffering usb stack implementation simpler?&lt;/span&gt;[/quote]
&lt;p&gt;I don&amp;#39;t think either &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;_read()&lt;/span&gt; or &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;_read_any()&lt;/span&gt; API implementation in the app_usbd library is significantly simpler than the other.&lt;/p&gt;
&lt;p&gt;Or&amp;nbsp;could you perhaps be asking about the application layer, where you implement the handling? If so, I think the implementation is different, but not necessarily simpler or more complex. I just suggested it in case it could be a working alternative for you, as well as a potential further hint on where the issue.&lt;/p&gt;
&lt;p&gt;However, that&amp;#39;s a bit strange if you had the same issue with the &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;_read()&lt;/span&gt; API.&amp;nbsp;The way the two APIs handle buffers are different, after all. &lt;br /&gt;Could you check if&amp;nbsp;there are some notes, such as in commit messages, from that time?&lt;/p&gt;
[quote user="PeterLjung"]Regarding ruby it should only be to install ruby and one single gem serialport. &lt;br /&gt;Make sure it looks something like this.&amp;nbsp; Later ruby version should also be fine.[/quote]
&lt;p&gt;Ah yes. I have Ruby 3.2.2 and serialport gem version 1.3.2. The hiccups I mentioned was embarrassingly with the installation... Turns out I had some misunderstanding about&amp;nbsp;the&amp;nbsp;MSYS2&amp;nbsp;part of the installation log, and everything went (almost) fine...&lt;/p&gt;
&lt;p&gt;However, when I run the script, it is not working though.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1698272011879v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;There were a couple of error message during installation about the wizard being unable to find&lt;i&gt;&amp;nbsp;&lt;/i&gt;catgets and libcatgets for &lt;em&gt;removal&amp;nbsp;&lt;/em&gt;to avoid conflicts. &lt;br /&gt;Seems related to &lt;a href="https://github.com/oneclick/rubyinstaller2/issues/101"&gt;this PR&lt;/a&gt;.&amp;nbsp;I don&amp;#39;t think this is an issue though.&lt;/p&gt;
&lt;p&gt;I will try and see if this is just some simple differences in COM port handling between Windows and Linux and fix it.&amp;nbsp;If that doesn&amp;#39;t work,&amp;nbsp;I will figure something else out. I will keep you posted, nonetheless.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/452162?ContentTypeID=1</link><pubDate>Wed, 25 Oct 2023 07:54:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79655aa7-7481-45e3-8445-dd9e550419d3</guid><dc:creator>PeterLjung</dc:creator><description>&lt;p&gt;It looks like disabling event queue (&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;APP_USBD_CONFIG_EVENT_QUEUE_ENABLE&lt;/span&gt;) removes manual triggering of usb state via&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;app_usbd_event_queue_process()&lt;/span&gt; so it changes the usage of the API a bit.&lt;br /&gt;&lt;br /&gt;We tried&amp;nbsp;&lt;span&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;app_usbd_cdc_acm_read()&lt;/span&gt;, but ended up using &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;_any()&lt;/span&gt; variant instead. It think we had the same problem with this one.&amp;nbsp;Is really double buffering usb stack implementation simpler?&lt;br /&gt;&lt;br /&gt;We are using a separate sw stack that only support SDK so&amp;nbsp;right now its not possible to move to connect.&lt;br /&gt;&lt;br /&gt;Regarding ruby it should only be to install ruby and one single gem serialport. &lt;br /&gt;Make sure it looks something like this.&amp;nbsp; Later ruby version should also be fine.&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;$ ruby -v&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;$ gem list&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;*** LOCAL GEMS ***&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;serialport (1.3.2)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/452066?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2023 18:18:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f846026b-3b66-408f-bdac-88b36b633925</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;I would like to give a short reply. I returned and started working on the case. However, I am unfamiliar with Ruby and have been having some hiccups with the reproduction.&lt;/p&gt;
[quote user="PeterLjung"]&amp;quot;You could test the application in IRQ mode, with the event queue disabled to see if that changes anything.&amp;quot;&lt;br /&gt;&lt;br /&gt;Should IRQ be disabled at some state of the program?[/quote]
&lt;p&gt;This is done by setting&amp;nbsp;&lt;span&gt;APP_USBD_CONFIG_EVENT_QUEUE_ENABLE to 0. This disables the USB event queue in the app_usbd library and all USB events would be handled directly in the interrupt handler.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I would like to discuss an alternative while the issue is not yet clear. Have you tried using&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;app_usbd_cdc_acm_read()&lt;/span&gt; instead? That API allows double buffering. Since the package length is not constant, you&amp;nbsp;probably have to use a buffer size of 1. However, if your package has a format, or if you can control the host side to send it in a divisible number, like 512, 528, 544, ... (increment by 16), then you can use a larger buffer size.&lt;/p&gt;
&lt;p&gt;One more thing I should have checked&amp;nbsp;in my first reply. Are you working on a new product? What&amp;nbsp;development stage are you at? If you are at early stages, then&amp;nbsp;our official recommendation is the nRF Connect SDK instead of the nRF5 SDK, which is in &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/nrf-connect-sdk-and-nrf5-sdk-statement"&gt;maintenance mode&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I will continue to investigate this issue today and tomorrow.&amp;nbsp;I would like to at least get to the point of getting a reproduction setup to run.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/451788?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2023 15:25:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b99a591-ce18-4f55-b77c-9bb550ebf8ab</guid><dc:creator>PeterLjung</dc:creator><description>&lt;p&gt;Yes,&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;strong&gt;app_usbd_event_queue_process&lt;/strong&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;()&lt;/span&gt; is only called in main() in test app above and not from any interrupt routine.&lt;br /&gt;&lt;br /&gt;I also tried to replace blocking &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;nrf_delay_ms()&lt;/span&gt; calls with RTC based events, but the same behavior&amp;nbsp;persists.&lt;br /&gt;&lt;br /&gt;Not exactly sure what you mean by this:&lt;br /&gt;&amp;quot;You could test the application in IRQ mode, with the event queue disabled to see if that changes anything.&amp;quot;&lt;br /&gt;&lt;br /&gt;Should IRQ be disabled at some state of the program?&lt;br /&gt;&lt;br /&gt;Anyway I have attached my updated version here. Only modified &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;main.c&lt;/span&gt;&amp;nbsp;&lt;br /&gt;&lt;a title="usb-test-packed-2.tgz" href="https://drive.google.com/file/d/1yTPAQmS_oIvXXCuM0_3ikpUmXyloUHyG/view?usp=share_link"&gt;usb-test-packed-2.tgz&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Best regards / Peter&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/451729?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2023 12:54:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce577073-2d66-4bb5-b35b-491a9172a4a7</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Hieu will be back in office to continue this case tomorrow, but in the meantime one of our experts on the USB stack has taken a look at your project and has some feedback for you.&lt;/p&gt;
&lt;p&gt;Although we couldn&amp;#39;t pinpoint what the error is likely to be we have some suggestions to what it could be.&lt;/p&gt;
&lt;p&gt;First off, do you do the intermediate call to&amp;nbsp;&lt;strong&gt;&lt;span&gt;&lt;span dir="ltr"&gt;&lt;i&gt;while (app_usbd_event_queue_process()&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt; from an interrupt? If so that will definitely cause trouble with the priorities in your application. You could test the application in IRQ mode, with the event queue disabled to see if that changes anything.&lt;/p&gt;
&lt;p&gt;There might be a problem with the way you&amp;#39;re using the&amp;nbsp;&lt;span&gt;&lt;span dir="ltr"&gt;&lt;strong&gt;app_usbd_event_queue_process&lt;/strong&gt;() function, asthe point is to call it in your while loop, and not wherever you think it &amp;quot;fits&amp;quot; into your application.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;You&amp;#39;re also using multiple blocking delays within your project, and the entire nRF5 SDK is based on asynchronous APIs, with callbacks when there is data to process. We would recommend you set up your project similarly, and go to a sleep mode at the end of your while loop instead of just running a delay. Based on the number of iterations we&amp;#39;ve had of our USB stack in the nRF5 SDK we don&amp;#39;t think this is inherently an issue within the stack.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;Best regards,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;Simon&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/451592?ContentTypeID=1</link><pubDate>Sun, 22 Oct 2023 07:30:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c915fac-e9ca-4689-9d01-0d0da686bd6f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;This seems to be some thing in the design of the state machine.I haven&amp;#39;t been able to replicate it yet as both of the working and non_working seems be stuck at my end. I am running ubuntu in the virtual machine but running VM should not be an issue.&lt;/p&gt;
&lt;p&gt;I will try to see if I can include the developer into helping us into this issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/451232?ContentTypeID=1</link><pubDate>Thu, 19 Oct 2023 09:30:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfe5cee3-1d30-49a1-912e-558e0160ce52</guid><dc:creator>PeterLjung</dc:creator><description>&lt;p&gt;Size is accessed both directly after&amp;nbsp;&lt;span&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;app_usbd_cdc_acm_read_any()&lt;/span&gt; on success.&amp;nbsp;&lt;br /&gt;&lt;/span&gt;And from event handler in pending response.&lt;br /&gt;&lt;br /&gt;The following is a complete example including firmware and a small Ruby script on PC side to reproduce the error.&lt;br /&gt;That should hopefully make it clear how we are using the API.&lt;br /&gt;&lt;a title="usb-test-packed-no-sdk.tgz" href="https://drive.google.com/file/d/1fZj_zKkFOw-8w60JxmTgfe54FKnaZMOr/view?usp=sharing"&gt;usb-test-packed-no-sdk.tgz&lt;br /&gt;&lt;br /&gt;&lt;/a&gt;See README.md for intro of how to use the code.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Regards&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB CDC ACM: RX data gets overwritten in app_usbd_cdc_acm_read_any() at end of data transmission</title><link>https://devzone.nordicsemi.com/thread/451146?ContentTypeID=1</link><pubDate>Wed, 18 Oct 2023 22:11:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:584ca018-1c15-4313-ba60-eb2ccfe3a6d8</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;Firstly, I would like to update you that I have been looking into the USB CDC ACM modules and a reproduction setup base on the USB CDC ACM example.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Next, I would like to ask about a few details in your code:&lt;/p&gt;
[quote user=""]ret = app_usbd_cdc_acm_read_any(&amp;amp;m_app_cdc_acm, m_rx_buffer, MIN(BUFFER_SIZE,size));[/quote]
&lt;p&gt;How are you calling this function?&lt;/p&gt;
[quote user=""]&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;rx_size = app_usbd_cdc_acm_rx_size(p_cdc_acm);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; copy_rx_data(buffer, n, m_rx_buffer);&lt;/span&gt;[/quote]
&lt;p&gt;Are&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;buffer&lt;/span&gt; and &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;n&lt;/span&gt; variables for another level of buffer where&amp;nbsp;you just recombine the fragments of data&amp;nbsp;from received in &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;m_rx_buffer&lt;/span&gt; across multiple the&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;app_usbd_cdc_acm_read_any()&lt;/span&gt; calls?&lt;/p&gt;
&lt;p&gt;If that&amp;#39;s not correct, could you give more details about them?&lt;/p&gt;
&lt;p&gt;Also, it would be great if you can recommend me a terminal program that goes well with this kind of test.&amp;nbsp;I&amp;nbsp;have been using PuTTy but I don&amp;#39;t feel very confident that it&amp;#39;s suitable for sending a large number of bytes at once.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Finally, I understand that you have waited a long time before receiving the first reply. However, I am out of office for the rest of the week. I will try to follow up if possible. My apology for the inconvenience.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>