summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-09 14:25:38 (UTC)
committer zecke <zecke>2002-10-09 14:25:38 (UTC)
commitf9f2d227b3cfbc2187b4f7f535fc59f9735798d0 (patch) (side-by-side diff)
tree7645623f7dde640222fab3e5ff0af0af3ae2f882
parentff0caad7ea46d19f7a7916047fd0914f6f100dde (diff)
downloadopie-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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/io_serial.cpp14
-rw-r--r--noncore/apps/opie-console/profile.cpp2
-rw-r--r--noncore/apps/opie-console/test/console.pro15
-rw-r--r--noncore/apps/opie-console/test/main.cpp13
-rw-r--r--noncore/apps/opie-console/test/sender.ui60
-rw-r--r--noncore/apps/opie-console/test/senderui.cpp47
-rw-r--r--noncore/apps/opie-console/test/senderui.h23
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
@@ -39,8 +39,11 @@ void IOSerial::close() {
bool IOSerial::open() {
+ qWarning("open");
if (!m_fd) {
+ qWarning("going to open %s", m_device.latin1());
struct termios tty;
m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (m_fd < 0) {
+ qWarning(" fd < 0 ");
emit error(CouldNotOpen, strerror(errno));
return FALSE;
@@ -51,4 +54,5 @@ bool IOSerial::open() {
int speed = baud(m_baud);
if (speed == -1) {
+ qWarning("speed -1");
emit error(Refuse, tr("Invalid baud rate"));
}
@@ -114,4 +118,5 @@ bool IOSerial::open() {
return TRUE;
} else {
+ qWarning("opened");
emit error(Refuse, tr("Device is already connected"));
m_fd = 0;
@@ -122,4 +127,6 @@ bool IOSerial::open() {
void IOSerial::reload(const Profile &config) {
m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE);
+ qWarning( "Dev" +m_device );
+ qWarning( "Conf:" +config.readEntry("Device") );
m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD);
m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY);
@@ -151,13 +158,12 @@ void IOSerial::errorOccured() {
void IOSerial::dataArrived() {
- QByteArray array;
- char buf[4096];
+ QByteArray array(4096);
- int len = read(m_fd, buf, 4096);
+ int len = read(m_fd, array.data(), 4096);
if (len == 0)
close();
if (len < 0)
return;
- array.setRawData(buf, len);
+ array.resize( len );
emit received(array);
}
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
@@ -79,7 +79,9 @@ void Profile::clearConf() {
}
void Profile::writeEntry( const QString& key, const QString& value ) {
+ qWarning("key %s value %s", key.latin1(), value.latin1() );
m_conf.replace( key, value );
}
void Profile::writeEntry( const QString& key, int num ) {
+ qWarning("num");
writeEntry( key, QString::number( num ) );
}
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 @@
+TEMPLATE = app
+#CONFIG = qt warn_on release
+CONFIG = qt debug
+#DESTDIR = $(OPIEDIR)/bin
+HEADERS = ../io_layer.h ../io_serial.h \
+ senderui.h ../profile.h
+SOURCES = ../io_layer.cpp ../io_serial.cpp \
+ ../profile.cpp \
+ main.cpp senderui.cpp
+INTERFACES = sender.ui
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe -lopie
+TARGET = test
+
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 @@
+#include <qpe/qpeapplication.h>
+
+#include "senderui.h"
+
+
+int main( int argc, char* argv[] ){
+QPEApplication app(argc,argv );
+
+SenderUI ui;
+app.showMainWidget(&ui);
+
+return app.exec();
+} \ 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 @@
+<!DOCTYPE UI><UI>
+<class>Sender</class>
+<widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Form1</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>596</width>
+ <height>480</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Form1</string>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QMultiLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>MultiLineEdit1</cstring>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButton1</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&amp;Send</string>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>PushButton1</sender>
+ <signal>clicked()</signal>
+ <receiver>Form1</receiver>
+ <slot>slotSend()</slot>
+ </connection>
+ <slot access="public">slotSend()</slot>
+</connections>
+</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 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <qmultilineedit.h>
+
+#include "../profile.h"
+#include "../io_serial.h"
+
+
+#include "senderui.h"
+
+SenderUI::SenderUI()
+ : Sender() {
+
+ /* we do that manually */
+ Profile prof;
+ QString str = "/dev/ttyS0";
+ prof.writeEntry("Device",str );
+ prof.writeEntry("Baud", 115200 );
+
+ qWarning("prof " + prof.readEntry("Device") + " " + str);
+ ser = new IOSerial(prof);
+ connect(ser, SIGNAL(received(const QByteArray& ) ),
+ this, SLOT(got(const QByteArray&) ) );
+
+ if ( ser->open() )
+ qWarning("opened!!!");
+ else
+ qWarning("could not open");
+
+
+
+}
+SenderUI::~SenderUI() {
+
+}
+void SenderUI::slotSend() {
+ QCString str = MultiLineEdit1->text().utf8();
+ qWarning("sending: %s", str.data() );
+ ser->send( str );
+}
+void SenderUI::got(const QByteArray& ar) {
+ for ( uint i = 0; i < ar.count(); i++ ) {
+ printf("%c", ar[i] );
+ }
+ //printf("\n");
+}
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 @@
+#ifndef SENDER_UI_H
+#define SENDER_UI_H
+
+#include <qcstring.h>
+
+#include "sender.h"
+
+class IOSerial;
+class SenderUI : public Sender {
+ Q_OBJECT
+public:
+ SenderUI();
+ ~SenderUI();
+
+public slots:
+ void slotSend();
+ void got(const QByteArray& );
+private:
+ IOSerial* ser;
+};
+
+
+#endif