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 Reply Children
  • The overrun error is commonly caused by overflowing the RX buffer.

    Increasing the UART buffer might solve this, but not necessarily. It is likely that you will still be receiving at a faster frequency than you are processing the bytes, and therefore a larger buffer will only postpone the inevitable overrun error.
    Most likely, you will need to either ensure that you call app_uart_get() more often or clear out/provide a new buffer every so often to prevent it from building up and exceeding its limit.
    As Awneil suggested, you call to NRF_LOG_FLUSH might be the culprit here(if there is not more to the application than the code you shared earlier).

    Best regards,
    Karl

Related