This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: non blocking serial read returns EAGAIN
- To: Phung Te Ha <phungte at yahoo dot com>
- Subject: Re: [ECOS] non blocking serial read returns EAGAIN
- From: Jonathan Larmour <jlarmour at redhat dot com>
- Date: Thu, 19 Jul 2001 20:00:00 +0100
- Cc: ecos-discuss at sources dot redhat dot com
- Organization: Red Hat UK Ltd.
- References: <20010719171512.14922.qmail@web12107.mail.yahoo.com>
Phung Te Ha wrote:
>
> Hi everyone,
>
> Would like to have your idea on the following:
>
> . cyg_io_read on a serial port, previously set to non
> blocking returns EAGAIN if less than buffer's len has
> been read.
>
> . This breaks the following situation:
> 1. set to non blocking the serial port
> 2. call select on the port, wait for data.
> 3. on return of select, call read to take the data
> out.
> 4. let's say there's less data than buffer's len, the
> dev_fo_read returns error even before setting read len
> to the uio, and read returns -1, always, even when
> data has been read...
>
> My question is:
> . why would cyg_io_read return error in this case?
It's a different interface with different semantics. It returns -EAGAIN if
less data was returned than expected. Instead it should be the code in
dev_fo_read (and dev_fo_write) that tests for this. Something like just:
Index: devfs.cxx
===================================================================
RCS file: /home/cvs/ecc/ecc/io/fileio/current/src/devfs.cxx,v
retrieving revision 1.4
diff -u -5 -p -r1.4 devfs.cxx
--- devfs.cxx 2000/08/01 08:59:43 1.4
+++ devfs.cxx 2001/07/19 18:58:59
@@ -335,10 +335,15 @@ static int dev_fo_read (struct CYG_
err = cyg_io_read( (cyg_io_handle_t)fp->f_data,
iov->iov_base,
&len);
+ if( EAGAIN == err ) // must be in non-blocking mode
+ {
+ uio->uio_resid -= len;
+ return ENOERR;
+ }
if( err < 0 ) break;
uio->uio_resid -= len;
}
@@ -361,10 +366,15 @@ static int dev_fo_write (struct CYG_
err = cyg_io_write( (cyg_io_handle_t)fp->f_data,
iov->iov_base,
&len);
+ if( EAGAIN == err ) // must be in non-blocking mode
+ {
+ uio->uio_resid -= len;
+ return ENOERR;
+ }
if( err < 0 ) break;
uio->uio_resid -= len;
}
Jifl
--
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
Come to the Red Hat TechWorld open source conference in Brussels!
Keynotes, techie talks and exhibitions http://www.redhat-techworld.com/