This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UART RX buffer read problem

Other Parts Discussed in Thread: AM1705

Hi Everybody!

I'm using linux kernel 3.2.2 on Sitara AM1705. 

My application has a select() function that checks UART ( /dev/ttyS1 ) for received data. I read incoming data without errors within read(). Then the program redirects received symbols to the main console ( /dev/ttyS0 ).

The problem is in receive data loss on ttyS1. I see this when check received symbols in application buffer.

By the inspection and changing kernel code I found out that RX FIFO trigger (FIFO Control buffer) is set to 8 bytes. So, I tried to change trigger to 1 byte and it makes less data loss.  Hence it appears that application can't read out received symbols from UART RX buffer in time! Application consumes max 2.3% of the CPU time (top statistics). Why this is happening?

Has anybody ever encountered this issue? What should I do? Should I change kernel driver or my application?

See my code clippings below =>

....

  /* Open second uart with fd */
 fd = open("/dev/ttyS1", O_RDWR | O_ASYNC | O_NDELAY);
 if (fd == -1) {
 /* Could not open the second uart */
SYS_LOG_ERR("unable to open /dev/ttyS1");
return CLI_FAILURE;
}
else {
/* Setup open file flags */
 fcntl(fd, F_SETFL, 0);
}

.....

/* Read incoming data */

 if ((len = read(fd, msg, (sizeof(msg)-1))) < 0)
{
  SYS_LOG_ERR("read from second uart failed");
}
else
{

/* Data redirection */

....

}