author | zecke <zecke> | 2002-09-28 18:29:02 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-28 18:29:02 (UTC) |
commit | bc88219d0a9cf935d90c88fe75e238e86c675937 (patch) (unidiff) | |
tree | 0121d1d3d881cf69948f3faf420a71d894dd6832 /noncore/apps/opie-console/io_serial.cpp | |
parent | 18d575d0ee47a0700091de81bc3e8c54be4eae18 (diff) | |
download | opie-bc88219d0a9cf935d90c88fe75e238e86c675937.zip opie-bc88219d0a9cf935d90c88fe75e238e86c675937.tar.gz opie-bc88219d0a9cf935d90c88fe75e238e86c675937.tar.bz2 |
io_layer take Profile instead of Config
Profile added including some Config like stuff
io_serial getBaud -> baud
a default for gcc3 later
tabdwidget will be our central widget
profileconfig I needed groups() and clearAll
that's pretty much it
Diffstat (limited to 'noncore/apps/opie-console/io_serial.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/io_serial.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp index c9155d1..b495f39 100644 --- a/noncore/apps/opie-console/io_serial.cpp +++ b/noncore/apps/opie-console/io_serial.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include "io_serial.h" | 5 | #include "io_serial.h" |
6 | 6 | ||
7 | IOSerial::IOSerial(const Config &config) : IOLayer(config) { | 7 | IOSerial::IOSerial(const Profile &config) : IOLayer(config) { |
8 | m_fd = 0; | 8 | m_fd = 0; |
9 | reload(config); | 9 | reload(config); |
10 | } | 10 | } |
@@ -46,7 +46,7 @@ bool IOSerial::open() { | |||
46 | tcgetattr(m_fd, &tty); | 46 | tcgetattr(m_fd, &tty); |
47 | 47 | ||
48 | /* Baud rate */ | 48 | /* Baud rate */ |
49 | int speed = getBaud(m_baud); | 49 | int speed = baud(m_baud); |
50 | if (speed == -1) { | 50 | if (speed == -1) { |
51 | emit error(Refuse, tr("Invalid baud rate")); | 51 | emit error(Refuse, tr("Invalid baud rate")); |
52 | } | 52 | } |
@@ -57,15 +57,16 @@ bool IOSerial::open() { | |||
57 | if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { | 57 | if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { |
58 | m_dbits = 8; | 58 | m_dbits = 8; |
59 | } | 59 | } |
60 | 60 | ||
61 | /* Data bits */ | 61 | /* Data bits */ |
62 | switch (m_dbits) { | 62 | switch (m_dbits) { |
63 | case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; | 63 | case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; |
64 | case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; | 64 | case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; |
65 | case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; | 65 | case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; |
66 | case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; | 66 | case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; |
67 | default: break; | ||
67 | } | 68 | } |
68 | 69 | ||
69 | /* Raw, no echo mode */ | 70 | /* Raw, no echo mode */ |
70 | tty.c_iflag = IGNBRK; | 71 | tty.c_iflag = IGNBRK; |
71 | tty.c_lflag = 0; | 72 | tty.c_lflag = 0; |
@@ -78,7 +79,7 @@ bool IOSerial::open() { | |||
78 | } else { | 79 | } else { |
79 | tty.c_cflag &= ~CSTOPB; | 80 | tty.c_cflag &= ~CSTOPB; |
80 | } | 81 | } |
81 | 82 | ||
82 | tty.c_cc[VMIN] = 1; | 83 | tty.c_cc[VMIN] = 1; |
83 | tty.c_cc[VTIME] = 5; | 84 | tty.c_cc[VTIME] = 5; |
84 | 85 | ||
@@ -87,19 +88,19 @@ bool IOSerial::open() { | |||
87 | tty.c_iflag |= IXON | IXOFF; | 88 | tty.c_iflag |= IXON | IXOFF; |
88 | else | 89 | else |
89 | tty.c_iflag &= ~(IXON|IXOFF|IXANY); | 90 | tty.c_iflag &= ~(IXON|IXOFF|IXANY); |
90 | 91 | ||
91 | if (m_flow & FlowHW) | 92 | if (m_flow & FlowHW) |
92 | tty.c_cflag |= CRTSCTS; | 93 | tty.c_cflag |= CRTSCTS; |
93 | else | 94 | else |
94 | tty.c_cflag &= ~CRTSCTS; | 95 | tty.c_cflag &= ~CRTSCTS; |
95 | 96 | ||
96 | /* Parity */ | 97 | /* Parity */ |
97 | tty.c_cflag &= ~(PARENB | PARODD); | 98 | tty.c_cflag &= ~(PARENB | PARODD); |
98 | if (m_parity & ParityEven) | 99 | if (m_parity & ParityEven) |
99 | tty.c_cflag |= PARENB; | 100 | tty.c_cflag |= PARENB; |
100 | else if (m_parity & ParityOdd) | 101 | else if (m_parity & ParityOdd) |
101 | tty.c_cflag |= (PARENB | PARODD); | 102 | tty.c_cflag |= (PARENB | PARODD); |
102 | 103 | ||
103 | /* Set the changes */ | 104 | /* Set the changes */ |
104 | tcsetattr(m_fd, TCSANOW, &tty); | 105 | tcsetattr(m_fd, TCSANOW, &tty); |
105 | 106 | ||
@@ -115,7 +116,7 @@ bool IOSerial::open() { | |||
115 | } | 116 | } |
116 | } | 117 | } |
117 | 118 | ||
118 | void IOSerial::reload(const Config &config) { | 119 | void IOSerial::reload(const Profile &config) { |
119 | m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); | 120 | m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); |
120 | m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD); | 121 | m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD); |
121 | m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); | 122 | m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); |
@@ -124,7 +125,7 @@ void IOSerial::reload(const Config &config) { | |||
124 | m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW); | 125 | m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW); |
125 | } | 126 | } |
126 | 127 | ||
127 | int IOSerial::getBaud(int baud) const { | 128 | int IOSerial::baud(int baud) const { |
128 | switch (baud) { | 129 | switch (baud) { |
129 | case 300: return B300; break; | 130 | case 300: return B300; break; |
130 | case 600: return B600; break; | 131 | case 600: return B600; break; |