diff --git a/src/requirements.txt b/src/requirements.txt index 22b9b08..214557b 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -17,7 +17,8 @@ pyserial pyserial-asyncio qrcode requests -tensorflow +#tensorflow #tflite-runtime zebra pylibdmtx~=0.1.10 +pandas~=1.3.3 \ No newline at end of file diff --git a/src/test/rfid.py b/src/test/rfid.py index 322f2c9..b7afc48 100644 --- a/src/test/rfid.py +++ b/src/test/rfid.py @@ -2,6 +2,7 @@ import logging import platform import sys import time +import traceback from datetime import datetime from pathlib import Path @@ -10,7 +11,6 @@ import ndef import nfc from nfc.clf import RemoteTarget - logging.basicConfig( format="{asctime}:{name}:{levelname}:{message}", datefmt="%Y-%m-%dT%H-%M-%S%z", @@ -31,59 +31,63 @@ logging.basicConfig( **({"errors": "surrogateescape"} if sys.version_info.major >= 3 and sys.version_info.minor >= 10 else {}), ) -connected=False +connected = False is_win = platform.system().lower() == "windows" if is_win: - dev_list=['com:COM5:pn532'] + dev_list = ['com:COM5:pn532'] else: dev_list = ['tty:USB0:pn532', 'tty:USB1:pn532', 'tty:USB2:pn532'] while True: try: if not connected: + logging.info("Attempting to connect to NFC reader...") clf = nfc.ContactlessFrontend() for dev in dev_list: connected = clf.open(dev) if connected: - print(f"CONNECTED TO {dev}") + logging.info(f"CONNECTED TO {dev}") break else: - print(f"UNABLE TO CONNECT TO {dev}") + logging.error(f"UNABLE TO CONNECT TO {dev}") if connected: target = clf.sense(RemoteTarget('106A'), RemoteTarget('106B'), RemoteTarget('212F')) if target is not None: tag = nfc.tag.activate(clf, target) if tag is not None: - print(tag) + logging.info(f"Tag detected: {tag}") if tag.ndef is not None: if not len(tag.ndef.records): - print("EMPTY TAG - WRITING...") + logging.info("EMPTY TAG - WRITING...") if not tag.ndef.is_writeable: - print("This Tag is not writeable.") + logging.warning("This Tag is not writeable.") break else: tag.format() - #tag.ndef.records = [ndef.TextRecord("Errecinque"),ndef.TextRecord("5812345678")] - record=ndef.TextRecord("Errecinque,fixture,5812345678") + record = ndef.TextRecord("Errecinque,fixture,5812345678") tag.ndef.records = [record] if tag.ndef.has_changed: - print("WRITE ERROR") + logging.error("WRITE ERROR") else: - print("WRITE OK") - + logging.info("WRITE OK") for record in tag.ndef.records: - print(record) + logging.info(f"Record: {record}") else: - print("ERROR NOT NDEF") + logging.error("ERROR NOT NDEF") else: - print("NO TARGET") + logging.info("NO TARGET") else: - print("NOT CONNECTED") + logging.info("NOT CONNECTED") + except IOError as io_err: + logging.error(f"IOError: {io_err}") + traceback.print_exc() + connected = False except Exception as e: - print(f"EXCEPTION {e}") - connected=False + logging.error(f"General Exception: {e}") + traceback.print_exc() + connected = False time.sleep(1) -print("EXITING") -clf.close() \ No newline at end of file +logging.info("EXITING") +clf.close()