Flowtter / py-acr122u

A library to use the acr122u at its full potential.
MIT License
50 stars 12 forks source link

2-second delay after sending certain commands #12

Open RokyB3 opened 3 months ago

RokyB3 commented 3 months ago

Hello,

I am using this simple python script:

from py122u import nfc
import time

while 1:
    # Initialize the NFC reader
    try: 
        reader = nfc.Reader()
    except:
        print("Error connecting to scanner")

    try:
        reader.connect()
        print(reader.read_binary_blocks(10, 4))
        time.sleep(0.5)
    except:
        print("Error reading from scanner")
        time.sleep(0.5)

The first time an NFC is connected to the scanner, its 10th page bytes are printed to the screen. They continue to be printed while the NFC is connected to the scanner.

When the NFC is removed from the scanner, the scanner's light stays green and it is not possible to read another chip.

Even after adding reader.disconnect() after the print(reader.read_binary_blocks(10, 4)) statement, it does not work.

Changing the sleep time in the last except statement from 0.5 to 2 allows the scanner time to seemingly timeout, change its light back to red, and connect to a new NFC chip.

Is there a way to disconnect from the chip and connect to another without waiting the two seconds?

Thanks.