From f7229e09ecc0da158d9b7c02f5ab13ad219c5edb Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 17 Dec 2020 11:46:47 -0500 Subject: [PATCH] Catching errors With no PMS sensor attached you cannot flip through the screens ( tapping the light sensor until you reach the PMS page will throw uncaught exception. Added exception to the three cases, in the same manner as the main page --- examples/combined.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/combined.py b/examples/combined.py index 6c4ab6f..556bcb0 100755 --- a/examples/combined.py +++ b/examples/combined.py @@ -275,7 +275,7 @@ def main(): unit = "ug/m3" try: data = pms5003.read() - except pmsReadTimeoutError: + except (SerialTimeoutError, pmsReadTimeoutError): logging.warning("Failed to read PMS5003") else: data = float(data.pm_ug_per_m3(1.0)) @@ -286,7 +286,7 @@ def main(): unit = "ug/m3" try: data = pms5003.read() - except pmsReadTimeoutError: + except (SerialTimeoutError, pmsReadTimeoutError): logging.warning("Failed to read PMS5003") else: data = float(data.pm_ug_per_m3(2.5)) @@ -297,7 +297,7 @@ def main(): unit = "ug/m3" try: data = pms5003.read() - except pmsReadTimeoutError: + except (SerialTimeoutError, pmsReadTimeoutError): logging.warning("Failed to read PMS5003") else: data = float(data.pm_ug_per_m3(10))