This is the mail archive of the
ecos-discuss@sourceware.cygnus.com
mailing list for the eCos project.
tty driver
- To: <ecos-discuss at sourceware dot cygnus dot com>
- Subject: [ECOS] tty driver
- From: "Perry Wang" <perrywang at nmnc dot com>
- Date: Tue, 21 Dec 1999 14:45:22 -0800
The current tty driver source echos backspace even if it's already at the
beginning of the line.
Also, cyg_io_read returns -1 when user send backspace at the beginning of
the line. This is self-explanatory if you look at the code.
Here is the fix. Please let me know if all this is unnecessary. I would
prefer not having to change the eCos source.
--------------
[root@mail common]# diff -u tty.c.orig tty.c
--- tty.c.orig Tue Dec 21 14:17:14 1999
+++ tty.c Tue Dec 21 14:44:19 1999
@@ -191,7 +191,8 @@
cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle;
struct tty_private_info *priv = (struct tty_private_info *)t->priv;
cyg_io_handle_t chan = (cyg_io_handle_t)priv->dev_handle;
- cyg_uint32 size, clen;
+ cyg_int32 size;
+ cyg_uint32 clen;
Cyg_ErrNo res;
cyg_uint8 c;
cyg_uint8 *buf = (cyg_uint8 *)_buf;
@@ -208,8 +209,11 @@
if ((priv->dev_info.tty_in_flags & CYG_TTY_IN_FLAGS_BINARY) == 0) {
if ((c == '\b') || (c == 0x7F)) {
size -= 2; // erase one character + 'backspace' char
- if (size < 0) size = 0;
- if (priv->dev_info.tty_in_flags & CYG_TTY_IN_FLAGS_ECHO) {
+ if (size < 0) { // beginning of the line, don't echo \b
+ size = 0;
+ } else if (priv->dev_info.tty_in_flags &
+ CYG_TTY_IN_FLAGS_ECHO)
+ {
clen = 3;
cyg_io_write(chan, "\b \b", &clen);
}