Daniel Tan
2018-06-26 08:01:55 +08:00
committed by GitHub
parent c8b922c8a4
commit 2fdb154346

View File

@@ -593,6 +593,7 @@ MFRC522::StatusCode MFRC522::PICC_Select( Uid *uid, ///< Pointer to Uid struct
byte cascadeLevel = 1; byte cascadeLevel = 1;
MFRC522::StatusCode result; MFRC522::StatusCode result;
byte count; byte count;
byte checkBit;
byte index; byte index;
byte uidIndex; // The first index in uid->uidByte[] that is used in the current Cascade Level. 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. 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; return STATUS_INTERNAL_ERROR;
} }
// Choose the PICC with the bit set. // Choose the PICC with the bit set.
count = (collisionPos - 1) % 8; // The bit to modify currentLevelKnownBits = collisionPos;
index = 1 + ((collisionPos - 1) / 8) + (count ? 1 : 0); // First byte is index 0. count = currentLevelKnownBits % 8; // The bit to modify
buffer[index] |= (1 << count); checkBit = (currentLevelKnownBits - 1) % 8;
//currentLevelKnownBits = collisionPos; // FIXME not used further, maybe bug index = 1 + (currentLevelKnownBits / 8) + (count ? 1 : 0); // First byte is index 0.
buffer[index] |= (1 << checkBit);
} }
else if (result != STATUS_OK) { else if (result != STATUS_OK) {
return result; return result;