author | zecke <zecke> | 2002-10-09 14:25:38 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-09 14:25:38 (UTC) |
commit | f9f2d227b3cfbc2187b4f7f535fc59f9735798d0 (patch) (unidiff) | |
tree | 7645623f7dde640222fab3e5ff0af0af3ae2f882 | |
parent | ff0caad7ea46d19f7a7916047fd0914f6f100dde (diff) | |
download | opie-f9f2d227b3cfbc2187b4f7f535fc59f9735798d0.zip opie-f9f2d227b3cfbc2187b4f7f535fc59f9735798d0.tar.gz opie-f9f2d227b3cfbc2187b4f7f535fc59f9735798d0.tar.bz2 |
A small testsuite
the stuff from the remote goes to the stdout
There is a send button and a multilineedit
be sure to hit \n before sending...
Some debug code... in some files
debugged IOSerial it should be fine now
-rw-r--r-- | noncore/apps/opie-console/io_serial.cpp | 14 | ||||
-rw-r--r-- | noncore/apps/opie-console/profile.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/test/console.pro | 15 | ||||
-rw-r--r-- | noncore/apps/opie-console/test/main.cpp | 13 | ||||
-rw-r--r-- | noncore/apps/opie-console/test/sender.ui | 60 | ||||
-rw-r--r-- | noncore/apps/opie-console/test/senderui.cpp | 47 | ||||
-rw-r--r-- | noncore/apps/opie-console/test/senderui.h | 23 |
7 files changed, 170 insertions, 4 deletions
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp index 77ced85..929aeff 100644 --- a/noncore/apps/opie-console/io_serial.cpp +++ b/noncore/apps/opie-console/io_serial.cpp | |||
@@ -1,171 +1,177 @@ | |||
1 | #include <fcntl.h> | 1 | #include <fcntl.h> |
2 | #include <termios.h> | 2 | #include <termios.h> |
3 | #include <errno.h> | 3 | #include <errno.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include "io_serial.h" | 5 | #include "io_serial.h" |
6 | 6 | ||
7 | IOSerial::IOSerial(const Profile &config) : IOLayer(config) { | 7 | IOSerial::IOSerial(const Profile &config) : IOLayer(config) { |
8 | m_read = 0l; | 8 | m_read = 0l; |
9 | m_error = 0l; | 9 | m_error = 0l; |
10 | m_fd = 0; | 10 | m_fd = 0; |
11 | reload(config); | 11 | reload(config); |
12 | } | 12 | } |
13 | 13 | ||
14 | 14 | ||
15 | IOSerial::~IOSerial() { | 15 | IOSerial::~IOSerial() { |
16 | if (m_fd) { | 16 | if (m_fd) { |
17 | close(); | 17 | close(); |
18 | } | 18 | } |
19 | } | 19 | } |
20 | 20 | ||
21 | void IOSerial::send(const QByteArray &data) { | 21 | void IOSerial::send(const QByteArray &data) { |
22 | if (m_fd) { | 22 | if (m_fd) { |
23 | write(m_fd, data.data(), data.size()); | 23 | write(m_fd, data.data(), data.size()); |
24 | } else { | 24 | } else { |
25 | emit error(Refuse, tr("Not connected")); | 25 | emit error(Refuse, tr("Not connected")); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | void IOSerial::close() { | 29 | void IOSerial::close() { |
30 | if (m_fd) { | 30 | if (m_fd) { |
31 | delete m_read; | 31 | delete m_read; |
32 | delete m_error; | 32 | delete m_error; |
33 | ::close(m_fd); | 33 | ::close(m_fd); |
34 | m_fd = 0; | 34 | m_fd = 0; |
35 | } else { | 35 | } else { |
36 | emit error(Refuse, tr("Not connected")); | 36 | emit error(Refuse, tr("Not connected")); |
37 | } | 37 | } |
38 | } | 38 | } |
39 | 39 | ||
40 | bool IOSerial::open() { | 40 | bool IOSerial::open() { |
41 | qWarning("open"); | ||
41 | if (!m_fd) { | 42 | if (!m_fd) { |
43 | qWarning("going to open %s", m_device.latin1()); | ||
42 | struct termios tty; | 44 | struct termios tty; |
43 | m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK); | 45 | m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK); |
44 | if (m_fd < 0) { | 46 | if (m_fd < 0) { |
47 | qWarning(" fd < 0 "); | ||
45 | emit error(CouldNotOpen, strerror(errno)); | 48 | emit error(CouldNotOpen, strerror(errno)); |
46 | return FALSE; | 49 | return FALSE; |
47 | } | 50 | } |
48 | tcgetattr(m_fd, &tty); | 51 | tcgetattr(m_fd, &tty); |
49 | 52 | ||
50 | /* Baud rate */ | 53 | /* Baud rate */ |
51 | int speed = baud(m_baud); | 54 | int speed = baud(m_baud); |
52 | if (speed == -1) { | 55 | if (speed == -1) { |
56 | qWarning("speed -1"); | ||
53 | emit error(Refuse, tr("Invalid baud rate")); | 57 | emit error(Refuse, tr("Invalid baud rate")); |
54 | } | 58 | } |
55 | cfsetospeed(&tty, speed); | 59 | cfsetospeed(&tty, speed); |
56 | cfsetispeed(&tty, speed); | 60 | cfsetispeed(&tty, speed); |
57 | 61 | ||
58 | /* Take care of Space / Mark parity */ | 62 | /* Take care of Space / Mark parity */ |
59 | if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { | 63 | if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { |
60 | m_dbits = 8; | 64 | m_dbits = 8; |
61 | } | 65 | } |
62 | 66 | ||
63 | /* Data bits */ | 67 | /* Data bits */ |
64 | switch (m_dbits) { | 68 | switch (m_dbits) { |
65 | case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; | 69 | case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; |
66 | case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; | 70 | case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; |
67 | case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; | 71 | case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; |
68 | case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; | 72 | case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; |
69 | default: break; | 73 | default: break; |
70 | } | 74 | } |
71 | 75 | ||
72 | /* Raw, no echo mode */ | 76 | /* Raw, no echo mode */ |
73 | tty.c_iflag = IGNBRK; | 77 | tty.c_iflag = IGNBRK; |
74 | tty.c_lflag = 0; | 78 | tty.c_lflag = 0; |
75 | tty.c_oflag = 0; | 79 | tty.c_oflag = 0; |
76 | tty.c_cflag |= CLOCAL | CREAD; | 80 | tty.c_cflag |= CLOCAL | CREAD; |
77 | 81 | ||
78 | /* Stop bits */ | 82 | /* Stop bits */ |
79 | if (m_sbits == 2) { | 83 | if (m_sbits == 2) { |
80 | tty.c_cflag |= CSTOPB; | 84 | tty.c_cflag |= CSTOPB; |
81 | } else { | 85 | } else { |
82 | tty.c_cflag &= ~CSTOPB; | 86 | tty.c_cflag &= ~CSTOPB; |
83 | } | 87 | } |
84 | 88 | ||
85 | tty.c_cc[VMIN] = 1; | 89 | tty.c_cc[VMIN] = 1; |
86 | tty.c_cc[VTIME] = 5; | 90 | tty.c_cc[VTIME] = 5; |
87 | 91 | ||
88 | /* Flow control */ | 92 | /* Flow control */ |
89 | if (m_flow & FlowSW) | 93 | if (m_flow & FlowSW) |
90 | tty.c_iflag |= IXON | IXOFF; | 94 | tty.c_iflag |= IXON | IXOFF; |
91 | else | 95 | else |
92 | tty.c_iflag &= ~(IXON|IXOFF|IXANY); | 96 | tty.c_iflag &= ~(IXON|IXOFF|IXANY); |
93 | 97 | ||
94 | if (m_flow & FlowHW) | 98 | if (m_flow & FlowHW) |
95 | tty.c_cflag |= CRTSCTS; | 99 | tty.c_cflag |= CRTSCTS; |
96 | else | 100 | else |
97 | tty.c_cflag &= ~CRTSCTS; | 101 | tty.c_cflag &= ~CRTSCTS; |
98 | 102 | ||
99 | /* Parity */ | 103 | /* Parity */ |
100 | tty.c_cflag &= ~(PARENB | PARODD); | 104 | tty.c_cflag &= ~(PARENB | PARODD); |
101 | if (m_parity & ParityEven) | 105 | if (m_parity & ParityEven) |
102 | tty.c_cflag |= PARENB; | 106 | tty.c_cflag |= PARENB; |
103 | else if (m_parity & ParityOdd) | 107 | else if (m_parity & ParityOdd) |
104 | tty.c_cflag |= (PARENB | PARODD); | 108 | tty.c_cflag |= (PARENB | PARODD); |
105 | 109 | ||
106 | /* Set the changes */ | 110 | /* Set the changes */ |
107 | tcsetattr(m_fd, TCSANOW, &tty); | 111 | tcsetattr(m_fd, TCSANOW, &tty); |
108 | 112 | ||
109 | /* Notifications on read & errors */ | 113 | /* Notifications on read & errors */ |
110 | m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); | 114 | m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); |
111 | m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); | 115 | m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); |
112 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); | 116 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); |
113 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); | 117 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); |
114 | return TRUE; | 118 | return TRUE; |
115 | } else { | 119 | } else { |
120 | qWarning("opened"); | ||
116 | emit error(Refuse, tr("Device is already connected")); | 121 | emit error(Refuse, tr("Device is already connected")); |
117 | m_fd = 0; | 122 | m_fd = 0; |
118 | return FALSE; | 123 | return FALSE; |
119 | } | 124 | } |
120 | } | 125 | } |
121 | 126 | ||
122 | void IOSerial::reload(const Profile &config) { | 127 | void IOSerial::reload(const Profile &config) { |
123 | m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); | 128 | m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); |
129 | qWarning( "Dev" +m_device ); | ||
130 | qWarning( "Conf:" +config.readEntry("Device") ); | ||
124 | m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD); | 131 | m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD); |
125 | m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); | 132 | m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); |
126 | m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS); | 133 | m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS); |
127 | m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS); | 134 | m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS); |
128 | m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW); | 135 | m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW); |
129 | } | 136 | } |
130 | 137 | ||
131 | int IOSerial::baud(int baud) const { | 138 | int IOSerial::baud(int baud) const { |
132 | switch (baud) { | 139 | switch (baud) { |
133 | case 300: return B300; break; | 140 | case 300: return B300; break; |
134 | case 600: return B600; break; | 141 | case 600: return B600; break; |
135 | case 1200: return B1200; break; | 142 | case 1200: return B1200; break; |
136 | case 2400: return B2400; break; | 143 | case 2400: return B2400; break; |
137 | case 4800: return B4800; break; | 144 | case 4800: return B4800; break; |
138 | case 9600: return B9600; break; | 145 | case 9600: return B9600; break; |
139 | case 19200: return B19200; break; | 146 | case 19200: return B19200; break; |
140 | case 38400: return B38400; break; | 147 | case 38400: return B38400; break; |
141 | case 57600: return B57600; break; | 148 | case 57600: return B57600; break; |
142 | case 115200: return B115200; break; | 149 | case 115200: return B115200; break; |
143 | } | 150 | } |
144 | return -1; | 151 | return -1; |
145 | } | 152 | } |
146 | 153 | ||
147 | void IOSerial::errorOccured() { | 154 | void IOSerial::errorOccured() { |
148 | emit error(ClosedUnexpected, strerror(errno)); | 155 | emit error(ClosedUnexpected, strerror(errno)); |
149 | close(); | 156 | close(); |
150 | } | 157 | } |
151 | 158 | ||
152 | void IOSerial::dataArrived() { | 159 | void IOSerial::dataArrived() { |
153 | QByteArray array; | 160 | QByteArray array(4096); |
154 | char buf[4096]; | ||
155 | 161 | ||
156 | int len = read(m_fd, buf, 4096); | 162 | int len = read(m_fd, array.data(), 4096); |
157 | if (len == 0) | 163 | if (len == 0) |
158 | close(); | 164 | close(); |
159 | if (len < 0) | 165 | if (len < 0) |
160 | return; | 166 | return; |
161 | array.setRawData(buf, len); | 167 | array.resize( len ); |
162 | emit received(array); | 168 | emit received(array); |
163 | } | 169 | } |
164 | 170 | ||
165 | QString IOSerial::identifier() const { | 171 | QString IOSerial::identifier() const { |
166 | return "serial"; | 172 | return "serial"; |
167 | } | 173 | } |
168 | 174 | ||
169 | QString IOSerial::name() const { | 175 | QString IOSerial::name() const { |
170 | return "RS232 Serial IO Layer"; | 176 | return "RS232 Serial IO Layer"; |
171 | } | 177 | } |
diff --git a/noncore/apps/opie-console/profile.cpp b/noncore/apps/opie-console/profile.cpp index 1a94619..ffd672e 100644 --- a/noncore/apps/opie-console/profile.cpp +++ b/noncore/apps/opie-console/profile.cpp | |||
@@ -33,87 +33,89 @@ Profile &Profile::operator=( const Profile& prof ) { | |||
33 | return *this; | 33 | return *this; |
34 | } | 34 | } |
35 | Profile::~Profile() { | 35 | Profile::~Profile() { |
36 | } | 36 | } |
37 | QMap<QString, QString> Profile::conf()const { | 37 | QMap<QString, QString> Profile::conf()const { |
38 | return m_conf; | 38 | return m_conf; |
39 | } | 39 | } |
40 | QString Profile::name()const { | 40 | QString Profile::name()const { |
41 | return m_name; | 41 | return m_name; |
42 | } | 42 | } |
43 | QCString Profile::ioLayerName()const { | 43 | QCString Profile::ioLayerName()const { |
44 | return m_ioLayer; | 44 | return m_ioLayer; |
45 | } | 45 | } |
46 | QCString Profile::terminalName( )const { | 46 | QCString Profile::terminalName( )const { |
47 | return m_term; | 47 | return m_term; |
48 | } | 48 | } |
49 | int Profile::foreground()const { | 49 | int Profile::foreground()const { |
50 | return m_fore; | 50 | return m_fore; |
51 | } | 51 | } |
52 | int Profile::background()const { | 52 | int Profile::background()const { |
53 | return m_back; | 53 | return m_back; |
54 | } | 54 | } |
55 | int Profile::terminal()const { | 55 | int Profile::terminal()const { |
56 | return m_terminal; | 56 | return m_terminal; |
57 | } | 57 | } |
58 | void Profile::setName( const QString& str ) { | 58 | void Profile::setName( const QString& str ) { |
59 | m_name = str; | 59 | m_name = str; |
60 | } | 60 | } |
61 | void Profile::setIOLayer( const QCString& name ) { | 61 | void Profile::setIOLayer( const QCString& name ) { |
62 | m_ioLayer = name; | 62 | m_ioLayer = name; |
63 | } | 63 | } |
64 | void Profile::setTerminalName( const QCString& str ) { | 64 | void Profile::setTerminalName( const QCString& str ) { |
65 | m_term = str; | 65 | m_term = str; |
66 | } | 66 | } |
67 | void Profile::setBackground( int back ) { | 67 | void Profile::setBackground( int back ) { |
68 | m_back = back; | 68 | m_back = back; |
69 | } | 69 | } |
70 | void Profile::setForeground( int fore ) { | 70 | void Profile::setForeground( int fore ) { |
71 | m_fore = fore; | 71 | m_fore = fore; |
72 | } | 72 | } |
73 | void Profile::setTerminal( int term ) { | 73 | void Profile::setTerminal( int term ) { |
74 | m_terminal = term; | 74 | m_terminal = term; |
75 | } | 75 | } |
76 | /* config stuff */ | 76 | /* config stuff */ |
77 | void Profile::clearConf() { | 77 | void Profile::clearConf() { |
78 | m_conf.clear(); | 78 | m_conf.clear(); |
79 | } | 79 | } |
80 | void Profile::writeEntry( const QString& key, const QString& value ) { | 80 | void Profile::writeEntry( const QString& key, const QString& value ) { |
81 | qWarning("key %s value %s", key.latin1(), value.latin1() ); | ||
81 | m_conf.replace( key, value ); | 82 | m_conf.replace( key, value ); |
82 | } | 83 | } |
83 | void Profile::writeEntry( const QString& key, int num ) { | 84 | void Profile::writeEntry( const QString& key, int num ) { |
85 | qWarning("num"); | ||
84 | writeEntry( key, QString::number( num ) ); | 86 | writeEntry( key, QString::number( num ) ); |
85 | } | 87 | } |
86 | void Profile::writeEntry( const QString& key, bool b ) { | 88 | void Profile::writeEntry( const QString& key, bool b ) { |
87 | writeEntry( key, QString::number(b) ); | 89 | writeEntry( key, QString::number(b) ); |
88 | } | 90 | } |
89 | void Profile::writeEntry( const QString& key, const QStringList& lis, const QChar& sep ) { | 91 | void Profile::writeEntry( const QString& key, const QStringList& lis, const QChar& sep ) { |
90 | writeEntry( key, lis.join(sep) ); | 92 | writeEntry( key, lis.join(sep) ); |
91 | } | 93 | } |
92 | QString Profile::readEntry( const QString& key, const QString& deflt )const { | 94 | QString Profile::readEntry( const QString& key, const QString& deflt )const { |
93 | QMap<QString, QString>::ConstIterator it; | 95 | QMap<QString, QString>::ConstIterator it; |
94 | it = m_conf.find( key ); | 96 | it = m_conf.find( key ); |
95 | 97 | ||
96 | if ( it != m_conf.end() ) | 98 | if ( it != m_conf.end() ) |
97 | return it.data(); | 99 | return it.data(); |
98 | 100 | ||
99 | return deflt; | 101 | return deflt; |
100 | } | 102 | } |
101 | int Profile::readNumEntry( const QString& key, int def )const { | 103 | int Profile::readNumEntry( const QString& key, int def )const { |
102 | QMap<QString, QString>::ConstIterator it; | 104 | QMap<QString, QString>::ConstIterator it; |
103 | it = m_conf.find( key ); | 105 | it = m_conf.find( key ); |
104 | 106 | ||
105 | if ( it != m_conf.end() ) { | 107 | if ( it != m_conf.end() ) { |
106 | bool ok; | 108 | bool ok; |
107 | int val = it.data().toInt(&ok); | 109 | int val = it.data().toInt(&ok); |
108 | 110 | ||
109 | if (ok) | 111 | if (ok) |
110 | return val; | 112 | return val; |
111 | } | 113 | } |
112 | return def; | 114 | return def; |
113 | } | 115 | } |
114 | bool Profile::readBoolEntry( const QString& key, bool def )const { | 116 | bool Profile::readBoolEntry( const QString& key, bool def )const { |
115 | return readNumEntry( key, def ); | 117 | return readNumEntry( key, def ); |
116 | } | 118 | } |
117 | void Profile::setConf( const QMap<QString, QString>& conf ) { | 119 | void Profile::setConf( const QMap<QString, QString>& conf ) { |
118 | m_conf = conf; | 120 | m_conf = conf; |
119 | }; | 121 | }; |
diff --git a/noncore/apps/opie-console/test/console.pro b/noncore/apps/opie-console/test/console.pro new file mode 100644 index 0000000..721b820 --- a/dev/null +++ b/noncore/apps/opie-console/test/console.pro | |||
@@ -0,0 +1,15 @@ | |||
1 | TEMPLATE = app | ||
2 | #CONFIG = qt warn_on release | ||
3 | CONFIG = qt debug | ||
4 | #DESTDIR = $(OPIEDIR)/bin | ||
5 | HEADERS = ../io_layer.h ../io_serial.h \ | ||
6 | senderui.h ../profile.h | ||
7 | SOURCES = ../io_layer.cpp ../io_serial.cpp \ | ||
8 | ../profile.cpp \ | ||
9 | main.cpp senderui.cpp | ||
10 | INTERFACES = sender.ui | ||
11 | INCLUDEPATH += $(OPIEDIR)/include | ||
12 | DEPENDPATH += $(OPIEDIR)/include | ||
13 | LIBS += -lqpe -lopie | ||
14 | TARGET = test | ||
15 | |||
diff --git a/noncore/apps/opie-console/test/main.cpp b/noncore/apps/opie-console/test/main.cpp new file mode 100644 index 0000000..f5e8722 --- a/dev/null +++ b/noncore/apps/opie-console/test/main.cpp | |||
@@ -0,0 +1,13 @@ | |||
1 | #include <qpe/qpeapplication.h> | ||
2 | |||
3 | #include "senderui.h" | ||
4 | |||
5 | |||
6 | int main( int argc, char* argv[] ){ | ||
7 | QPEApplication app(argc,argv ); | ||
8 | |||
9 | SenderUI ui; | ||
10 | app.showMainWidget(&ui); | ||
11 | |||
12 | return app.exec(); | ||
13 | } \ No newline at end of file | ||
diff --git a/noncore/apps/opie-console/test/sender.ui b/noncore/apps/opie-console/test/sender.ui new file mode 100644 index 0000000..092f6e3 --- a/dev/null +++ b/noncore/apps/opie-console/test/sender.ui | |||
@@ -0,0 +1,60 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>Sender</class> | ||
3 | <widget> | ||
4 | <class>QWidget</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>Form1</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>596</width> | ||
15 | <height>480</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Form1</string> | ||
21 | </property> | ||
22 | <vbox> | ||
23 | <property stdset="1"> | ||
24 | <name>margin</name> | ||
25 | <number>11</number> | ||
26 | </property> | ||
27 | <property stdset="1"> | ||
28 | <name>spacing</name> | ||
29 | <number>6</number> | ||
30 | </property> | ||
31 | <widget> | ||
32 | <class>QMultiLineEdit</class> | ||
33 | <property stdset="1"> | ||
34 | <name>name</name> | ||
35 | <cstring>MultiLineEdit1</cstring> | ||
36 | </property> | ||
37 | </widget> | ||
38 | <widget> | ||
39 | <class>QPushButton</class> | ||
40 | <property stdset="1"> | ||
41 | <name>name</name> | ||
42 | <cstring>PushButton1</cstring> | ||
43 | </property> | ||
44 | <property stdset="1"> | ||
45 | <name>text</name> | ||
46 | <string>&Send</string> | ||
47 | </property> | ||
48 | </widget> | ||
49 | </vbox> | ||
50 | </widget> | ||
51 | <connections> | ||
52 | <connection> | ||
53 | <sender>PushButton1</sender> | ||
54 | <signal>clicked()</signal> | ||
55 | <receiver>Form1</receiver> | ||
56 | <slot>slotSend()</slot> | ||
57 | </connection> | ||
58 | <slot access="public">slotSend()</slot> | ||
59 | </connections> | ||
60 | </UI> | ||
diff --git a/noncore/apps/opie-console/test/senderui.cpp b/noncore/apps/opie-console/test/senderui.cpp new file mode 100644 index 0000000..fc93c04 --- a/dev/null +++ b/noncore/apps/opie-console/test/senderui.cpp | |||
@@ -0,0 +1,47 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <stdio.h> | ||
3 | |||
4 | #include <qmultilineedit.h> | ||
5 | |||
6 | #include "../profile.h" | ||
7 | #include "../io_serial.h" | ||
8 | |||
9 | |||
10 | #include "senderui.h" | ||
11 | |||
12 | SenderUI::SenderUI() | ||
13 | : Sender() { | ||
14 | |||
15 | /* we do that manually */ | ||
16 | Profile prof; | ||
17 | QString str = "/dev/ttyS0"; | ||
18 | prof.writeEntry("Device",str ); | ||
19 | prof.writeEntry("Baud", 115200 ); | ||
20 | |||
21 | qWarning("prof " + prof.readEntry("Device") + " " + str); | ||
22 | ser = new IOSerial(prof); | ||
23 | connect(ser, SIGNAL(received(const QByteArray& ) ), | ||
24 | this, SLOT(got(const QByteArray&) ) ); | ||
25 | |||
26 | if ( ser->open() ) | ||
27 | qWarning("opened!!!"); | ||
28 | else | ||
29 | qWarning("could not open"); | ||
30 | |||
31 | |||
32 | |||
33 | } | ||
34 | SenderUI::~SenderUI() { | ||
35 | |||
36 | } | ||
37 | void SenderUI::slotSend() { | ||
38 | QCString str = MultiLineEdit1->text().utf8(); | ||
39 | qWarning("sending: %s", str.data() ); | ||
40 | ser->send( str ); | ||
41 | } | ||
42 | void SenderUI::got(const QByteArray& ar) { | ||
43 | for ( uint i = 0; i < ar.count(); i++ ) { | ||
44 | printf("%c", ar[i] ); | ||
45 | } | ||
46 | //printf("\n"); | ||
47 | } | ||
diff --git a/noncore/apps/opie-console/test/senderui.h b/noncore/apps/opie-console/test/senderui.h new file mode 100644 index 0000000..bc69f5d --- a/dev/null +++ b/noncore/apps/opie-console/test/senderui.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef SENDER_UI_H | ||
2 | #define SENDER_UI_H | ||
3 | |||
4 | #include <qcstring.h> | ||
5 | |||
6 | #include "sender.h" | ||
7 | |||
8 | class IOSerial; | ||
9 | class SenderUI : public Sender { | ||
10 | Q_OBJECT | ||
11 | public: | ||
12 | SenderUI(); | ||
13 | ~SenderUI(); | ||
14 | |||
15 | public slots: | ||
16 | void slotSend(); | ||
17 | void got(const QByteArray& ); | ||
18 | private: | ||
19 | IOSerial* ser; | ||
20 | }; | ||
21 | |||
22 | |||
23 | #endif | ||