author | mickeyl <mickeyl> | 2004-02-15 15:28:27 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-15 15:28:27 (UTC) |
commit | 4f5703de93628ec6920957ef18d6cd5c87a69ba1 (patch) (unidiff) | |
tree | 674e0d5eeb30ccf52dd5f0491522e651c2383116 | |
parent | 3d50523ac7782e08795fabb071c8678d79a71b13 (diff) | |
download | opie-4f5703de93628ec6920957ef18d6cd5c87a69ba1.zip opie-4f5703de93628ec6920957ef18d6cd5c87a69ba1.tar.gz opie-4f5703de93628ec6920957ef18d6cd5c87a69ba1.tar.bz2 |
*** empty log message ***
-rw-r--r-- | noncore/net/wellenreiter/TODO | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 34 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 15 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.h | 1 |
4 files changed, 32 insertions, 20 deletions
diff --git a/noncore/net/wellenreiter/TODO b/noncore/net/wellenreiter/TODO index fd70fc7..b6ec617 100644 --- a/noncore/net/wellenreiter/TODO +++ b/noncore/net/wellenreiter/TODO | |||
@@ -30,6 +30,8 @@ ENGINE | |||
30 | 30 | ||
31 | - enable sniffing in wired networks | 31 | - enable sniffing in wired networks |
32 | 32 | ||
33 | - fix autodetection (interface name) | ||
34 | |||
33 | --------- | 35 | --------- |
34 | UI | 36 | UI |
35 | --------- | 37 | --------- |
diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp index b814427..5b1b4a4 100644 --- a/noncore/net/wellenreiter/gui/gps.cpp +++ b/noncore/net/wellenreiter/gui/gps.cpp | |||
@@ -45,6 +45,8 @@ bool GPS::open( const QString& host, int port ) | |||
45 | GpsLocation GPS::position() const | 45 | GpsLocation GPS::position() const |
46 | { | 46 | { |
47 | char buf[256]; | 47 | char buf[256]; |
48 | double lat = -111.0; | ||
49 | double lon = -111.0; | ||
48 | 50 | ||
49 | int result = _socket->writeBlock( "p\r\n", 3 ); | 51 | int result = _socket->writeBlock( "p\r\n", 3 ); |
50 | _socket->flush(); | 52 | _socket->flush(); |
@@ -53,19 +55,19 @@ GpsLocation GPS::position() const | |||
53 | int numAvail = _socket->bytesAvailable(); | 55 | int numAvail = _socket->bytesAvailable(); |
54 | qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); | 56 | qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); |
55 | if ( numAvail ) | 57 | if ( numAvail ) |
56 | { | 58 | { |
57 | QTextStream stream( _socket ); | 59 | int numRead = _socket->readBlock( &buf[0], sizeof buf ); |
58 | 60 | int numScan = sscanf( &buf[0], "GPSD,P=%lg %lg", &lat, &lon); | |
59 | QString str; | 61 | |
60 | stream.readRawBytes( &buf[0], 7 ); | 62 | if ( numRead < 7 || numScan != 2 ) |
61 | float lat = -111; | 63 | { |
62 | stream >> lat; | 64 | qDebug( "GPS read %d bytes succeeded, invalid response: '%s'", numRead, &buf[0] ); |
63 | stream.skipWhiteSpace(); | 65 | return GpsLocation( -111, -111 ); |
64 | float lon = -111; | 66 | } |
65 | stream >> lon; | 67 | else |
66 | stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF | 68 | { |
67 | 69 | return GpsLocation( lat, lon ); | |
68 | return GpsLocation( lat, lon ); | 70 | } |
69 | } | 71 | } |
70 | } | 72 | } |
71 | return GpsLocation( -111, -111 ); | 73 | return GpsLocation( -111, -111 ); |
@@ -123,9 +125,3 @@ QString GpsLocation::dmsPosition() const | |||
123 | 125 | ||
124 | return dms; | 126 | return dms; |
125 | } | 127 | } |
126 | |||
127 | |||
128 | |||
129 | |||
130 | |||
131 | |||
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 05a8913..b462afd 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qstatusbar.h> | 36 | #include <qstatusbar.h> |
37 | #include <qspinbox.h> | ||
37 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
38 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
39 | 40 | ||
@@ -133,6 +134,7 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
133 | 134 | ||
134 | QPopupMenu* demo = new QPopupMenu( mb ); | 135 | QPopupMenu* demo = new QPopupMenu( mb ); |
135 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); | 136 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); |
137 | demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); | ||
136 | 138 | ||
137 | id = mb->insertItem( tr( "&File" ), file ); | 139 | id = mb->insertItem( tr( "&File" ), file ); |
138 | //id = mb->insertItem( tr( "&View" ), view ); | 140 | //id = mb->insertItem( tr( "&View" ), view ); |
@@ -223,7 +225,7 @@ WellenreiterMainWindow::~WellenreiterMainWindow() | |||
223 | 225 | ||
224 | void WellenreiterMainWindow::demoAddStations() | 226 | void WellenreiterMainWindow::demoAddStations() |
225 | { | 227 | { |
226 | //mw = 0; // test SIGSGV handling | 228 | //mw = 0; // test SIGSEGV handling |
227 | 229 | ||
228 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); | 230 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); |
229 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); | 231 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); |
@@ -233,6 +235,17 @@ void WellenreiterMainWindow::demoAddStations() | |||
233 | } | 235 | } |
234 | 236 | ||
235 | 237 | ||
238 | void WellenreiterMainWindow::demoReadFromGps() | ||
239 | { | ||
240 | WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); | ||
241 | GPS* gps = new GPS( this ); | ||
242 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | ||
243 | GpsLocation loc = gps->position(); | ||
244 | |||
245 | QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n$1" ).arg( loc.dmsPosition() ) ); | ||
246 | } | ||
247 | |||
248 | |||
236 | QString WellenreiterMainWindow::getFileName( bool save ) | 249 | QString WellenreiterMainWindow::getFileName( bool save ) |
237 | { | 250 | { |
238 | QMap<QString, QStringList> map; | 251 | QMap<QString, QStringList> map; |
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h index 8d4e768..a5cb7a5 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.h +++ b/noncore/net/wellenreiter/gui/mainwindow.h | |||
@@ -50,6 +50,7 @@ class WellenreiterMainWindow: public QMainWindow | |||
50 | public slots: | 50 | public slots: |
51 | void showConfigure(); | 51 | void showConfigure(); |
52 | void demoAddStations(); | 52 | void demoAddStations(); |
53 | void demoReadFromGps(); | ||
53 | void fileSaveLog(); | 54 | void fileSaveLog(); |
54 | void fileSaveHex(); | 55 | void fileSaveHex(); |
55 | void fileSaveSession(); | 56 | void fileSaveSession(); |