This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to view LOG from nRF52840 USB CDC example

Hi,
I am working on the project through the USB CDC example.

I know how to view log using RTT Viewer through J-Link and UART-LOG using UART.

But how can I see LOG with only CDC-USB connected?


I am using Putty to connect to the COM port that came with the CDC-USB, and the CDC does not work. If I am running CDC, I can not see the LOG.

I wonder if there is a way to view LOG with only USB-CDC connected except the above two methods.

  • Unfortunately, there's no built-in functionality to redirect the logging calls to the USB peripheral. However, you can define your own backed for logging. If you look at nrf_log_backend_uart.c you can see how the backend is implemented, so you can use this as a starting point and rewrite it for the USB peripheral.

    Or, you can start out with the USB CDC example in the sdk and use app_usbd_cdc_acm_write() to print out your log messages.

  • I'm looking for exactly the same feature; I would be logical to me to be able to sent the log over the usb CDC serial uart...

    did you made any progress? Can you share? Thx.

  • Hi, can you tell me how to see logs using j-link ..i have connected swdio,swdclk,VCC,gnd  from dongle  to j-link but the dongle is not being detected.. thanks in advance


  • in my test case , i'm using usb interactive example,i need using CDC ACM port to read log,
    so  i change nrf_cli_init parameter from NRF_LOG_SEVERITY_ERROR to NRF_LOG_SEVERITY_INFO and it works for me.

    static void cli_init(void) 
    { 
        ret_code_t ret; 
    #if CLI_OVER_USB_CDC_ACM 
        //ret = nrf_cli_init(&m_cli_cdc_acm, NULL, true, true, NRF_LOG_SEVERITY_ERROR); 
        ret = nrf_cli_init(&m_cli_cdc_acm, NULL, true, true, NRF_LOG_SEVERITY_INFO); 
        APP_ERROR_CHECK(ret); 
    #endif 
    #if CLI_OVER_UART 
        nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG; 
        uart_config.pseltxd = TX_PIN_NUMBER; 
        uart_config.pselrxd = RX_PIN_NUMBER; 
        #ifdef HWFC uart_config.pselcts = CTS_PIN_NUMBER; 
        uart_config.pselrts = RTS_PIN_NUMBER; 
        uart_config.hwfc = NRF_UART_HWFC_ENABLED; 
        #endif 
        ret = nrf_cli_init(&m_cli_uart, &uart_config, true, true, NRF_LOG_SEVERITY_ERROR); 
        APP_ERROR_CHECK(ret); 
    #endif 
    }

Related