Skip to content

Commit 1007e4c

Browse files
committed
catch and retry OSError in example
1 parent 593a5a3 commit 1007e4c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

examples/lc709203f_simpletest.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313

1414
print("IC version:", hex(sensor.ic_version))
1515
while True:
16-
print(
17-
"Battery: %0.3f Volts / %0.1f %%" % (sensor.cell_voltage, sensor.cell_percent)
18-
)
16+
try:
17+
print(
18+
"Battery: %0.3f Volts / %0.1f %%"
19+
% (sensor.cell_voltage, sensor.cell_percent)
20+
)
21+
except OSError:
22+
print("retry reads")
23+
1924
time.sleep(1)

0 commit comments

Comments
 (0)