Diffstat (limited to 'noncore/net/wellenreiter/gui/gps.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
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 | |||
@@ -47,2 +47,4 @@ GpsLocation GPS::position() const | |||
47 | char buf[256]; | 47 | char buf[256]; |
48 | double lat = -111.0; | ||
49 | double lon = -111.0; | ||
48 | 50 | ||
@@ -56,13 +58,12 @@ GpsLocation GPS::position() const | |||
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; | ||
60 | stream.readRawBytes( &buf[0], 7 ); | ||
61 | float lat = -111; | ||
62 | stream >> lat; | ||
63 | stream.skipWhiteSpace(); | ||
64 | float lon = -111; | ||
65 | stream >> lon; | ||
66 | stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF | ||
67 | 61 | ||
62 | if ( numRead < 7 || numScan != 2 ) | ||
63 | { | ||
64 | qDebug( "GPS read %d bytes succeeded, invalid response: '%s'", numRead, &buf[0] ); | ||
65 | return GpsLocation( -111, -111 ); | ||
66 | } | ||
67 | else | ||
68 | { | ||
68 | return GpsLocation( lat, lon ); | 69 | return GpsLocation( lat, lon ); |
@@ -70,2 +71,3 @@ GpsLocation GPS::position() const | |||
70 | } | 71 | } |
72 | } | ||
71 | return GpsLocation( -111, -111 ); | 73 | return GpsLocation( -111, -111 ); |
@@ -125,7 +127 @@ QString GpsLocation::dmsPosition() const | |||
125 | } | } | |
126 | |||
127 | |||
128 | |||
129 | |||
130 | |||
131 | |||