Connecting Tech Pros Worldwide Forums | Help | Site Map

why does select syscall returns evenif no data in serial port buffer

alok
Guest
 
Posts: n/a
#1: Jun 18 '07
Hi

I have opened a serial port and then blocked on a select system call .
but select returns even if no data is comming from other end. So when
I read the buffer after select returns, I only found 0s nad this
continues . So the problem is select returns even if there is no data
in serial port buffer.

void main()
{
int fd_uart =-1 ;
int retval,cErr;
fd_set read_fds;
int max_fd = 0;

/* intialize the data set */
if( fd_uart = open("/dev/ttyS0", O_RDWR | O_NOCTTY ) == -1)
{
exit(0);
}

FD_ZERO( &read_fds );
FD_SET(fd_uart, &read_fds );
max_fd = fd_uart;

while(1)

{
select( max_fd + 1, &read_fds, 0, 0, NULL);
printf("\nData\n");
}


}


Richard Tobin
Guest
 
Posts: n/a
#2: Jun 18 '07

re: why does select syscall returns evenif no data in serial port buffer


In article <1182164353.965759.245510@o11g2000prd.googlegroups .com>,
alok <alok.net@gmail.comwrote:
Quote:
>I have opened a serial port and then blocked on a select system call .
You need to ask this on a unix newsgroup.
Quote:
>but select returns even if no data is comming from other end. So when
>I read the buffer after select returns, I only found 0s nad this
>continues .
But I notice you don't test the return value from select(), and you
seem to think that the buffer should be changed after select() returns,
but in fact select() only tells you whether a read() would return
immediately - it doesn't read any data itself.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Ben Bacarisse
Guest
 
Posts: n/a
#3: Jun 18 '07

re: why does select syscall returns evenif no data in serial port buffer


alok <alok.net@gmail.comwrites:
Quote:
Hi
>
I have opened a serial port and then blocked on a select system call.
Wrong group. I happen to have spotted what is wrong and will mail you
a reply (I don't read any of the right groups!).

--
Ben.
Closed Thread