Data mixing with CDC ACM & CLI

Hello,

I have a problem when I send data with CDC ACM and using CLI interface my data is mixing. If I put a delay between sending data I have no problem but this solution is not very clean. 

Have you got an idea of why I can fix this problem?

Thank You,

Téo 

  • Hi Téo

    Can you share some additional information regarding your application/project? What SDK and SDK version are you using? How exactly is your data mixing, do the bytes/logging info weave together in-between each other or do you get any errors of some kind?

    It should be possible to have several USB classes on the same USB peripheral, as long as you initialize them before enabling USB. Have you done any debugging to see if the application throws any errors that might give us an idea of what's going wrong here. It might be some issues with the two creating a race condition of some kind if they have the same interrupt priority for example.

    Best regards,

    Simon

  • I use SDK 17.1.0, the goal is to communicate with my tracker with USB port. I have no error just my data are mixed when I receive it. I use nrf_cli_print_stream(&m_cli_cdc_acm, (char *) buf, size) to write my data and my cli is define with this 

    NRF_CLI_DEF(m_cli_cdc_acm,
                "",
                &m_cli_cdc_acm_transport.transport,
                '\r',
                CLI_EXAMPLE_LOG_QUEUE_SIZE);

    When I'm debugging I have 0 error it's work correctly but when I send lot off data it's mixed. The small transfer of data work nice but when I send multiple packet data is mixed. 

  • I try to use APP_USBD_CDC_ACM_USER_EVT_TX_DONE but it 's always at 1 the transmission is always finish. I find this strange 

  • Hi

    After discussing this with a colleague, I think we need some more details, as there shouldn't be a problem running multiple CDC ACM com ports. I guess it could have something to do with how you transmit the data. Can you show some details of how this is done exactly? Are you for example transmitting from an interrupt?

    Also, what do you mean by APP_USBD_CDC_ACM_USER_EVT_TX_DONE  always being 1? This is an event, and not a variable. How are you using this event exactly? As app_usbd_cdc_acm_write says, you should wait for the APP_USBD_CDC_ACM_USER_EVT_TX_DONE  when writing to make sure that all data has been set and the input buffer can be accessed again.

    Best regards,

    Simon

  • Hi

    I'm facing the same problem.
    I'm using nrf_cli_print_stream() from the nrf_cli library (which uses CDC ACM library) to send chunks of raw data.

    The problem is that when I try to send several chunks, some data is lost, as if I didn't wait for the buffer to be ready.

    I noticed that the function cli_write waits for the tx_rdy flag, which is set by the cli_transport_evt_handler which is called by cdc_acm_user_ev_handler when APP_USBD_CDC_ACM_USER_EVT_TX_DONE event is detected.

    That being said, I should be able to call nrf_cli_print_stream() several times in a row without having my data mixed up or lost, right?

    Also I am using SDK 17.1

    Thanks for your help

Related