I've recently noticed a very odd behavior on my system (running on an AT91SAM9G15): Despite the fact I'm reading serial port continuously, TTY driver takes sometimes 1,2s to deliver data from the input censored.
Thing is: I'm not losing any data, it just takes too many calls to read for it to come.
Maybe my code will help to explain the problem.
First off, I set my serial port:
Code: Select all
/* 8N1 */
tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8;
/** Parity bit (none) */
tty.c_cflag &= ~(PARENB | PARODD);
/** Stop bit (1)*/
tty.c_cflag &= ~CSTOPB;
/* Noncanonical mode */
tty.c_lflag = 0;
tty.c_oflag = 0;
tty.c_cc[VMIN] = 0;
tty.c_cc[VTIME] = 0;
Code: Select all
s_ret = select(rfid_fd + 1, &set, NULL, NULL, &port_timeval);
Code: Select all
switch (s_ret)
{
case SRET_TIMOUT:
//Timeout do rfid sem ler nada
//CRTCL_PRINTF(D_RFID_MSG, "Select Timeout\n");
sem_post(&sem_rfid);
return u16_recv_len;
case SRET_ERROR:
//CRTCL_PRINTF(D_RFID_MSG, "Error: Select Timeout\n");
sem_post(&sem_rfid);
register_error(EM_RFID,EM_RFID_SELECT_FAILURE);
return -EINTR;
default:
if ((rd_ret = read(rfid_fd, &recv_buff[u16_recv_len], (u16_req_len - u16_recv_len))) > 0)
{
u16_recv_len += rd_ret;
}
break;
}
I've tried every kind of setting I could think of. It's tricky now since I don't know if at91 UART drivers aren't delivering data to tty driver or tty driver isn't fetching it? which is which here?
Any help would be appreciated.