Skip to content

Commit b05a907

Browse files
Now issues warnings when theres non EZO devices present on the I2C line, instead of erroring out
1 parent e983aec commit b05a907

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

i2c.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ def get_devices():
2626
for i in device_address_list:
2727
device.set_i2c_address(i)
2828
response = device.query("I")
29-
moduletype = response.split(",")[1]
30-
response = device.query("name,?").split(",")[1]
29+
try:
30+
moduletype = response.split(",")[1]
31+
response = device.query("name,?").split(",")[1]
32+
except IndexError:
33+
print(">> WARNING: device at I2C address " + str(i) + " has not been identified as an EZO device, and will not be queried")
34+
continue
3135
device_list.append(AtlasI2C(address = i, moduletype = moduletype, name = response))
3236
return device_list
3337

@@ -56,12 +60,12 @@ def print_help_text():
5660

5761
def main():
5862

63+
print_help_text()
64+
5965
device_list = get_devices()
6066

6167
device = device_list[0]
6268

63-
print_help_text()
64-
6569
print_devices(device_list, device)
6670

6771
real_raw_input = vars(__builtins__).get('raw_input', input)

0 commit comments

Comments
 (0)