public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] non blocking serial read returns EAGAIN
@ 2001-07-19 10:15 Phung Te Ha
  2001-07-19 12:00 ` Jonathan Larmour
  0 siblings, 1 reply; 2+ messages in thread
From: Phung Te Ha @ 2001-07-19 10:15 UTC (permalink / raw)
  To: ecos-discuss

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?

Thanks for your idea.

Phungte

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] non blocking serial read returns EAGAIN
  2001-07-19 10:15 [ECOS] non blocking serial read returns EAGAIN Phung Te Ha
@ 2001-07-19 12:00 ` Jonathan Larmour
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Larmour @ 2001-07-19 12:00 UTC (permalink / raw)
  To: Phung Te Ha; +Cc: ecos-discuss

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/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-07-19 12:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-19 10:15 [ECOS] non blocking serial read returns EAGAIN Phung Te Ha
2001-07-19 12:00 ` Jonathan Larmour

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).