This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

nonblocking read call (dev_fo_read)


Hi,

I have a problem using the serial device nonblocking.

I have enabled CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING.
In my application I use:

   fd=open("/dev/ser0", O_RDWR | O_NONBLOCK);

If I do a read call:

   received=read(fd,buf,10);
   if (received<0)
      perror("read");
	
I get the error "Try again later", although the read call had get data. With 
debugging I think I have found what is wrong. The serial device driver 
function returns allways with -EAGAIN, if there is data or not. In the 
function "dev_fo_read" will be compared if err is EAGAIN. Here is it going 
wrong, because err is -EAGAIN not EAGAIN.

In "dev_fo_read":

   if( EAGAIN == err ) // must be in non-blocking mode
   {
        uio->uio_resid -= len;
        return ENOERR;
   }

I think this must be:

   if( EAGAIN == -err ) // must be in non-blocking mode
   {
        uio->uio_resid -= len;
        return ENOERR;
   }
 
Does anybody know if this is the right change to make this work?

Thanks,

Roland

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]