From ef772376e8ce71cdb01bc05c1fe280fa95b78735 Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Sun, 31 Jan 2021 09:17:33 +0700 Subject: [PATCH 1/4] Added timeout which raises an exception to avoid infinite loop in operation_mode setter --- adafruit_rfm69.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_rfm69.py b/adafruit_rfm69.py index b8ec63b..ce7f447 100644 --- a/adafruit_rfm69.py +++ b/adafruit_rfm69.py @@ -475,7 +475,8 @@ def operation_mode(self, val): self._write_u8(_REG_OP_MODE, op_mode) # Wait for mode to change by polling interrupt bit. while not self.mode_ready: - pass + if (time.monotonic() - start) >= 1: + raise RuntimeError('Operation mode failed to set.') @property def sync_word(self): From e8adaf828b80a84d296aba96527875608fb0b5a3 Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Sun, 31 Jan 2021 09:28:09 +0700 Subject: [PATCH 2/4] Added the start variable. --- adafruit_rfm69.py | 1 + 1 file changed, 1 insertion(+) diff --git a/adafruit_rfm69.py b/adafruit_rfm69.py index ce7f447..014d4ee 100644 --- a/adafruit_rfm69.py +++ b/adafruit_rfm69.py @@ -474,6 +474,7 @@ def operation_mode(self, val): op_mode |= val << 2 self._write_u8(_REG_OP_MODE, op_mode) # Wait for mode to change by polling interrupt bit. + start = time.monotonic() while not self.mode_ready: if (time.monotonic() - start) >= 1: raise RuntimeError('Operation mode failed to set.') From 26c867082024da674243fcc4a872a1da2e3f2e64 Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Sun, 31 Jan 2021 20:16:04 +0700 Subject: [PATCH 3/4] Changed to double quotes --- adafruit_rfm69.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_rfm69.py b/adafruit_rfm69.py index 014d4ee..5601c1d 100644 --- a/adafruit_rfm69.py +++ b/adafruit_rfm69.py @@ -477,7 +477,7 @@ def operation_mode(self, val): start = time.monotonic() while not self.mode_ready: if (time.monotonic() - start) >= 1: - raise RuntimeError('Operation mode failed to set.') + raise RuntimeError("Operation mode failed to set.") @property def sync_word(self): From 5718b26a7fa7d93ef19b4aebe6f59b7d35ded961 Mon Sep 17 00:00:00 2001 From: BiffoBear Date: Thu, 4 Feb 2021 05:52:10 +0700 Subject: [PATCH 4/4] Changed RuntimeError to TimeoutError. --- adafruit_rfm69.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_rfm69.py b/adafruit_rfm69.py index 5601c1d..9eeed7e 100644 --- a/adafruit_rfm69.py +++ b/adafruit_rfm69.py @@ -477,7 +477,7 @@ def operation_mode(self, val): start = time.monotonic() while not self.mode_ready: if (time.monotonic() - start) >= 1: - raise RuntimeError("Operation mode failed to set.") + raise TimeoutError("Operation Mode failed to set.") @property def sync_word(self):