Merge pull request #24 from tgikal/tgikal-SPI-read_passive_target-timeout
SPI read_passive_target timeout
This commit is contained in:
commit
b949e87e1a
1 changed files with 6 additions and 6 deletions
|
@ -81,14 +81,14 @@ class PN532_SPI(PN532):
|
|||
status = bytearray([reverse_bit(_SPI_STATREAD), 0])
|
||||
|
||||
timestamp = time.monotonic()
|
||||
while (time.monotonic() - timestamp) < timeout:
|
||||
with self._spi as spi:
|
||||
with self._spi as spi:
|
||||
while (time.monotonic() - timestamp) < timeout:
|
||||
time.sleep(0.02) # required
|
||||
spi.write_readinto(status, status) #pylint: disable=no-member
|
||||
if reverse_bit(status[1]) == 0x01: # LSB data is read in MSB
|
||||
return True # Not busy anymore!
|
||||
else:
|
||||
time.sleep(0.01) # pause a bit till we ask again
|
||||
if reverse_bit(status[1]) == 0x01: # LSB data is read in MSB
|
||||
return True # Not busy anymore!
|
||||
else:
|
||||
time.sleep(0.01) # pause a bit till we ask again
|
||||
# We timed out!
|
||||
return False
|
||||
|
||||
|
|
Loading…
Reference in a new issue