author | zecke <zecke> | 2002-10-11 15:08:46 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-11 15:08:46 (UTC) |
commit | 8c6b8752f69aa527e51f00b3a8526fe03dd9e122 (patch) (unidiff) | |
tree | 074d38fe859dc8482ab0adc53f340669cd501f6e /noncore/apps/opie-console/sz_transfer.cpp | |
parent | 4dff3be36a89c2e864278ce85c477f923c4e3407 (diff) | |
download | opie-8c6b8752f69aa527e51f00b3a8526fe03dd9e122.zip opie-8c6b8752f69aa527e51f00b3a8526fe03dd9e122.tar.gz opie-8c6b8752f69aa527e51f00b3a8526fe03dd9e122.tar.bz2 |
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
Diffstat (limited to 'noncore/apps/opie-console/sz_transfer.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/sz_transfer.cpp | 115 |
1 files changed, 12 insertions, 103 deletions
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 | |||
@@ -7,98 +7,2 @@ | |||
7 | 7 | ||
8 | /* following function ripped out of minicom's sysdep2.c */ | ||
9 | |||
10 | |||
11 | /* | ||
12 | * Set cbreak mode. | ||
13 | * Mode 0 = normal. | ||
14 | * Mode 1 = cbreak, no echo | ||
15 | * Mode 2 = raw, no echo. | ||
16 | * Mode 3 = only return erasechar (for wkeys.c) | ||
17 | * | ||
18 | * Returns: the current erase character. | ||
19 | */ | ||
20 | |||
21 | static struct termios savetty; | ||
22 | int setcbreak(int mode) | ||
23 | { | ||
24 | #if 1 | ||
25 | struct termios tty; | ||
26 | static int init = 0; | ||
27 | static int erasechar; | ||
28 | |||
29 | |||
30 | if (init == 0) { | ||
31 | tcgetattr(0, &savetty); | ||
32 | erasechar = savetty.c_cc[VERASE]; | ||
33 | init++; | ||
34 | } | ||
35 | |||
36 | if (mode == 3) return(erasechar); | ||
37 | |||
38 | |||
39 | |||
40 | /* Always return to default settings first */ | ||
41 | tcsetattr(0, TCSADRAIN, &savetty); | ||
42 | |||
43 | if (mode == 0) { | ||
44 | return(erasechar); | ||
45 | } | ||
46 | |||
47 | tcgetattr(0, &tty); | ||
48 | if (mode == 1) { | ||
49 | tty.c_oflag &= ~OPOST; | ||
50 | tty.c_lflag &= ~(XCASE|ECHONL|NOFLSH); | ||
51 | tty.c_lflag &= ~(ICANON | ISIG | ECHO); | ||
52 | tty.c_iflag &= ~(ICRNL|INLCR); | ||
53 | tty.c_cflag |= CREAD; | ||
54 | tty.c_cc[VTIME] = 5; | ||
55 | tty.c_cc[VMIN] = 1; | ||
56 | } | ||
57 | if (mode == 2) { /* raw */ | ||
58 | tty.c_iflag &= ~(IGNBRK | IGNCR | INLCR | ICRNL | IUCLC | | ||
59 | IXANY | IXON | IXOFF | INPCK | ISTRIP); | ||
60 | tty.c_iflag |= (BRKINT | IGNPAR); | ||
61 | tty.c_oflag &= ~OPOST; | ||
62 | tty.c_lflag &= ~(XCASE|ECHONL|NOFLSH); | ||
63 | tty.c_lflag &= ~(ICANON | ISIG | ECHO); | ||
64 | tty.c_cflag |= CREAD; | ||
65 | tty.c_cc[VTIME] = 5; | ||
66 | tty.c_cc[VMIN] = 1; | ||
67 | } | ||
68 | tcsetattr(0, TCSADRAIN, &tty); | ||
69 | return(erasechar); | ||
70 | #else | ||
71 | struct sgttyb args; | ||
72 | static int init = 0; | ||
73 | static int erasechar; | ||
74 | |||
75 | if (init == 0) { | ||
76 | (void) ioctl(0, TIOCGETP, &savetty); | ||
77 | (void) ioctl(0, TIOCGETC, &savetty2); | ||
78 | erasechar = savetty.sg_erase; | ||
79 | init++; | ||
80 | } | ||
81 | |||
82 | if (mode == 3) return(erasechar); | ||
83 | |||
84 | if (mode == 0) { | ||
85 | (void) ioctl(0, TIOCSETP, &savetty); | ||
86 | (void) ioctl(0, TIOCSETC, &savetty2); | ||
87 | return(erasechar); | ||
88 | } | ||
89 | |||
90 | (void) ioctl(0, TIOCGETP, &args); | ||
91 | if (mode == 1) { | ||
92 | args.sg_flags |= CBREAK; | ||
93 | args.sg_flags &= ~(ECHO|RAW); | ||
94 | } | ||
95 | if (mode == 2) { | ||
96 | args.sg_flags |= RAW; | ||
97 | args.sg_flags &= ~(ECHO|CBREAK); | ||
98 | } | ||
99 | (void) ioctl(0, TIOCSETP, &args); | ||
100 | return(erasechar); | ||
101 | #endif | ||
102 | |||
103 | } | ||
104 | 8 | ||
@@ -123,3 +27,3 @@ void SzTransfer::sendFile(const QString& file) { | |||
123 | *proc << "sz"; | 27 | *proc << "sz"; |
124 | *proc << "-v" << "-v" << "-v" << "-b" << file; | 28 | *proc << "-v" << "-v" << "-b" << file; |
125 | connect(proc, SIGNAL(processExited(OProcess *)), | 29 | connect(proc, SIGNAL(processExited(OProcess *)), |
@@ -138,3 +42,3 @@ void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { | |||
138 | 42 | ||
139 | //qWarning("recieved from sz %d bytes", buflen); | 43 | qWarning("recieved from sz on stdout %d bytes", buflen); |
140 | 44 | ||
@@ -142,5 +46,9 @@ void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { | |||
142 | data.fill(*buffer, buflen); | 46 | data.fill(*buffer, buflen); |
47 | for (uint i = 0; i < data.count(); i++ ) { | ||
48 | printf("%c", buffer[i] ); | ||
49 | } | ||
50 | printf("\n"); | ||
143 | 51 | ||
144 | // send out through the io layer | 52 | // send out through the io layer |
145 | (layer())->send(data); | 53 | layer()->send(data); |
146 | } | 54 | } |
@@ -150,5 +58,6 @@ void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { | |||
150 | // parse and show data in a progress dialog/widget | 58 | // parse and show data in a progress dialog/widget |
151 | printf("\n"); | 59 | printf("stderr:\n"); |
152 | for (int i = 0; i < length; i++) | 60 | //for (int i = 0; i < length; i++) |
153 | printf("%c", buffer[i]); | 61 | // printf("%c", buffer[i]); |
62 | //printf("\n"); | ||
154 | } | 63 | } |
@@ -157,3 +66,3 @@ void SzTransfer::receivedStdin(const QByteArray &data) { | |||
157 | 66 | ||
158 | //qWarning("recieved from io_serial %d bytes", data.size()); | 67 | qWarning("recieved from io_serial %d bytes", data.size()); |
159 | 68 | ||