* [ECOS] nonblocking read call (dev_fo_read)
@ 2002-04-04 8:27 Roland Caßebohm
2002-04-05 4:21 ` Nick Garnett
0 siblings, 1 reply; 2+ messages in thread
From: Roland Caßebohm @ 2002-04-04 8:27 UTC (permalink / raw)
To: ecos-discuss
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [ECOS] nonblocking read call (dev_fo_read)
2002-04-04 8:27 [ECOS] nonblocking read call (dev_fo_read) Roland Caßebohm
@ 2002-04-05 4:21 ` Nick Garnett
0 siblings, 0 replies; 2+ messages in thread
From: Nick Garnett @ 2002-04-05 4:21 UTC (permalink / raw)
To: Roland Caßebohm; +Cc: ecos-discuss
Roland Caßebohm <roland.cassebohm@visionsystems.de> writes:
> Does anybody know if this is the right change to make this work?
>
Yep, that looks like a bug. It also needs changing in
dev_fo_write(). I've applied the following patch to our repository:
Index: ChangeLog
===================================================================
RCS file: /home/cvs/ecc/ecc/io/fileio/current/ChangeLog,v
retrieving revision 1.45
diff -u -5 -r1.45 ChangeLog
--- ChangeLog 2002/03/07 16:19:27 1.45
+++ ChangeLog 2002/04/05 12:17:43
@@ -1,5 +1,10 @@
+2002-04-05 Nick Garnett <nickg@redhat.com>
+
+ * src/devfs.cxx: Changed test for EAGAIN in dev_fo_read() and
+ dev_fo_write() to negate value first.
+
2002-03-07 Nick Garnett <nickg@redhat.com>
* doc/fileio.sgml: Added this file to contain documentation on
this package.
Index: src/devfs.cxx
===================================================================
RCS file: /home/cvs/ecc/ecc/io/fileio/current/src/devfs.cxx,v
retrieving revision 1.7
diff -u -5 -r1.7 devfs.cxx
--- src/devfs.cxx 2002/01/23 15:35:13 1.7
+++ src/devfs.cxx 2002/04/05 12:17:43
@@ -341,11 +341,11 @@
else
err = cyg_io_read( (cyg_io_handle_t)t,
iov->iov_base,
&len);
- if( EAGAIN == err ) // must be in non-blocking mode
+ if( -EAGAIN == err ) // must be in non-blocking mode
{
uio->uio_resid -= len;
return ENOERR;
}
if( err < 0 ) break;
@@ -378,11 +378,11 @@
else
err = cyg_io_write( (cyg_io_handle_t)t,
iov->iov_base,
&len);
- if( EAGAIN == err ) // must be in non-blocking mode
+ if( -EAGAIN == err ) // must be in non-blocking mode
{
uio->uio_resid -= len;
return ENOERR;
}
if( err < 0 ) break;
--
Nick Garnett, eCos Kernel Architect
Red Hat, Cambridge, UK
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-04-05 12:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-04 8:27 [ECOS] nonblocking read call (dev_fo_read) Roland Caßebohm
2002-04-05 4:21 ` Nick Garnett
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).