<?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>CDC ACM does not work after restart</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/100176/cdc-acm-does-not-work-after-restart</link><description>Hi, 
 I did some more testing and here&amp;#39;s an update of my problem: 
 I am facing a problem when using my nrf52840 usb dongle (nrf sdk 17.0.1) on a usb port on Windows. 
 It works fine the first time the pc starts. But after rebooting windows USB CDC is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 09 Jun 2023 07:31:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/100176/cdc-acm-does-not-work-after-restart" /><item><title>RE: CDC ACM does not work after restart</title><link>https://devzone.nordicsemi.com/thread/430126?ContentTypeID=1</link><pubDate>Fri, 09 Jun 2023 07:31:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:435410c5-fc88-4d84-8375-b19a48d6d3e3</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Andreas&lt;/p&gt;
&lt;p&gt;I asked one of my colleagues that has more experience with the Dongle than me as well, but we can&amp;#39;t see why this would occur I&amp;#39;m afraid. You could maybe try to add a watchdog or some timeout so that the service (or Dongle) restarts itself if is pending for X amount of time.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sorry that we don&amp;#39;t have a more concise fix for you...&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CDC ACM does not work after restart</title><link>https://devzone.nordicsemi.com/thread/429721?ContentTypeID=1</link><pubDate>Wed, 07 Jun 2023 10:14:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:981f5215-bfb1-4181-90b8-a95514a416bc</guid><dc:creator>Andreas48752</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;thanks for your answer.&lt;/p&gt;
&lt;p&gt;We did some more testing and it looks like this:&lt;/p&gt;
&lt;p&gt;After I start the PC with connected nrf dongle it is not possible for the service to send data to the dongle. I startet an serial port monitor and I can see that the service tries to send data but it is in pending state forever.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When I restart the service or unplug the dongle and plug it in again it works fine and the service can send data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think it is something that the nrf firmware does not open the port correctly on the dongle side (or maybe some events are not triggered, I don&amp;#39;t know).&lt;/p&gt;
&lt;p&gt;As a workaround the customer restarts the service if it can&amp;#39;t send data. This works but it would be nice if it should not be necessary at every start...&lt;/p&gt;
&lt;p&gt;Can you image a scenario where the sdk does not initialize correctly right after the pc is started? If I connect the debugger and unplug and plug in again (so the dongle does not loose power supply) it works fine.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CDC ACM does not work after restart</title><link>https://devzone.nordicsemi.com/thread/428634?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2023 08:12:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fd85076-7325-4ab3-86b3-ef7ef5c13556</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I just assumed it was a continuation to some other case since you started with &amp;quot;I did some more testing&amp;quot;.&lt;/p&gt;
&lt;p&gt;From your description this seems like this is an issue with the service on the PC side, which we&amp;#39;re not experts at, as we focus on the nRF SoCs and products. I did a quick search internally looking for cases in the past with a similar issue, but didn&amp;#39;t find anything that seemed to cover what you&amp;#39;re seeing unfortunately. Would it be an idea to restart the service on the PC side during boot-up for example, is that an option?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CDC ACM does not work after restart</title><link>https://devzone.nordicsemi.com/thread/428131?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 10:22:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad8b2ab0-e25f-4d93-b44b-ac2e15345455</guid><dc:creator>Andreas48752</dc:creator><description>&lt;p&gt;Hi Simon.&lt;br /&gt;no Problem at all.&amp;nbsp;We also&amp;nbsp;had a public holiday yesterday.&lt;/p&gt;
&lt;p&gt;It is something completely different than the other thread. No ANT+ is needed here. Also S140 is used.&lt;/p&gt;
&lt;p&gt;The problem ist that the PC software is not using DTR, so I tried to change some parts of app_usbd_cdc_acm.c.&lt;/p&gt;
&lt;p&gt;This is what I changed. It works sofar, but sometimes after starting the pc the dongle does not receive any data. If I restart the service on PC side (which closes and opens the port) it works again.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ret_code_t app_usbd_cdc_acm_read(app_usbd_cdc_acm_t const * p_cdc_acm,
                                 void *                     p_buf,
                                 size_t                     length)
{
    ASSERT(p_buf != NULL);
    ret_code_t ret;
    app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm);

    if (0U == (p_cdc_acm_ctx-&amp;gt;line_state &amp;amp; APP_USBD_CDC_ACM_LINE_STATE_DTR))
    {
        /*Port is not opened*/
       //return NRF_ERROR_INVALID_STATE; //we are talking to a pc. this is not needed




    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static ret_code_t setup_req_class_out(app_usbd_class_inst_t const * p_inst,
                                      app_usbd_setup_evt_t const *  p_setup_ev)
{
    app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst);
    app_usbd_cdc_acm_ctx_t *   p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm);

    switch (p_setup_ev-&amp;gt;setup.bRequest)
    {
       ...
        case APP_USBD_CDC_REQ_SET_CONTROL_LINE_STATE:
        {
            if (p_setup_ev-&amp;gt;setup.wLength.w != 0)
            {
                return NRF_ERROR_NOT_SUPPORTED;
            }

            NRF_LOG_INFO(&amp;quot;REQ_SET_CONTROL_LINE_STATE: 0x%x&amp;quot;, p_setup_ev-&amp;gt;setup.wValue.w);

            bool old_dtr = (p_cdc_acm_ctx-&amp;gt;line_state &amp;amp; APP_USBD_CDC_ACM_LINE_STATE_DTR) ?
                            true : false;            
            p_cdc_acm_ctx-&amp;gt;line_state = 1;// todo changed so it will work if no DTR is set from PC;// p_setup_ev-&amp;gt;setup.wValue.w;            
            bool new_dtr = (p_cdc_acm_ctx-&amp;gt;line_state &amp;amp; APP_USBD_CDC_ACM_LINE_STATE_DTR) ?
                            true : false;

            if (old_dtr == new_dtr)
            {
                return NRF_SUCCESS;
            }

            const app_usbd_cdc_acm_user_event_t ev = new_dtr ?
                  APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN : APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE;

            user_event_handler(p_inst, ev);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ret_code_t app_usbd_cdc_acm_read_any(app_usbd_cdc_acm_t const * p_cdc_acm,
                                     void *                     p_buf,
                                     size_t                     length)
{
    ASSERT(p_buf != NULL);
    ret_code_t ret;
    app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm);

    if (0U == (p_cdc_acm_ctx-&amp;gt;line_state &amp;amp; APP_USBD_CDC_ACM_LINE_STATE_DTR))
    {
        /*Port is not opened*/
        //return NRF_ERROR_INVALID_STATE; // we are talking to a pc. this is not needed
       
    }
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CDC ACM does not work after restart</title><link>https://devzone.nordicsemi.com/thread/428115?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 09:30:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c799b0a9-9811-4b03-9c23-97c577994271</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Andreas&lt;/p&gt;
&lt;p&gt;First off, sorry about the late reply, but yesterday (Monday May 29th) was a public holiday here in Norway. I just wanted to check if this is a continuation of&lt;a href="https://devzone.nordicsemi.com/support-private/support/308253"&gt; this thread&lt;/a&gt; you have with my colleague Jonathan, or if it&amp;#39;s something completely different?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>