-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Describe the bug
When reading the UID of a tag with a 4-byte UID ReadUID() returns 5 bytes.
To Reproduce
Steps to reproduce the behavior:
- Call
ReadUID()and scan an NFC tag with a 4-byte UID. - 5 bytes will be returned. Comparing to the tag's known UID, the fifth byte appears to be extraneous.
Expected behavior
4 bytes should be returned.
Platform (please complete the following information):
- OS: Raspbian 10.9
- Board: Gen 1 Raspberry Pi Model B
- Device: MFRC522
Additional context
The problem appears to be here: https://github.com/periph/devices/blob/47f3fec45df8376070823f45f7624567267335a8/mfrc522/mfrc522.go#L404-414
Both antiColl() and antColll2() check the crc byte but then also return it. In the case of a 4-byte UID selectCard() then returns the whole slice including the CRC, oops.
I think in the case of a 7-byte NUID it will also be wrong, the code correctly strips byte 0 (0x88), then leaves the crc from antiColl(), then strips the crc from antiColl2(), meaning it will return 8-bytes but byte 4 will be extraneous.