diff --git a/src/MFRC522.cpp b/src/MFRC522.cpp index 4287a2b..fc6edf9 100644 --- a/src/MFRC522.cpp +++ b/src/MFRC522.cpp @@ -736,10 +736,10 @@ MFRC522::StatusCode MFRC522::PICC_Select( Uid *uid, ///< Pointer to Uid struct return STATUS_INTERNAL_ERROR; } // Choose the PICC with the bit set. - currentLevelKnownBits = collisionPos; - count = (currentLevelKnownBits - 1) % 8; // The bit to modify - index = 1 + (currentLevelKnownBits / 8) + (count ? 1 : 0); // First byte is index 0. + 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; } else if (result != STATUS_OK) { return result;