From 8c6b8752f69aa527e51f00b3a8526fe03dd9e122 Mon Sep 17 00:00:00 2001 From: zecke Date: Fri, 11 Oct 2002 15:08:46 +0000 Subject: Introduce rawIO in the IOLayer This is needed because ?-modem does not like buffered IO at all and we at least double buffered it While sz_transfer is now dead we've filetransfer which is using DirectIO between IOLayer and the SZ IOSerial got adjusted to the rawIO introduction --- (limited to 'noncore/apps/opie-console/sz_transfer.cpp') diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp index 41917c0..0a315cf 100644 --- a/noncore/apps/opie-console/sz_transfer.cpp +++ b/noncore/apps/opie-console/sz_transfer.cpp @@ -5,102 +5,6 @@ #include #include -/* 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 - -} SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) @@ -121,10 +25,10 @@ void SzTransfer::sendFile(const QString& file) { proc = new OProcess; *proc << "sz"; - *proc << "-v" << "-v" << "-v" << "-b" << file; - connect(proc, SIGNAL(processExited(OProcess *)), + *proc << "-v" << "-v" << "-b" << file; + connect(proc, SIGNAL(processExited(OProcess *)), this, SLOT(sent())); - connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), + connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), this, SLOT(SzReceivedStdout(OProcess *, char *, int))); connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), this, SLOT(SzReceivedStderr(OProcess *, char *, int))); @@ -136,27 +40,32 @@ void SzTransfer::sendFile(const QString& file) { void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { - //qWarning("recieved from sz %d bytes", buflen); + qWarning("recieved from sz on stdout %d bytes", buflen); QByteArray data(buflen); data.fill(*buffer, buflen); + for (uint i = 0; i < data.count(); i++ ) { + printf("%c", buffer[i] ); + } + printf("\n"); // send out through the io layer - (layer())->send(data); + layer()->send(data); } void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { // parse and show data in a progress dialog/widget - printf("\n"); - for (int i = 0; i < length; i++) - printf("%c", buffer[i]); + printf("stderr:\n"); + //for (int i = 0; i < length; i++) + // printf("%c", buffer[i]); + //printf("\n"); } 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 proc->writeStdin(data.data(), data.size()); -- cgit v0.9.0.2