Re: why does select syscall returns evenif no data in serial port buffer
- From: alok <alok.net@xxxxxxxxx>
- Date: Mon, 18 Jun 2007 21:27:18 -0700
On Jun 19, 5:33 am, Barry Margolin <bar...@xxxxxxxxxxxx> wrote:
In article <1182166240.058906.274...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
alok <alok....@xxxxxxxxx> wrote:
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.
Is read() returning 0? That means EOF, and it will cause select() to
return.
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");
}
}
--
Barry Margolin, bar...@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
No read returns number of 0s in buffer . So when every time select
returns and reads the buffer, it found some number of 0s even if this
system is not connected .
.
- Follow-Ups:
- Re: why does select syscall returns evenif no data in serial port buffer
- From: Barry Margolin
- Re: why does select syscall returns evenif no data in serial port buffer
- References:
- Prev by Date: Re: why does select syscall returns evenif no data in serial port buffer
- Next by Date: Re: why does select syscall returns evenif no data in serial port buffer
- Previous by thread: Re: why does select syscall returns evenif no data in serial port buffer
- Next by thread: Re: why does select syscall returns evenif no data in serial port buffer
- Index(es):
Relevant Pages
|
|