public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Jonathan Larmour <jlarmour@redhat.com>
To: Phung Te Ha <phungte@yahoo.com>
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] non blocking serial read returns EAGAIN
Date: Thu, 19 Jul 2001 12:00:00 -0000	[thread overview]
Message-ID: <3B572E30.95E143D5@redhat.com> (raw)
In-Reply-To: <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/

      reply	other threads:[~2001-07-19 12:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-19 10:15 Phung Te Ha
2001-07-19 12:00 ` Jonathan Larmour [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B572E30.95E143D5@redhat.com \
    --to=jlarmour@redhat.com \
    --cc=ecos-discuss@sources.redhat.com \
    --cc=phungte@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).