printf() function doesn't print anything to vscode terminal

Hey Nordic,

I am using

  • SDKv17.1.0
  • VSCODE as IDE
  • S140 as softdevice
  • Windows

Let me first insert my code snippet:

// ALREADY_DONE_FOR_YOU: Declaration of a function that will take care of some housekeeping of ble connections related to our service and characteristic
void ble_our_service_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context)
{
    uint32_t former, latter, charIndex;
    ble_os_t * p_our_service =(ble_os_t *) p_context;  
	// OUR_JOB: Step 3.D Implement switch case handling BLE events related to our service. 
	switch (p_ble_evt->header.evt_id)
    {
        case BLE_GATTS_EVT_WRITE:
            printf("BLE_GATTS_EVT_WRITE");
            for(charIndex = 0; charIndex < NO_OF_CHARACTERISTICS; charIndex++)
            {
                if(p_ble_evt->evt.gatts_evt.params.write.uuid.uuid == BLE_UUID_OUR_CHARACTERISTC_UUID + charIndex)
                {
                    NRF_LOG_INFO("16-bit UUID: 0x%x", p_ble_evt->evt.gatts_evt.params.write.uuid.uuid);
                    former = (p_ble_evt->evt.gatts_evt.params.write.data[0]<<8) + (p_ble_evt->evt.gatts_evt.params.write.data[1]);
                    latter = (p_ble_evt->evt.gatts_evt.params.write.data[2]<<8) + (p_ble_evt->evt.gatts_evt.params.write.data[3]);
                    printf("former = 0x%x", (unsigned int) former);
                    NRF_LOG_INFO("latter = 0x%x", latter);

                }
            }

            break;
        case BLE_GAP_EVT_CONNECTED:
            p_our_service->conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
            break;
        case BLE_GAP_EVT_DISCONNECTED:
            p_our_service->conn_handle = BLE_CONN_HANDLE_INVALID;
            break;
        default:
            // No implementation needed.
            break;
    }
}

Here, NRF_LOG_INFO() function works, meaning that, I can see the log messages on PuTTY but printf() doesn't print anything to the terminal as expected.

This is the screenshot taken from PuTTY:

I want to print the same thing to the vscode terminal with printf() function.

You can download my project folder from here.

Thanks,

Omer

Parents
  • Hi,

    From a Nordic viewpoint this is not something we support. If you want to use VS Code then i suggest that you upgrade to the nRF Connect SDK. 


    So printf() works when you are using putty? But not with VS code terminal?

    What terminal in VS code are you using? This question might be better suited on a VS code forum if it is not specific to one of our VS Code extensions. 


    Have you tested with one of our examples from the nRF 5 SDK? 

    Is this a question about you nRF5 SDK project or a VS code issue? 


    Regards,
    Jonathan

  • Hi Jonathan,

    After talking with one of the senior engineers in the office, it turned out that it is different to run a ".c" program on a computer than on a development kit. Since those programs are run on our DKs, "printf()" statements cannot reach the values to be printed. For this, "NRF_LOG_INFO()-like" functions are used to print out something to PuTTY, and it gets the data from the board using UART.

    Thanks for your reply though,

    Omer

Reply
  • Hi Jonathan,

    After talking with one of the senior engineers in the office, it turned out that it is different to run a ".c" program on a computer than on a development kit. Since those programs are run on our DKs, "printf()" statements cannot reach the values to be printed. For this, "NRF_LOG_INFO()-like" functions are used to print out something to PuTTY, and it gets the data from the board using UART.

    Thanks for your reply though,

    Omer

Children
Related