I have a problem with the MFRC522 library. It seems to me that after the tag was read / written one time correctly, in the next cycle the library always returns 2 on the check whether a card is present or not, meaning it skips one cycle every time.
The "request" function seems to give controll to the "tocard" function which does strange magic like
if ~((i != 0) and ~(n & 0x01) and ~(n & waitIRq)): where it just seems to check registers but it is too hard to understand from only the library.
This is a HUGE problem for me, since I want the reader to poll, like a video game engine does when you hold a button pressed. To be specific, I want to recognise wheter a card that is present was already present in the last reading cycle, and so forth, meaning a user that just held the card onto the device would not create much dump data and senseless database entries, also what's the point in calculating a delta between timestamps when you are not even sure if your stamp was saved or just deleted lol.
I tried something like this:
# Scan for cards (status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL) # If a card is found if status == MIFAREReader.MI_OK and same_card == False: # MI_OK == status code 0 print "Card detected" elif status == MIFAREReader.MI_ERR: # MI_ERR == status code 2 print "debug: no card present" same_card = False else: print "same card detected"
[Setting same_card to true after writing data successfully, of course]
For some reason I do not understand, the second reading cycle after I wrote data onto the card (or deleted it after getting my delta, this would be second time we enter work cycle) always returns status code 2 (MI.err)
This can't be possible because I'm still here holding that card against the reader (even if I slept for about 5 seconds, no difference)
The only other call at the end of the working cycle would be to
def MFRC522_StopCrypto1(self): self.ClearBitMask(self.Status2Reg, 0x08)
but this will hardly cause this behaviour, right?
Does anybody have a working example of a script that is blocking if the card is held against the reader constantly? No cheating allowed (sleeping f.e.). Bonus points if you can provide something using interrupts....