Hi Marcus, With each eMail I gain a bit more understanding! And yes, I am enjoying learning Python:)
I have played with it directly in a terminal and yes I understand now what is happening and it works fine. However my test script seems to be running too fast, so I suspect that it is still caching. Could you have a look at my code and see if I have the use_cache(0) statement in the right place. One further question, with this code I can now unplug a sensor while the code is running, it shows that it is unplugged (present = 0) and if I plug it in again it sees it and displays the values again. My problem now is that I would like it to recover like that even if the sensor is missing when the code starts to run. Currently it starts up OK and shows that the sensor is missing, but if I connect it it is still not recognised. Is there a way to achieve this? Thanks Mick #!/usr/bin/python # file sen_object2.py from pyowfs import Connection import sys, time """ these are my test sensors Family = 10 id = 2054A9010800 Powered = 0 Present = 1 Family = 10 Address = 102054A901080020 Type = DS18S20 Temperature = 23.625 Family = 10 id = 522FA9010800 Powered = 0 Present = 1 Family = 10 Address = 10522FA9010800CB Type = DS18S20 Temperature = 24.625 Family = 28 id = C0617A020000 Powered = 0 Present = 1 Family = 28 Address = 28C0617A020000A1 Type = DS18B20 Temperature = 28.375 Family = 28 id = F26D7A020000 Powered = 0 Present = 1 Family = 28 Address = 28F26D7A02000003 Type = DS18B20 Temperature = 25.0625 """ connection = Connection ("/dev/ttyD0") class SenObject: """Sensor object - """ def __init__(self, a = None, b = None, c = None): self.id = a self.code = b self.description = c try: self.sensor = connection.find (id = self.id)[0] self.sensor.use_cache(0) except IndexError: print 'Index Error in __init__' def temp(self): t = -9.99 try: t = self.sensor.get ("temperature") except (AttributeError, KeyError): print 'AttributeError or KeyError' return t def family(self): pass def present(self): p = 0 try: p = self.sensor.get ("present") except (AttributeError, KeyError): print 'AttributeError or KeyError' return p def powered(self): pass # end of sens_object w = SenObject('F26D7A020000', 'wCode', 'this is wcode') x = SenObject('522FA9010800', 'xCode', 'this is xcode') y = SenObject('2054A9010800', 'yCode', 'this is ycode') z = SenObject('C0617A020000', 'zCode', 'this is zcode') loop = 1 while loop > 0: for s in [w, x, y, z]: if s.present() == 0: print '#################### not present ###############= ', s.present() else: print 'present = ', s.present() print 'id = ', s.id print 'temp = ', s.temp() print 'code = ', s.code print 'description = ', s.description print '####### Loop count is ####### ', loop loop += 1 time.sleep(0.1) ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Owfs-developers mailing list Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers