Hi,

The following hack seems to solve the problem. Change:
@@ -232,7 +232,10 @@
         val          = struct.unpack('iiiiii', msg)
         version      = socket.ntohl(val[0])
         payload_len  = socket.ntohl(val[1])
-        ret_value    = socket.ntohl(val[2])
+        try:
+            ret_value    = socket.ntohl(val[2])
+        except OverflowError:
+            ret_value = 0

The attached patch fixes this issue.

Also, I have attached a patch, which fixes indenting in the ow Python
module.



m...@gmx.de пишет:
> Hi,
> 
> I get an exception if I try to connect to the owserver with ownet.
> 
> # lsb_release -d
> Description:  Ubuntu 10.04.1 LTS
> 
> # uname -a
> Linux mknx 2.6.32-24-server #41-Ubuntu SMP Thu Aug 19 02:47:08 UTC 2010 
> x86_64 GNU/Linux
> 
> # python -V
> Python 2.6.5
> 
> # /opt/owfs/bin/owserver -V
> /opt/owfs/bin/owserver version:
>       2.8p2
> libow version:
>       2.8p2
> 
> # cat owtest.py 
> #! /usr/bin/env python
> 
> import ownet
> ownet.Sensor('/', '127.0.0.1', 4304)
> 
> # ./owtest.py 
> Sensor.useCache(True)
> Connection.unpack("????")
> Traceback (most recent call last):
>   File "./owtest.py", line 6, in <module>
>     ownet.Sensor('/', '127.0.0.1', 4304)
>   File "/usr/lib/python2.6/dist-packages/ownet/__init__.py", line 169, in 
> __init__
>     self.useCache(self._useCache)
>   File "/usr/lib/python2.6/dist-packages/ownet/__init__.py", line 321, in 
> useCache
>     self._type    = self._connection.read('/system/adapter/name.0')
>   File "/usr/lib/python2.6/dist-packages/ownet/connection.py", line 138, in 
> read
>     ret, payload_len, data_len = self.unpack(data)
>   File "/usr/lib/python2.6/dist-packages/ownet/connection.py", line 235, in 
> unpack
>     ret_value    = socket.ntohl(val[2])
> OverflowError: can't convert negative number to unsigned long
> 
> I've uncommented the "Connection.unpack("????")" output to see the msg.
> Is it a regular reply from the server?
> Any hints? I've tried it with i386 as well, same problem.
> 
> so long
> 
> Marcus
> 
> 
> 
diff -Nur -x '*.orig' -x '*~' owfs-2.8p2/module/ownet/python/ownet/connection.py owfs-2.8p2.new/module/ownet/python/ownet/connection.py
--- owfs-2.8p2/module/ownet/python/ownet/connection.py	2009-04-13 05:17:09.000000000 +0400
+++ owfs-2.8p2.new/module/ownet/python/ownet/connection.py	2010-09-12 06:00:17.000000000 +0400
@@ -232,7 +232,10 @@
         val          = struct.unpack('iiiiii', msg)
         version      = socket.ntohl(val[0])
         payload_len  = socket.ntohl(val[1])
-        ret_value    = socket.ntohl(val[2])
+        try:
+            ret_value    = socket.ntohl(val[2])
+        except OverflowError:
+            ret_value = 0
         format_flags = socket.ntohl(val[3])
         data_len     = socket.ntohl(val[4])
         offset       = socket.ntohl(val[5])
diff -Nur -x '*.orig' -x '*~' owfs-2.8p2/module/ownet/python/ownet/__init__.py owfs-2.8p2.new/module/ownet/python/ownet/__init__.py
--- owfs-2.8p2/module/ownet/python/ownet/__init__.py	2006-12-30 05:42:44.000000000 +0300
+++ owfs-2.8p2.new/module/ownet/python/ownet/__init__.py	2010-09-12 06:07:38.000000000 +0400
@@ -247,10 +247,10 @@
         and thr PIO.0 might be 1.
         """
 
-        if name in self._attrs:
+        try:
             #print 'Sensor.__getattr__(%s)' % name
-            attr = self._connection.read(self._attrs[name])
-        else:
+            attr = object._connection.read(object.__getattribute__(self, '_attrs')[name])
+        except KeyError:
             raise AttributeError, name
 
         return attr
diff -Nur -x '*.orig' -x '*~' owfs-2.8p2/module/swig/python/ow/__init__.py owfs-2.8p2.new/module/swig/python/ow/__init__.py
--- owfs-2.8p2/module/swig/python/ow/__init__.py	2010-08-24 14:02:58.000000000 +0400
+++ owfs-2.8p2.new/module/swig/python/ow/__init__.py	2010-09-04 18:41:52.000000000 +0400
@@ -344,8 +344,8 @@
         """
         #print 'Sensor.__getattr__', name
         try:
-		    return owfs_get(object.__getattribute__(self, '_attrs')[name])
-		except KeyError:
+            return owfs_get(object.__getattribute__(self, '_attrs')[name])
+        except KeyError:
             raise AttributeError, name
 
 
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to