From 1edbf9c4aefcc1a4e19e209e897837c43debd649 Mon Sep 17 00:00:00 2001 From: EggMan20339 <99349302+EggMan20339@users.noreply.github.com> Date: Thu, 9 May 2024 21:11:20 -0400 Subject: [PATCH] testing NFC --- main.py | 2 +- test.py | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test.py diff --git a/main.py b/main.py index 92213b3..1e3ea91 100644 --- a/main.py +++ b/main.py @@ -33,7 +33,7 @@ On Windows, the native WebAuthn API will be used. """ import time import configparser -gpie = True +gpie = False if gpie: import RPi.GPIO as GPIO import pickle diff --git a/test.py b/test.py new file mode 100644 index 0000000..e07f922 --- /dev/null +++ b/test.py @@ -0,0 +1,26 @@ +import nfc +import time + +def connected(tag): + print("Tag detected:", tag) + return True + +def read_nfc(): + try: + clf = nfc.ContactlessFrontend('usb') # Ensure this matches your connection + print("NFC reader initialized.") + except Exception as e: + print("Failed to initialize NFC reader:", e) + return + + try: + while True: + print("Waiting for NFC tag...") + clf.connect(rdwr={'on-connect': connected}) + time.sleep(1) + except Exception as e: + print("Error reading NFC tag:", e) + finally: + clf.close() + +read_nfc()