Skip to content

Commit 7385419

Browse files
authored
Merge pull request #35 from BiffoBear/add-timeout-to-op-mode_setter
Added timeout which raises an exception to avoid an infinite loop
2 parents f7027e9 + 5718b26 commit 7385419

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

adafruit_rfm69.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,10 @@ def operation_mode(self, val):
474474
op_mode |= val << 2
475475
self._write_u8(_REG_OP_MODE, op_mode)
476476
# Wait for mode to change by polling interrupt bit.
477+
start = time.monotonic()
477478
while not self.mode_ready:
478-
pass
479+
if (time.monotonic() - start) >= 1:
480+
raise TimeoutError("Operation Mode failed to set.")
479481

480482
@property
481483
def sync_word(self):

0 commit comments

Comments
 (0)