From 2fdb1543460438ecf3709dce6257ff60c1a1c6aa Mon Sep 17 00:00:00 2001 From: Daniel Tan Date: Tue, 26 Jun 2018 08:01:55 +0800 Subject: [PATCH] Revert https://github.com/miguelbalboa/rfid/commit/764cb6c25101947ad02ece3b1200d4f7a52dfe98 and https://github.com/miguelbalboa/rfid/commit/767408134cd35aca89e4b926b213bac664fa2b88. Fix https://github.com/miguelbalboa/rfid/issues/394 --- src/MFRC522.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/MFRC522.cpp b/src/MFRC522.cpp index b9b34d5..4f6c7ea 100644 --- a/src/MFRC522.cpp +++ b/src/MFRC522.cpp @@ -593,6 +593,7 @@ MFRC522::StatusCode MFRC522::PICC_Select( Uid *uid, ///< Pointer to Uid struct byte cascadeLevel = 1; MFRC522::StatusCode result; byte count; + byte checkBit; byte index; byte uidIndex; // The first index in uid->uidByte[] that is used in the current Cascade Level. int8_t currentLevelKnownBits; // The number of known UID bits in the current Cascade Level. @@ -737,10 +738,11 @@ MFRC522::StatusCode MFRC522::PICC_Select( Uid *uid, ///< Pointer to Uid struct return STATUS_INTERNAL_ERROR; } // Choose the PICC with the bit set. - count = (collisionPos - 1) % 8; // The bit to modify - index = 1 + ((collisionPos - 1) / 8) + (count ? 1 : 0); // First byte is index 0. - buffer[index] |= (1 << count); - //currentLevelKnownBits = collisionPos; // FIXME not used further, maybe bug + currentLevelKnownBits = collisionPos; + count = currentLevelKnownBits % 8; // The bit to modify + checkBit = (currentLevelKnownBits - 1) % 8; + index = 1 + (currentLevelKnownBits / 8) + (count ? 1 : 0); // First byte is index 0. + buffer[index] |= (1 << checkBit); } else if (result != STATUS_OK) { return result;