Hi -

I've been exercising some changes to the ownet python interface, and  
everything seems to be working great. The changes were made because  
the existing code had trouble working through a 1-wire hub or DS2409  
microlan switch. I've been running with these changes for almost a  
week with no issues. Here are the diffs from ownet-0.2 (__init__.py):

339c339
<                 yield entry.split('/')[2]
---
 >                 yield entry.split('/')[-1]
376c376
<                 list = filter(lambda x: '/' in x,  
self._connection.dir(self._usePath))
---
 >                 list = filter(lambda x: '/' in x,  
self._connection.dir(path))
378,379c378,381
<                     for branch_entry in list.split(','):
<                         branch_path = self._usePath + '/' + branch  
+ '/' + branch_entry.split('/')[0]
---
 >                     namelist = ','.join(list)
 >                     #print 'Sensor.sensors namelist(%s)' % str 
(namelist)
 >                     for branch_entry in namelist.split(','):
 >                         #print 'branch_entry(%s)' % str(branch_entry)
381c383
<                             self._connection.read(branch_path + '/ 
type')
---
 >                             self._connection.read(branch_entry + '/ 
type')
384c386
<                         yield Sensor(branch_path,  
connection=self._connection)
---
 >                         yield Sensor(branch_entry,  
connection=self._connection)
#

Comments on the changes:
Line 339 is changed to report the last field on the line. For  
networks traversing DS2409 couplers, [2] would return multiples of  
'main' or 'aux' instead of the attributes of the sensor on the  
branch. [-1] correctly returns the attributes no matter how many  
levels deep the sensor is. (Although I have not tested nested couplers.)

Line 376 is changed to use the correct path, which includes the name  
of the branch (Thanks Peter!)

Lines 378-381 are changed to perform a format conversion in such a  
way it can be conveniently split. A commented debug statement is  
added, and the assignment of a value to branch_path is removed since  
there are no references to it.

Lines 381 and 384 (new lines 383 and 386) are changed to use the  
branch entry, instead of the branch path.

With these changes I can successfully do things like:
 >>> import ownet
 >>> s=ownet.Sensor("/", server="127.0.0.1", port=3002)
 >>> sl=s.sensorList()
 >>> print sl[3].sensorList()[0].temperature
     -1.68056
 >>>

This is reporting temperature from a DS18S20 hanging off the main  
branch of a DS2409 coupler which is connected to a DS9490 (a bit cool  
here today :)

Perhaps you can independently test these changes, and include them in  
an upcoming release. My apologies if this is not the proper way to  
submit patches. Please let me know if this should be handled  
differently. You folks have done the heavy lifting, I'm just trying  
to help out as I can.

Best regards and a Happy New Year,
Ziggy

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to