Skip to content

Commit 61e3863

Browse files
authored
Merge pull request #132 from mikejc58/wait_spi_char
change timeout to retry count in _wait_spi_char
2 parents 8771564 + 907de10 commit 61e3863

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,14 @@ def _read_bytes(self, spi, buffer, start=0, end=None):
260260
print("\t\tRead:", [hex(i) for i in buffer])
261261

262262
def _wait_spi_char(self, spi, desired):
263-
"""Read a byte with a time-out, and if we get it, check that its what we expect"""
264-
times = time.monotonic()
265-
while (time.monotonic() - times) < 0.1:
263+
"""Read a byte with a retry loop, and if we get it, check that its what we expect"""
264+
for _ in range(10):
266265
r = self._read_byte(spi)
267266
if r == _ERR_CMD:
268267
raise RuntimeError("Error response to command")
269268
if r == desired:
270269
return True
270+
time.sleep(0.01)
271271
raise RuntimeError("Timed out waiting for SPI char")
272272

273273
def _check_data(self, spi, desired):

0 commit comments

Comments
 (0)