This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

NONBLOCK mode in serial.c


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]