Merge pull request #114 from bradbishop/openbmc-1.0
dbus.Double and revert sensor cache
diff --git a/pyhwmon/hwmon.py b/pyhwmon/hwmon.py
index e7821f4..e5dc19a 100644
--- a/pyhwmon/hwmon.py
+++ b/pyhwmon/hwmon.py
@@ -39,7 +39,6 @@
self.hwmon_root = { }
self.scanDirectory()
gobject.timeout_add(DIR_POLL_INTERVAL, self.scanDirectory)
- self.cache = {}
def readAttribute(self,filename):
val = "-1"
@@ -55,30 +54,17 @@
with open(filename, 'w') as f:
f.write(str(value)+'\n')
- def should_update(self, attribute, value):
- if attribute not in self.cache:
- self.cache[attribute] = value
- return True
-
- update = (value != self.cache[attribute])
- self.cache[attribute] = value
-
- return update
def poll(self,objpath,attribute):
try:
raw_value = int(self.readAttribute(attribute))
- if self.should_update(attribute, raw_value):
- obj = bus.get_object(SENSOR_BUS,objpath,introspect=False)
- intf = dbus.Interface(obj,HwmonSensor.IFACE_NAME)
- rtn = intf.setByPoll(raw_value)
- if (rtn[0] == True):
- self.writeAttribute(attribute,rtn[1])
+ obj = bus.get_object(SENSOR_BUS,objpath,introspect=False)
+ intf = dbus.Interface(obj,HwmonSensor.IFACE_NAME)
+ rtn = intf.setByPoll(raw_value)
+ if (rtn[0] == True):
+ self.writeAttribute(attribute,rtn[1])
except:
print "HWMON: Attibute no longer exists: "+attribute
- self.sensors.pop(objpath,None)
- if attribute in self.cache:
- del self.cache[attribute]
return False
diff --git a/pytools/obmcutil b/pytools/obmcutil
index 6db589e..9207eca 100644
--- a/pytools/obmcutil
+++ b/pytools/obmcutil
@@ -16,6 +16,9 @@
elif (isinstance(it,dbus.Byte)):
if (key != None):
parent[key] = int(it)
+ elif (isinstance(it,dbus.Double)):
+ if (key != None):
+ parent[key] = float(it)
else:
pass