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



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 .

.



Relevant Pages

  • [PATCH] Numerous fixes to kernel-doc info in source files.
    ... static inline int ffs ... @buffer: where the data must be copied. ... * struct kfifo with kfree. ... @timer: ...
    (Linux-Kernel)
  • [UNIX] Multiple Vulnerabilities in Citadel/UX
    ... could allow complete control over a vulnerable server. ... Citadel server as can be seen by this simplistic code snippet: ... configuration buffers, leading to the possibility of carrying out a buffer ... int connect_to_host; ...
    (Securiteam)
  • Re: pushing the envelope with sockets
    ... receiving on the socket they are received (upto the buffer size), you can even change what happens if the buffer runs full. ... int read = S.EndReceive; ... class AsyncReader: Reader ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [PATCH] Updated: Reworked Cell OProfile: SPU mutex lock fix
    ... arch-independent pieces of the OProfile kernel driver that this patch ... kernel driver patches. ... into the kernel buffer without holding the buffer_mutex lock. ... int spu_sync_start; ...
    (Linux-Kernel)
  • [PATCH] char: make functions static in synclinkmp.c
    ... int *eof, void *data) ... /* Allocate DMA buffers for the transmit and receive descriptor lists. ... * This buffer is used to pass an assembled frame to the line discipline. ...
    (Linux-Kernel)