[pkg-fso-commits] [SCM] framworkd debian packageing branch, master, updated. milestone2-89-geb27523
Daniel Willmann
daniel at totalueberwachung.de
Sat Aug 23 14:06:17 UTC 2008
The following commit has been merged in the master branch:
commit 8da0bf0545147028f363e46c59d6c70c9cfba398
Author: Alon <alonlevy1 in g mail>
Date: Thu Aug 14 14:10:46 2008 +0200
ogpsd: Apply gpschannel_add_udpchannel_ane_filechannel.patch
This is a good step forward in the quest to support GTA01 (gllin)
diff --git a/framework/subsystems/ogpsd/gpschannel.py b/framework/subsystems/ogpsd/gpschannel.py
index 209ae81..a039848 100644
--- a/framework/subsystems/ogpsd/gpschannel.py
+++ b/framework/subsystems/ogpsd/gpschannel.py
@@ -13,8 +13,12 @@ GPLv2 or later
import os
import sys
import serial
+import socket
import gobject
+import logging
+logger = logging.getLogger('ogpsd')
+
class GPSChannel( object ):
"""A GPS Channel :-)"""
def __init__( self ):
@@ -23,6 +27,57 @@ class GPSChannel( object ):
def setCallback( self, callback ):
self.callback = callback
+class UDPChannel ( GPSChannel ):
+ """UDP reader, for gta01, gllin"""
+
+ 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))
+ self.s.setblocking(False)
+ gobject.io_add_watch( self.s.makefile(), gobject.IO_IN, self.readyToRead )
+
+ def readyToRead( self, source, condition ):
+ data = self.s.recv(1024)
+ if self.callback:
+ self.callback(data)
+
+ return True
+
+ def readyToSend( self, source, condition ):
+ return False
+
+class FileChannel ( GPSChannel ):
+ """File reader, for gta01, gllin"""
+
+ def __init__(self, path):
+ super(FileChannel, self).__init__()
+ logger.debug("FileChannel opens %s" % path)
+ self.fd = os.open(path, os.O_NONBLOCK + os.O_RDONLY)
+ gobject.io_add_watch( self.fd, gobject.IO_IN, self.readyToRead )
+
+ def readyToRead( self, source, condition ):
+ data_array = []
+ try:
+ while True:
+ data_array.append(os.read(self.fd, 1024))
+ except OSError:
+ pass
+ if len(data_array) == 1:
+ data = data_array[0] # shortcut for common case
+ else:
+ data = ''.join(data_array)
+ if self.callback:
+ self.callback(data)
+
+ return True
+
+ def readyToSend( self, source, condition ):
+ return False
+
+
class SerialChannel( GPSChannel ):
"""Serial reader"""
--
framworkd debian packageing
More information about the pkg-fso-commits
mailing list