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

printf doesn't work when implemented in a function.

Hello,

In one of my codes, I use the printf function. It works properly when implemented in the int main(void), but when I try to use it in a static void NAME (void){} function the printf don't print anything over the uart.

Are there any know behaviours about this ?

Config : Segger Embedded Studio, SDKs v15.0, Windows 10, PCA10056 0.12.0 2018.9

Best regards,
Sylvain.

Parents
  • How, exactly, did you "try to use it"?

    Is that function ever called?

    How to post source code:

  • /**@brief Handles events coming from the Custom MOX central module.
     */
    static void cusmox_c_evt_handler(ble_cusmox_c_t * p_cusmox_c, ble_cusmox_c_evt_t * p_cusmox_c_evt)
    {
        switch (p_cusmox_c_evt->evt_type)
        {
            case BLE_CUSMOX_C_EVT_DISCOVERY_COMPLETE:
            {
                ret_code_t err_code;
    
                err_code = ble_cusmox_c_handles_assign(&m_ble_cusmox_c,
                                                    p_cusmox_c_evt->conn_handle,
                                                    &p_cusmox_c_evt->params.peer_db);
                APP_ERROR_CHECK(err_code);
                //NRF_LOG_INFO("Sensor service discovered on conn_handle 0x%x.", p_cusmox_c_evt->conn_handle);
                printf("Sensor service discovered on conn_handle 0x%x.",p_cusmox_c_evt->conn_handle);
    
            default:
                // No implementation needed.
                break;
        }
    }

    Here's a part of the code. If I try to use printf function inside the service handle nothing is printed over the uart ...

Reply
  • /**@brief Handles events coming from the Custom MOX central module.
     */
    static void cusmox_c_evt_handler(ble_cusmox_c_t * p_cusmox_c, ble_cusmox_c_evt_t * p_cusmox_c_evt)
    {
        switch (p_cusmox_c_evt->evt_type)
        {
            case BLE_CUSMOX_C_EVT_DISCOVERY_COMPLETE:
            {
                ret_code_t err_code;
    
                err_code = ble_cusmox_c_handles_assign(&m_ble_cusmox_c,
                                                    p_cusmox_c_evt->conn_handle,
                                                    &p_cusmox_c_evt->params.peer_db);
                APP_ERROR_CHECK(err_code);
                //NRF_LOG_INFO("Sensor service discovered on conn_handle 0x%x.", p_cusmox_c_evt->conn_handle);
                printf("Sensor service discovered on conn_handle 0x%x.",p_cusmox_c_evt->conn_handle);
    
            default:
                // No implementation needed.
                break;
        }
    }

    Here's a part of the code. If I try to use printf function inside the service handle nothing is printed over the uart ...

Children
Related