author | hash <hash> | 2002-10-09 20:34:13 (UTC) |
---|---|---|
committer | hash <hash> | 2002-10-09 20:34:13 (UTC) |
commit | 091480d5d5fbe22e2f8f9814af3767cc08913236 (patch) (side-by-side diff) | |
tree | aba1ad94996339691f94586739cee911098a10c2 | |
parent | 907c53e8024f2a44795ce35890b686fbe1b7be9e (diff) | |
download | opie-091480d5d5fbe22e2f8f9814af3767cc08913236.zip opie-091480d5d5fbe22e2f8f9814af3767cc08913236.tar.gz opie-091480d5d5fbe22e2f8f9814af3767cc08913236.tar.bz2 |
thought it not work because the terminal echo, but i copied some code that
enables/disables echoing from minicom, and it still doesnt work.
-rw-r--r-- | noncore/apps/opie-console/sz_transfer.cpp | 111 |
1 files changed, 109 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp index a5af2be..41917c0 100644 --- a/noncore/apps/opie-console/sz_transfer.cpp +++ b/noncore/apps/opie-console/sz_transfer.cpp @@ -5,2 +5,101 @@ #include <stdio.h> +#include <sys/termios.h> + +/* following function ripped out of minicom's sysdep2.c */ + + +/* + * Set cbreak mode. + * Mode 0 = normal. + * Mode 1 = cbreak, no echo + * Mode 2 = raw, no echo. + * Mode 3 = only return erasechar (for wkeys.c) + * + * Returns: the current erase character. + */ + +static struct termios savetty; +int setcbreak(int mode) +{ +#if 1 + struct termios tty; + static int init = 0; + static int erasechar; + + + if (init == 0) { + tcgetattr(0, &savetty); + erasechar = savetty.c_cc[VERASE]; + init++; + } + + if (mode == 3) return(erasechar); + + + + /* Always return to default settings first */ + tcsetattr(0, TCSADRAIN, &savetty); + + if (mode == 0) { + return(erasechar); + } + + tcgetattr(0, &tty); + if (mode == 1) { + tty.c_oflag &= ~OPOST; + tty.c_lflag &= ~(XCASE|ECHONL|NOFLSH); + tty.c_lflag &= ~(ICANON | ISIG | ECHO); + tty.c_iflag &= ~(ICRNL|INLCR); + tty.c_cflag |= CREAD; + tty.c_cc[VTIME] = 5; + tty.c_cc[VMIN] = 1; + } + if (mode == 2) { /* raw */ + tty.c_iflag &= ~(IGNBRK | IGNCR | INLCR | ICRNL | IUCLC | + IXANY | IXON | IXOFF | INPCK | ISTRIP); + tty.c_iflag |= (BRKINT | IGNPAR); + tty.c_oflag &= ~OPOST; + tty.c_lflag &= ~(XCASE|ECHONL|NOFLSH); + tty.c_lflag &= ~(ICANON | ISIG | ECHO); + tty.c_cflag |= CREAD; + tty.c_cc[VTIME] = 5; + tty.c_cc[VMIN] = 1; + } + tcsetattr(0, TCSADRAIN, &tty); + return(erasechar); +#else + struct sgttyb args; + static int init = 0; + static int erasechar; + + if (init == 0) { + (void) ioctl(0, TIOCGETP, &savetty); + (void) ioctl(0, TIOCGETC, &savetty2); + erasechar = savetty.sg_erase; + init++; + } + + if (mode == 3) return(erasechar); + + if (mode == 0) { + (void) ioctl(0, TIOCSETP, &savetty); + (void) ioctl(0, TIOCSETC, &savetty2); + return(erasechar); + } + + (void) ioctl(0, TIOCGETP, &args); + if (mode == 1) { + args.sg_flags |= CBREAK; + args.sg_flags &= ~(ECHO|RAW); + } + if (mode == 2) { + args.sg_flags |= RAW; + args.sg_flags &= ~(ECHO|CBREAK); + } + (void) ioctl(0, TIOCSETP, &args); + return(erasechar); +#endif + +} + @@ -20,2 +119,4 @@ void SzTransfer::sendFile(const QString& file) { + //setcbreak(2); /* raw no echo */ + proc = new OProcess; @@ -37,3 +138,3 @@ void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { - qWarning("recieved from sz %d bytes", buflen); + //qWarning("recieved from sz %d bytes", buflen); @@ -56,3 +157,4 @@ void SzTransfer::receivedStdin(const QByteArray &data) { - qWarning("recieved from io_serial %d bytes", data.size()); + //qWarning("recieved from io_serial %d bytes", data.size()); + // recieved data from the io layer goes to sz @@ -65,2 +167,6 @@ void SzTransfer::sent() { qWarning("sent file"); + + //setcbreak(0); /* default */ + + delete proc; @@ -68,2 +174,3 @@ void SzTransfer::sent() { this, SLOT(receivedStdin(const QByteArray &))); + } |