Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > why does select syscall returns evenif no data in serial port buffer

Reply
Thread Tools

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

 
 
alok
Guest
Posts: n/a
 
      06-18-2007
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");
}


}

 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      06-18-2007
In article < .com>,
alok <> wrote:

>I have opened a serial port and then blocked on a select system call .


You need to ask this on a unix newsgroup.

>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.
 
Reply With Quote
 
 
 
 
Ben Bacarisse
Guest
Posts: n/a
 
      06-18-2007
alok <> writes:

> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? DR ASP .Net 2 07-29-2008 09:50 AM
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
buffer size of serial port Wills Java 3 09-26-2007 04:23 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Can I connect router Serial interface directly to a PC serial port? Faustino Dina Cisco 2 08-18-2004 02:30 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57