This is the mail archive of the ecos-discuss@sourceware.cygnus.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]

tty.c driver bug?



Hi, All--

Hmm... sounds like we're all in sync, looking around at the serial port
drivers!  I think that I've found another bug--tell me what you think. The
page
http://sourceware.cygnus.com/ecos/docs-latest/ref/ecos-ref/tty-driver.html
shows some of the different TTY input and output modes which can be
selected...  it implies that CYG_TTY_IN_FLAGS_CR will translate '\r' into
'\n', and that CYG_TTY_IN_FLAGS_CRLF will translate the pair '\r\n' into a
single '\n'...  however, looking in
packages/io/serial/current/src/common/tty.c, about line 212, shows that
CYG_TTY_IN_FLAGS_CR is ignored, and that CYG_TTY_IN_FLAGS_CRLF will
generate a pair of '\n':

(Code snip:)

...
            } else if ((c == '\n') || (c == '\r')) {
                clen = 2;
                if (priv->dev_info.tty_in_flags & CYG_TTY_IN_FLAGS_ECHO) {
                    cyg_io_write(chan, "\n\r", &clen);
                }
                if (priv->dev_info.tty_in_flags & CYG_TTY_IN_FLAGS_CRLF) {
                    c = '\n';  // Map CR -> LF
                }
                buf[size-1] = c;
                break;
            }
...

Looks like CYG_TTY_IN_FLAGS_CRLF should really be CYG_TTY_IN_FLAGS_CR, and
that a previous character should be stored for use with
CYG_TTY_IN_FLAGS_CRLF.  I'll use CYG_TTY_IN_FLAGS_CRLF for the time
being--all I really care about is when the user presses '\r'.  Might be a
good idea that CYG_TTY_IN_FLAGS_CRLF returns a single '\n' for either
'\r\n' or '\n\r'...  I've seen some lame systems which output those
characters in reverse.  Cheers!

-patrick

patrick@softprocess.com



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