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

APP_UART_COMMUNICATION_ERROR on handle

I'm having troubles parsing the received data stream form an UART device. If i just print whatever i received from the datastream, everything works just fine.

    if (p_event->evt_type == APP_UART_DATA_READY){
        app_uart_get(&rx);
        NRF_LOG_RAW_INFO("%c", rx);
        NRF_LOG_FLUSH();
    }

Howeve, if i try to store it in an external string and then print it , it returns APP_UART_COMMUNICATION_ERROR during reception.

    if (p_event->evt_type == APP_UART_DATA_READY){
        app_uart_get(&rx);
        if(rx == 0xD){
            buff[i] = (uint8_t)'\0';
            i = 0;
            NRF_LOG_RAW_INFO("%s", NRF_LOG_PUSH((char *)buff));
            NRF_LOG_FLUSH();
        }else{
            buff[i++] = rx;
        }
    }

Parents
  • What transport are you using for NRF_LOG ?

    If it's UART, then NRF_LOG_FLUSH(); could take some time - and cause overrun in your data reception ... ?

    it returns APP_UART_COMMUNICATION_ERROR

    What is "it" ?

  • The project is based on the uart example (on peripheral) and uses RTT as NRF_LOG backend. The event handled by the function is from that type (APP_UART_COMMUNICATION_ERROR).

    void uart_handle(app_uart_evt_t * p_event)
    {
        uint8_t rx;
        if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR)
        {
            //APP_ERROR_HANDLER(p_event->data.error_communication);
            NRF_LOG_RAW_INFO("APP_UART_COMMUNICATION_ERROR\n");
            NRF_LOG_FLUSH();
        }
        else if (p_event->evt_type == APP_UART_FIFO_ERROR)
        {
            //APP_ERROR_HANDLER(p_event->data.error_code);        
            NRF_LOG_RAW_INFO("APP_UART_FIFO_ERROR\n");
            NRF_LOG_FLUSH();
        } else if (p_event->evt_type == APP_UART_DATA_READY){
            app_uart_get(&rx);
            NRF_LOG_RAW_INFO("%c", rx);
            NRF_LOG_FLUSH();
            nrf_delay_ms(1000);
        }
    }

Reply
  • The project is based on the uart example (on peripheral) and uses RTT as NRF_LOG backend. The event handled by the function is from that type (APP_UART_COMMUNICATION_ERROR).

    void uart_handle(app_uart_evt_t * p_event)
    {
        uint8_t rx;
        if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR)
        {
            //APP_ERROR_HANDLER(p_event->data.error_communication);
            NRF_LOG_RAW_INFO("APP_UART_COMMUNICATION_ERROR\n");
            NRF_LOG_FLUSH();
        }
        else if (p_event->evt_type == APP_UART_FIFO_ERROR)
        {
            //APP_ERROR_HANDLER(p_event->data.error_code);        
            NRF_LOG_RAW_INFO("APP_UART_FIFO_ERROR\n");
            NRF_LOG_FLUSH();
        } else if (p_event->evt_type == APP_UART_DATA_READY){
            app_uart_get(&rx);
            NRF_LOG_RAW_INFO("%c", rx);
            NRF_LOG_FLUSH();
            nrf_delay_ms(1000);
        }
    }

Children
Related