Hi,

On Tue, Dec 09, 2008 at 03:47:54PM +0100, Sebastian Reichel wrote:
> On Tue, Dec 09, 2008 at 01:07:22AM +0100, Sascha Wessel wrote:
> > no, fso-gpsd listens on all interfaces by default.
> > I personally don't like this behaviour but on the other hand I want
> > fso-gpsd to behave as much as possible like the original gpsd.
> > Hence my advice to add "-S localhost:gpsd" to the init script,
> > especially since fso-gpsd is installed by default.
> 
> Hi,
> 
> IMHO it's a security flaw, if by default everybody can just
> connect to IP:gpsd and get ones position. In local networks it's not
> a big problem (since position is known), but on some events you get
> an IP, which is accessible via the internet.
> 
> And in local networks somebody could activate the GPS device, so
> that the Freerunner's akku discharges faster...

that's all right. But this is what the original gpsd is doing. It's
comparable with a webserver, if you install it you except it to
listen on port 80...

> Sascha: Since you seem to have much knowledge about frameworkd's
> gps part - do you know why there is a lack of position updates?
> 
> I'm using tangogps + fso-gpsd + frameworkd and rebootet before
> starting mapping to make sure it's not the suspend 100% bug you
> mentioned last time.
> 
> This time I looked on the display when one of these dropouts
> happened and tried to move map arround and switch tabs. It was all
> at normal speed, so it doesn't seem to be an overloaded CPU.
> 
> I also don't think, that I lost the satellites, because
> 1. The Freerunner is mounted on my bike and there is nothing but air
> above it, so best conditions for receiving
> 2. I still receive position changes during this dropout, but not so
> many. As you can see in [1] (for example with JOSM [2])
> 
> P.S.: I just had an idea - My FR started to suffer under Bug #1024
> recently (aka GSM reconnects). If you don't have any other idea I
> will have a look if gsm reconnects and gps dropouts are parallel.

I guess it's a problem with invalid ubx headers. Can you try the
attached patch?


Greetings,
Sascha


> -- Sebastian Reichel
>
> [1] http://openstreetmap.org/user/Sebastian%20Reichel/traces/268857
> [2] http://josm.openstreetmap.de/

diff --git a/framework/subsystems/ogpsd/ubx.py b/framework/subsystems/ogpsd/ubx.py
index 0dbad8e..ff5aab0 100644
--- a/framework/subsystems/ogpsd/ubx.py
+++ b/framework/subsystems/ogpsd/ubx.py
@@ -320,29 +320,40 @@ class UBXDevice( GPSDevice ):
 
     def parse( self, data ):
         self.buffer += data
+        buffer_offset = 0
         # Minimum packet length is 8
-        while len(self.buffer) >= 8:
+        while len(self.buffer) >= buffer_offset + 8:
             # Find the beginning of a UBX message
-            start = self.buffer.find( chr( SYNC1 ) + chr( SYNC2 ) )
-            if start > 0 or (start == -1 and len(self.buffer) > 1):
+            start = self.buffer.find( chr( SYNC1 ) + chr( SYNC2 ), buffer_offset )
+
+            if buffer_offset == 0 and start != 0:
                 logger.debug( "Discarded data not UBX %s" % repr(self.buffer[:start]) )
                 self.buffer = self.buffer[start:]
                 continue
 
-            (cl, id, length) = struct.unpack("<xxBBH", self.buffer[:6])
-            if len(self.buffer) < length + 8:
+            if start == -1:
                 return
 
-            if self.checksum(self.buffer[2:length+6]) != struct.unpack("<BB", self.buffer[length+6:length+8]):
-                logger.warning( "UBX packed class 0x%x, id 0x%x, length %i failed checksum" % (cl, id, length) )
-                self.buffer = self.buffer[2:]
+            (cl, id, length) = struct.unpack("<BBH", self.buffer[start+2:start+6])
+            if len(self.buffer) < start + length + 8:
+                buffer_offset = start + 2 
+                continue
+
+            if self.checksum(self.buffer[start+2:start+length+6]) != struct.unpack("<BB", self.buffer[start+length+6:start+length+8]):
+                buffer_offset = start + 2
+                continue
+
+            if start != 0:
+                logger.warning(" UBX packet ignored %s" % repr(self.buffer[:start]) )
+                self.buffer = self.buffer[start:]
+                buffer_offset = 0
                 continue
 
-            # Now we got a valid UBX packet, decode it
-            self.decode(cl, id, length, self.buffer[6:length+6])
+            self.decode(cl, id, length, self.buffer[start+6:start+length+6])
 
             # Discard packet
-            self.buffer = self.buffer[length+8:]
+            self.buffer = self.buffer[start+length+8:]
+            buffer_offset = 0
 
     def send( self, clid, length, payload ):
         logger.debug( "Sending UBX packet of type %s: %s" % ( clid, payload ) )
_______________________________________________
Smartphones-userland mailing list
Smartphones-userland@linuxtogo.org
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/smartphones-userland

Reply via email to