I had the same problem, and got that answer:
Yes. There is a simple fix for this in the connection.py file which =20
is part of the module. It should be in your site-python directory tree.
Here's a diff:
# diff connection.py connection.py.org
57c57
< interact with the ow sensors on any platform supported by Python.
---
> inteact with the ow sensors on any platform supported by Python.
96c96
<
---
>
114c114
< if payload_len >=3D 0:
---
> if payload_len:
119d118
< # ping response
168c167
< if payload_len > 0:
---
> if payload_len:
172d170
< # end of dir list or 'ping' response
The payload_length was not being checked for the case where a 'ping' =20
response is given back to the client.
Sooner or later you may also receive a "struct.error: unpack str size
=20=
does not match format". If you do encounter it, let me know, and =20
I'll post that patch as well. I would post a complete diff, but I =20
don''t feel all the changes are quite ready.
Paul
On 27.06.2007, at 21:41, Doug Collinge wrote:
I'm having a problem using the python interface in ownet (from CVS)
for reading a few DS18S20 thermometers. A very basic program
(shown below) finds all sensors with a "temperature" attribute and
then polls them continuously until the crash occurs. Sometimes
this takes minutes, sometimes hours, sometimes all day. The error
output is:
Traceback (most recent call last):
File "showbug.py", line 21, in <module>
thaddr = therm.address
File "/usr/lib/python2.5/site-packages/ownet/__init__.py", line
252, in __getattr__
attr = self._connection.read(self._attrs[name])
File "/usr/lib/python2.5/site-packages/ownet/connection.py", line
139, in read
data = s.recv(payload_len)
ValueError: negative buffersize in recv
which really seems like a code problem in connection.py, probably
resulting from some kind of error condition on the bus, given that
it's so sporadic. A similar monitoring program based on bash and
owfs does not seem to suffer from this problem so I'm guessing that
it's just a bug in ownet/python.
Not sure how to proceed from here - I'm not going to be able to use
Python if this can't be fixed.
=================================================
Relevant hunk of monitoring program...
r = ownet.Sensor('/uncached', server=sys.argv[1], port=int(sys.argv
[2]))
r.useCache(False)
therms = [sensor for sensor in r.sensors() if any(att ==
'temperature' for att in sensor.entries ()) ]
tempflakes = 0
for i in range(10000000):
r._connection.write('/simultaneous/temperature',1)
print i,tempflakes,
for therm in therms :
thaddr = therm.address
thtemp = therm.temperature
if thtemp :
print '%s: %7.3f ' % (thaddr, thtemp),
else :
tempflakes += 1
print ''
============================================
Output with crash after only a few minutes:
... many lines of output ...
209 0 1060412F00080080: 20.562 10D44A2F0008002B: 20.438
109B512F00080076: 20.375 108F522F000800BF: 20.625
210 0 1060412F00080080: 20.562 10D44A2F0008002B: 20.500
109B512F00080076: 20.375 108F522F000800BF: 20.625
211 0
Traceback (most recent call last):
File "showbug.py", line 21, in <module>
thtemp = therm.temperature
File "/usr/lib/python2.5/site-packages/ownet/__init__.py", line
252, in __getattr__
attr = self._connection.read(self._attrs[name])
File "/usr/lib/python2.5/site-packages/ownet/connection.py", line
139, in read
data = s.recv(payload_len)
ValueError: negative buffersize in recv
----------------------------------------------------------------------
--------------------------------
Output with crash after a few more minutes:
... many lines of output ...
318 0 1060412F00080080: 21.438 10D44A2F0008002B: 21.312
109B512F00080076: 21.500 108F522F000800BF: 21.500
319 0 1060412F00080080: 21.438 10D44A2F0008002B: 21.375
109B512F00080076: 21.562 108F522F000800BF: 21.562
320 0 1060412F00080080: 21.438 10D44A2F0008002B: 21.375
109B512F00080076: 21.562 108F522F000800BF: 21.500
321 0
Traceback (most recent call last):
File "showbug.py", line 21, in <module>
thaddr = therm.address
File "/usr/lib/python2.5/site-packages/ownet/__init__.py", line
252, in __getattr__
attr = self._connection.read(self._attrs[name])
File "/usr/lib/python2.5/site-packages/ownet/connection.py", line
139, in read
data = s.recv(payload_len)
ValueError: negative buffersize in recv
----------------------------------------------------------------------
------------------------------
... nearly 40-thousand lines of output ...
39562 0 0 1060412F00080080: 20.438 10D44A2F0008002B: 20.375
109B512F00080076: 20.312 108F522F000800BF: 20.625
39563 0 0 1060412F00080080: 20.438 10D44A2F0008002B: 20.375
109B512F00080076: 20.312 108F522F000800BF: 20.625
39564 0 0 1060412F00080080: 20.438 10D44A2F0008002B: 20.375
109B512F00080076: 20.312 108F522F000800BF: 20.562
39565 0 0 1060412F00080080: 20.375
Traceback (most recent call last):
File "showbug.py", line 21, in <module>
thaddr = therm.address
File "/usr/lib/python2.5/site-packages/ownet/__init__.py", line
252, in __getattr__
attr = self._connection.read(self._attrs[name])
File "/usr/lib/python2.5/site-packages/ownet/connection.py", line
139, in read
data = s.recv(payload_len)
ValueError: negative buffersize in recv
----------------------------------------------------------------------
---
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers