add 7/10 bytes ID
This commit is contained in:
@@ -1,46 +1,41 @@
|
||||
import mfrc522
|
||||
from os import uname
|
||||
|
||||
|
||||
def do_read():
|
||||
|
||||
if uname()[0] == 'WiPy':
|
||||
rdr = mfrc522.MFRC522("GP14", "GP16", "GP15", "GP22", "GP17")
|
||||
elif uname()[0] == 'esp8266':
|
||||
rdr = mfrc522.MFRC522(0, 2, 4, 5, 14)
|
||||
else:
|
||||
raise RuntimeError("Unsupported platform")
|
||||
|
||||
print("")
|
||||
print("Place card before reader to read from address 0x08")
|
||||
print("")
|
||||
|
||||
try:
|
||||
while True:
|
||||
|
||||
(stat, tag_type) = rdr.request(rdr.REQIDL)
|
||||
|
||||
if stat == rdr.OK:
|
||||
|
||||
(stat, raw_uid) = rdr.anticoll()
|
||||
|
||||
if stat == rdr.OK:
|
||||
print("New card detected")
|
||||
print(" - tag type: 0x%02x" % tag_type)
|
||||
print(" - uid : 0x%02x%02x%02x%02x" % (raw_uid[0], raw_uid[1], raw_uid[2], raw_uid[3]))
|
||||
print("")
|
||||
|
||||
if rdr.select_tag(raw_uid) == rdr.OK:
|
||||
|
||||
key = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
|
||||
|
||||
if rdr.auth(rdr.AUTHENT1A, 8, key, raw_uid) == rdr.OK:
|
||||
print("Address 8 data: %s" % rdr.read(8))
|
||||
rdr.stop_crypto1()
|
||||
else:
|
||||
print("Authentication error")
|
||||
else:
|
||||
print("Failed to select tag")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("Bye")
|
||||
import mfrc522
|
||||
from os import uname
|
||||
|
||||
|
||||
def uidToString(uid):
|
||||
mystring = ""
|
||||
for i in uid:
|
||||
mystring = "%02X" % i + mystring
|
||||
return mystring
|
||||
|
||||
def do_read():
|
||||
|
||||
if uname()[0] == 'WiPy':
|
||||
rdr = mfrc522.MFRC522("GP14", "GP16", "GP15", "GP22", "GP17")
|
||||
elif uname()[0] == 'esp32':
|
||||
rdr = mfrc522.MFRC522(sck=18,mosi=23,miso=19,rst=22,cs=21)
|
||||
else:
|
||||
raise RuntimeError("Unsupported platform")
|
||||
|
||||
print("")
|
||||
print("Place card before reader to read from address 0x08")
|
||||
print("")
|
||||
|
||||
try:
|
||||
while True:
|
||||
|
||||
(stat, tag_type) = rdr.request(rdr.REQIDL)
|
||||
|
||||
if stat == rdr.OK:
|
||||
|
||||
(stat, uid) = rdr.SelectTagSN()
|
||||
|
||||
if stat == rdr.OK:
|
||||
print("Card detected %s" % uidToString(uid))
|
||||
else:
|
||||
print("Authentication error")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("Bye")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user