ondryaso / pi-rc522

Raspberry Pi Python library for SPI RFID RC522 module
MIT License
412 stars 150 forks source link

rdr.request() fails one time in two #10

Open PierreRust opened 8 years ago

PierreRust commented 8 years ago

When polling the state while a while loop (like in the example) the rdr.request() fails one time in two if the tag is always kept close to the reader.

More precisely : when I place my tag on the reader and leave it there I would expect rdr.request() to return True at each iteration of the loop, but instead it returns a sequence like this :

(True, data) 
(False, None)
(True, data)
(False, None)
...

This behavior make it more complicated to detect a tag removal.

varac commented 7 years ago

Same issue here, what's wrong ? Any workaround ?

varac commented 7 years ago

I tried with the original mxgxw/MFRC522-python class and the issue is the same :o

varac commented 7 years ago

Well the workaround I found was this: On successful reading a tag, I call rdr.request() a second time without processing it's results. Not nice, but it works for me until this gets fixed.

davyhollevoet commented 7 years ago

I was experiencing the same thing with the lua port.

Curiously, two subsequent .request() calls do work correctly when you replace the tag with an other between the calls. So it doesn't seem that the library gets stuck in an inconsistent state or something like that; rather that the tag is not responding correctly when it is left on the reader.

This observation made me try calling halt() after reading the serial. This makes it work, but I'm not sure if it is the right thing to do. The example in the lua port does seem to imply that calling halt is not necessary when you're not selecting a tag.