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

NRF_LOG_INFO can't print a string.

Hello,

The following code was embedded in main function, the sdk version is 15.2.

NRF_LOG_INFO("test begin: ");

char string[] = "This is a string.";
NRF_LOG_INFO(string);

NRF_LOG_INFO("This is a string, too.");

NRF_LOG_INFO("test end ");

the debug console show as below:

My question is , why string "This is a string" can't print out?

Thank you!

Parents Reply Children
  • Oh~I explain the NRF_LOG_INFO in my project as follow:

    static char temp_str[64]={0};

    static void gatt_c_evt_handler(ble_gatt_c_t * p_gatt_c, ble_gatt_c_evt_t * p_gatt_c_evt)
    {
    switch (p_gatt_c_evt->evt_type)
    {

    ......

    case BLE_GATT_C_EVT_STATUS_NOTIFICATION:
    {
    if (p_gatt_c_evt->params.read.batt_state==0)
    {
    strcpy(temp_str,"Battery is good.");
    BLE_probe[p_gatt_c_evt->conn_handle].batt_status = 0xff;
    }
    else
    {
    strcpy(temp_str,"Low Battery.");
    BLE_probe[p_gatt_c_evt->conn_handle].batt_status = 0x00;
    }
    NRF_LOG_INFO("Link 0x%x, Battery status: %s\r\n",p_gatt_c_evt->conn_handle,(uint32_t)temp_str);

    break;

    }

    .......

    }

    You may take for reference.

    Remember to define NRF_LOG_USES_RTT=1 in your project file, if you use the segger jlink for log output.

  • Does this solution work when using freeRTOS?

Related