Open Himura2la opened 7 years ago
This is my version. We don't need a timeout variable, if the TimerIRq is set, we can be sure everything is lost and won't work. In my UART version it takes 5 iterations on 9600 baud to have TimerIRq set.
while True:
n = self.dev_read(0x04)
if n == 0:
continue # Too fast
if n & irq_wait:
break # Got it!
if n & 0x01:
error = True
break # The timer decrements the timer value in register TCounterValReg to zero
You should also change following condition to if not error:
and delete its else
branch
https://github.com/ondryaso/pi-rc522/blob/master/pirc522/__init__.py#L127
This mistake was copy-pasted, I filed an issue to the original repo. Sad.