Updated wipe.py
This commit is contained in:
20
wipe.py
20
wipe.py
@@ -18,7 +18,7 @@ def uid_to_num(uid):
|
|||||||
n = n * 256 + uid[i]
|
n = n * 256 + uid[i]
|
||||||
return n
|
return n
|
||||||
|
|
||||||
MIFAREReader = MFRC522.MFRC522()
|
RFID = MFRC522.MFRC522()
|
||||||
|
|
||||||
print "Waiting for tag...\n"
|
print "Waiting for tag...\n"
|
||||||
|
|
||||||
@@ -28,9 +28,9 @@ while True:
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
(status, TagSize) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
|
(status, TagSize) = RFID.Request(RFID.PICC_REQIDL)
|
||||||
|
|
||||||
if status != MIFAREReader.MI_OK:
|
if status != RFID.MI_OK:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if sector >= TagSize:
|
if sector >= TagSize:
|
||||||
@@ -43,24 +43,24 @@ while True:
|
|||||||
TrailerBlockAddr = (sector * 4 + 3)
|
TrailerBlockAddr = (sector * 4 + 3)
|
||||||
|
|
||||||
# Writing data
|
# Writing data
|
||||||
(status, UID) = MIFAREReader.MFRC522_Anticoll()
|
(status, UID) = RFID.Anticoll()
|
||||||
|
|
||||||
if status != MIFAREReader.MI_OK:
|
if status != RFID.MI_OK:
|
||||||
break
|
break
|
||||||
|
|
||||||
MIFAREReader.MFRC522_SelectTag(UID)
|
RFID.SelectTag(UID)
|
||||||
status = MIFAREReader.MFRC522_Auth(MIFAREReader.PICC_AUTHENT1A, TrailerBlockAddr, KEY, UID)
|
status = RFID.Auth(RFID.PICC_AUTHENT1A, TrailerBlockAddr, KEY, UID)
|
||||||
if status == MIFAREReader.MI_OK:
|
if status == RFID.MI_OK:
|
||||||
data = bytearray()
|
data = bytearray()
|
||||||
data.extend(bytearray("".ljust(len(BlockAddrs) * 16)))
|
data.extend(bytearray("".ljust(len(BlockAddrs) * 16)))
|
||||||
i = 0
|
i = 0
|
||||||
for block_num in BlockAddrs:
|
for block_num in BlockAddrs:
|
||||||
MIFAREReader.MFRC522_Write(block_num, data[(i*16):(i+1)*16])
|
RFID.Write(block_num, data[(i*16):(i+1)*16])
|
||||||
i += 1
|
i += 1
|
||||||
print "Sector", sector, "wiped!"
|
print "Sector", sector, "wiped!"
|
||||||
else:
|
else:
|
||||||
print "Can't access sector", sector, "!"
|
print "Can't access sector", sector, "!"
|
||||||
MIFAREReader.MFRC522_StopCrypto1()
|
RFID.StopCrypto1()
|
||||||
sector += 1
|
sector += 1
|
||||||
|
|
||||||
print "\nTag wiped!"
|
print "\nTag wiped!"
|
||||||
|
|||||||
Reference in New Issue
Block a user