Serial UART lost characters

Hi all

I currently have a project where i send and receive commands over UART to another chip.  When i receive a message over UART,  a callback is  triggered and I continuously read the serial terminal using  "uart_fifo_read(uart_dev_test, &c, 1) " until the end of the line is found.  Why is it that when the when the buffer reaches over 300 bytes, i seem to miss characters over the UART line?

 
static char serial_response[1000];
  
void serial_cb(const struct device *dev, void *user_data)
{
    if (!uart_irq_update(uart_dev_test))
    {
        return;
    }
    

    uint8_t c;

    uart_fifo_read(uart_dev_test, &c, 1);
    rx_buf[0] = c;

    // Check to see if buffer is full

    if (((strlen(serial_response) + strlen(rx_buf)) > 1000))
    {
        LOG_WRN("Response buffer full");
    }
    else
    {
        strcat(serial_response, rx_buf);
    }

    clearCharArray(rx_buf, sizeof(rx_buf));

   

    if ((c == ASCII_NEW_LINE || c == ASCII_CARRIAGE_RETURN))
    {
       // Do something
    }
Parents
  • Hi Hkhan7861,

    Could you show me how the characters missing in your test ? 
    I did a quick test here with the echo_bot sample and it seems to work fine. I don't see any character missing: 

    I changed MSG_SIZE to 1000 and reduce the number of message to 2

    K_MSGQ_DEFINE(uart_msgq, MSG_SIZE, 2, 4);

    Also I increased the main stack size: 
    CONFIG_MAIN_STACK_SIZE=4069
Reply
  • Hi Hkhan7861,

    Could you show me how the characters missing in your test ? 
    I did a quick test here with the echo_bot sample and it seems to work fine. I don't see any character missing: 

    I changed MSG_SIZE to 1000 and reduce the number of message to 2

    K_MSGQ_DEFINE(uart_msgq, MSG_SIZE, 2, 4);

    Also I increased the main stack size: 
    CONFIG_MAIN_STACK_SIZE=4069
Children
No Data
Related