PN532_SPI._wait_ready: fixed command overwriting
Use separate buffer for sending and receiving form SPI This fixes #28
This commit is contained in:
parent
34c3dfcf76
commit
3da8e1652c
1 changed files with 4 additions and 4 deletions
|
@ -78,14 +78,14 @@ class PN532_SPI(PN532):
|
||||||
|
|
||||||
def _wait_ready(self, timeout=1):
|
def _wait_ready(self, timeout=1):
|
||||||
"""Poll PN532 if status byte is ready, up to `timeout` seconds"""
|
"""Poll PN532 if status byte is ready, up to `timeout` seconds"""
|
||||||
status = bytearray([reverse_bit(_SPI_STATREAD), 0])
|
status_cmd = bytearray([reverse_bit(_SPI_STATREAD), 0x00])
|
||||||
|
status_response = bytearray([0x00, 0x00])
|
||||||
timestamp = time.monotonic()
|
timestamp = time.monotonic()
|
||||||
with self._spi as spi:
|
with self._spi as spi:
|
||||||
while (time.monotonic() - timestamp) < timeout:
|
while (time.monotonic() - timestamp) < timeout:
|
||||||
time.sleep(0.02) # required
|
time.sleep(0.02) # required
|
||||||
spi.write_readinto(status, status) #pylint: disable=no-member
|
spi.write_readinto(status_cmd, status_response) #pylint: disable=no-member
|
||||||
if reverse_bit(status[1]) == 0x01: # LSB data is read in MSB
|
if reverse_bit(status_response[1]) == 0x01: # LSB data is read in MSB
|
||||||
return True # Not busy anymore!
|
return True # Not busy anymore!
|
||||||
else:
|
else:
|
||||||
time.sleep(0.01) # pause a bit till we ask again
|
time.sleep(0.01) # pause a bit till we ask again
|
||||||
|
|
Loading…
Reference in a new issue