[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, master, updated. milestone4-368-g700ab82

Jan Luebbe jluebbe at debian.org
Mon Feb 2 18:51:56 UTC 2009


The following commit has been merged in the master branch:
commit 27e6e2dfe3c81bb754ca02d8e99007593dc44519
Author: Jan Luebbe <jluebbe at debian.org>
Date:   Wed Jan 14 22:10:28 2009 +0100

    ogpsd: add support for debugging via UDP

diff --git a/framework/subsystems/ogpsd/factory.py b/framework/subsystems/ogpsd/factory.py
index 8762410..be35550 100644
--- a/framework/subsystems/ogpsd/factory.py
+++ b/framework/subsystems/ogpsd/factory.py
@@ -33,8 +33,11 @@ def factory( prefix, controller ):
     devname = config.getValue( "ogpsd", "device", "DummyDevice")
     channame = config.getValue( "ogpsd", "channel", "GPSChannel")
     pathname = config.getValue( "ogpsd", "path", "")
+    debug = config.getValue( "ogpsd", "debug_addr", "")
 
     channel = globals()[channame]( pathname )
+    if debug:
+        channel.setDebugChannel( UDPChannel( debug ) )
     gpsdev = globals()[devname]( controller.bus, channel )
     objects.append( gpsdev )
 
diff --git a/framework/subsystems/ogpsd/gpschannel.py b/framework/subsystems/ogpsd/gpschannel.py
index 567af0e..5beddcd 100644
--- a/framework/subsystems/ogpsd/gpschannel.py
+++ b/framework/subsystems/ogpsd/gpschannel.py
@@ -25,6 +25,11 @@ class GPSChannel( object ):
     """A GPS Channel :-)"""
     def __init__( self, path=None ):
         self.callback = None
+        self.debugChannel = None
+
+    def setDebugChannel( self, debugChannel ):
+        self.debugChannel = debugChannel
+        self.debugChannel.setCallback( self.send )
 
     def initializeChannel( self ):
         pass
@@ -47,22 +52,40 @@ class GPSChannel( object ):
 class UDPChannel ( GPSChannel ):
     """Generic UDP reader"""
 
-    def __init__(self, path):
+    def __init__( self, path ):
         super(UDPChannel, self).__init__()
         logger.debug("UDPChannel opens port %s" % path)
-        self.port = int(path)
-        self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-        self.s.bind(('', self.port))
+        if ":" in path:
+            self.host, self.port = path.split( ":" )
+            self.port = int( self.port )
+        else:
+            self.host = ""
+            self.port = int( path )
+        self.s = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
+        self.s.bind( ("", self.port) )
         self.s.setblocking(False)
+        self.datapending = ""
         self.watchReadyToRead = gobject.io_add_watch( self.s.makefile(), gobject.IO_IN, self.readyToRead )
+        self.watchReadyToSend = None
 
     def readyToRead( self, source, condition ):
         data = self.s.recv(1024)
         if self.callback:
             self.callback(data)
-
         return True
 
+    def readyToSend( self, source, condition ):
+        if self.host:
+            self.s.sendto( self.datapending, (self.host, self.port) )
+        self.datapending = ""
+        self.watchReadyToSend = None
+        return False
+
+    def send( self, stream ):
+        self.datapending = self.datapending + stream
+        if not self.watchReadyToSend:
+            self.watchReadyToSend = gobject.io_add_watch( self.s.makefile(), gobject.IO_OUT, self.readyToSend )
+
 class GllinChannel( UDPChannel ):
     """UDP reader for GTA01, takes care of starting and stopping gllin"""
 
@@ -162,6 +185,9 @@ class SerialChannel( GPSChannel ):
             inWaiting = 0
 
         data = self.serial.read( inWaiting )
+
+        if self.debugChannel:
+            self.debugChannel.send( data )
         if self.callback:
             self.callback( data )
 

-- 
FSO frameworkd Debian packaging



More information about the pkg-fso-commits mailing list