This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Limited to reading 8 bytes per transmission on uart_fifo_read() Function

Hi, 

Is it possible to increase the size of the buffer for the UART IRQ RX function such that it receives more than 8 bytes at each interrupt? Currently I am trying to send a packet with a size greater than 8 bytes and when I print out via Putty terminal, the message gets truncated to only 8 bytes. 

The current function of uart_fifo_read() ignores the size input entirely and also reads one byte at a time e.g. uart_fifo_read(client,&buffer,len) where len is greater than 8.  I have circumvented the issue of the function only reading one byte at a time via a while loop and called the function and used a delimiter to break the loop so that isn't the biggest issue here.  

My entry function is the callback function declared through uart_irq_rx_enable(uart,uart_cb). Here's an excerpt of how I've implemented.

if(uart_irq_rx_ready(x)){
while(j<32){
data_length = uart_fifo_read(x,&input,sizeof(input));
uart_buf[j] = input[0];
if(uart_buf[j] == '/'){
break;
}
j++;
}
}

Much thanks

Tyson

  • Hi Tyson

    I would recommend using the UART async driver. Then you can use a larger buffer if you want, and get an RX callback if there has been no activity for a pre-determined amount of time (timeout). 

    Also, if you utilize the double buffering capability of the driver you ensure that you don't lose any data if the buffer fills up in the middle of a transaction. 

    I made an example showing how you can use this driver here:
    https://github.com/too1/ncs-uart-async-count-rx

    Best regards
    Torbjørn

Related