miguelbalboa / rfid

Arduino RFID Library for MFRC522
The Unlicense
2.73k stars 1.42k forks source link

How to get 5 bytes UID ? #604

Closed msw1998 closed 11 months ago

msw1998 commented 11 months ago

I want to get 5th byte output from MIFARE Classic Card instead of 4 bytes output. Currently I am getting this UID from arduino code 8B 65 66 B9 but from the raspberry pi code of SimpleMFRC522.py I get this uid in hex 8B 65 66 B9 31

I can't update the raspberry pi code to change the output from 5 byte to 4 byte as it is already in production Is there anyway I can get the 5th byte from this library?

Rotzbua commented 11 months ago

Block 0 contains the raw data for uid.

msw1998 commented 11 months ago

How can I print the raw data for the uid?

I did run the dumpinfo and it only gives me 4 bytes as mentioned above i tried increase uid->size to 5 and increase the bytesToCopy variable to 5 as well then it outputted the 5th byte as 00

toobaz commented 6 months ago

The fifth byte is just a checksum. For instance, in your case:

In [1]: hex(int("8B", 16)^int("65", 16)^int("66", 16)^int("B9", 16))[2:]
Out[1]: '31'

Also see this stackexchange answer