Skip to content

Commit 9b42c74

Browse files
authored
Merge pull request #29 from basil-huber/spi_buffer_fix
PN532_SPI._wait_ready: fixed command overwriting
2 parents 34c3dfc + 3da8e16 commit 9b42c74

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

adafruit_pn532/spi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ def _wakeup(self):
7878

7979
def _wait_ready(self, timeout=1):
8080
"""Poll PN532 if status byte is ready, up to `timeout` seconds"""
81-
status = bytearray([reverse_bit(_SPI_STATREAD), 0])
82-
81+
status_cmd = bytearray([reverse_bit(_SPI_STATREAD), 0x00])
82+
status_response = bytearray([0x00, 0x00])
8383
timestamp = time.monotonic()
8484
with self._spi as spi:
8585
while (time.monotonic() - timestamp) < timeout:
8686
time.sleep(0.02) # required
87-
spi.write_readinto(status, status) #pylint: disable=no-member
88-
if reverse_bit(status[1]) == 0x01: # LSB data is read in MSB
87+
spi.write_readinto(status_cmd, status_response) #pylint: disable=no-member
88+
if reverse_bit(status_response[1]) == 0x01: # LSB data is read in MSB
8989
return True # Not busy anymore!
9090
else:
9191
time.sleep(0.01) # pause a bit till we ask again

0 commit comments

Comments
 (0)