This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
NONBLOCK mode in serial.c
- To: <ecos-discuss at sourceware dot cygnus dot com>
- Subject: [ECOS] NONBLOCK mode in serial.c
- From: "Boris V. Guzhov" <borg at int dot spb dot ru>
- Date: Tue, 15 May 2001 11:18:17 +0400
There are some remarks to io/serial/current/src/common/serial.c file.
I think that in it the NONBLOCK mode is incorrectly implemented
(not like POSIX).
1) I the serial_write() function there is a code:
#ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
// Optionally return if configured for non-blocking
mode.
if (!cbuf->blocking) {
*len -= size; // number of characters actually
sent
cbuf->waiting = false;
res = -EAGAIN;
break;
}
#endif // CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
Probably it should assign res=-EAGAIN only if *len = 0, otherwise
it should assign res=ENOERR:
#ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
// Optionally return if configured for non-blocking
mode.
if (!cbuf->blocking) {
*len -= size; // number of characters actually
sent
cbuf->waiting = false;
res = *len ? ENOERR : -EAGAIN;
break;
}
#endif // CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
2) In the serial_read() function there is:
} else {
#ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
if (!cbuf->blocking) {
*len = size; // characters actually read
res = -EAGAIN;
break;
}
#endif // CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
Similarly: if size>0 it should assign res=ENOERR:
} else {
if (size) {
*len = size; // characters actually read
res = ENOERR;
break;
}
#ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
if (!cbuf->blocking) {
*len = 0;
res = -EAGAIN;
break;
}
#endif // CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
--
Boris Guzhov,
St.Petersburg, Russia