From c1834c3a765874931fe3865d4d9ae76792f1b328 Mon Sep 17 00:00:00 2001 From: bton Date: Thu, 8 Feb 2024 00:22:45 +0100 Subject: [PATCH] cp old NFC file and deleted all the website stuff --- NFC_Reader.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 NFC_Reader.py diff --git a/NFC_Reader.py b/NFC_Reader.py new file mode 100644 index 0000000..6e61275 --- /dev/null +++ b/NFC_Reader.py @@ -0,0 +1,27 @@ +import time +import nfc + +def get_reader(): + devices = subprocess.check_output("lsusb") + for i in devices.split(b'\n'): + if str(i).__contains__("Advanced Card Systems, Ltd ACR122U"): + bus = str(i).split(":")[0].split(" Device ")[0].split("Bus ")[1] + device = str(i).split(":")[0].split("Device ")[1] + return("usb:{}:{}".format(bus, device)) + raise Exception("\n\n Error: NFC reader not found") + +def onTagSense(tag): + id = int.from_bytes(tag.identifier, "big") + print(id) + return True + +def start_nfc_normal(): + device = get_reader() + clf = nfc.ContactlessFrontend(device) + clf.open(device) + while True: + clf.connect(rdwr={'on-connect': onTagSense, 'beep-on-connect': True }) + +if __name__ == "__main__": + start_nfc_normal() +