diff py/sensor_ds18b20.py @ 178:77c2a9caca3d

a few fixes
author Matt Johnston <matt@ucc.asn.au>
date Thu, 30 Jan 2014 22:55:27 +0800
parents 33ed66a7ea0b
children 16a83e2c97a0
line wrap: on
line diff
--- a/py/sensor_ds18b20.py	Thu Jul 25 08:05:40 2013 +0800
+++ b/py/sensor_ds18b20.py	Thu Jan 30 22:55:27 2014 +0800
@@ -77,7 +77,11 @@
     def sensor_names(self):
         """ Returns a sequence of sensorname """
         slaves_path = os.path.join(self.master_dir, "w1_master_slaves")
-        names = open(slaves_path, 'r').read().split()
+        contents = open(slaves_path, 'r').read()
+        if 'not found' in contents:
+            E("No W1 sensors found")
+            return []
+        names = contents.split()
         return names
 
     def wort_name(self):