[PATCH skeleton] Fix the sensor scandirectory recovery bug when poll or readattribute fail

OpenBMC Patches openbmc-patches at stwcx.xyz
Wed Jun 8 17:01:23 AEST 2016


From: Ken <ken.sk.lai at mail.foxconn.com>

---
 bin/hwmon.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bin/hwmon.py b/bin/hwmon.py
index 1209d46..19a2309 100755
--- a/bin/hwmon.py
+++ b/bin/hwmon.py
@@ -47,10 +47,13 @@ class Hwmons():
 		self.cache = {}
 
 	def readAttribute(self,filename):
-		val = ""
+		val = "-1"
+		try:
 		with open(filename, 'r') as f:
 			for line in f:
 				val = line.rstrip('\n')
+		except (OSError, IOError):
+		print "Cannot read attributes:", filename
 		return val
 
 	def writeAttribute(self,filename,value):
@@ -78,6 +81,7 @@ class Hwmons():
 					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
-- 
2.8.3




More information about the openbmc mailing list