Closed abkarino closed 5 years ago
@LudovicRousseau Sorry I overrode your changes. :)
It may well be a "limitation" of the reader. The reader has no easy way to detect the card is no more present. So it must use a timeout. I don't know if you can change the reader timeout. I guess not.
If it is the reader, then the timeout would be consistent. You see I send a buzzer code in case of fail. After it is done, it takes 2 second in case of I authenticated the card. But takes 0.1 if I don't.
I am using ACR122U. If I don't run the python script, the response is 0.1
for card in addedcards:
try:
card.connection = card.createConnection()
card.connection.connect()
card.connection.transmit(self.SuccessBeeb)
raise Exception("Card not supported")
except Exception as e:
try:
card.connection.transmit(self.WrongBeeb)
except:
pass
print(e.message)
pass
This code results in 0.1 sec response time, so I am sure it is not the write process as I can't play the sound if the card is not found.
So it is mainly data, sw1, sw2 = card.connection.transmit(self.Auth)
.
Can you propose any approach to get more info about that? Will you have time, to check if you can reproduce it?
You can try to get logs at the PC/SC level. But I have no idea how to do that on Windows.
@LudovicRousseau do you provide a way to unpower card? It seems that my problem is releated to auto power off after 5 sec. I want to unpower card via code.
I see hresult = SCardDisconnect(hcard, SCARD_UNPOWER_CARD)
in get the ATR of a card
but don't know how to integrate since I use observer approach.
SCardDisconnect() is part of the low level PySCard API. https://pyscard.sourceforge.io/epydoc/smartcard.scard.scard-module.html#SCardDisconnect
How to integrate with high level API? Do I have to make the whole script based on low level API?
The .connect()
method has a disposition
parameter.
https://pyscard.sourceforge.io/epydoc/smartcard.CardConnection.CardConnection-class.html#connect
using disposition=SCARD_UNPOWER_CARD
should unpower the card on disconnection.
I think I tried it but didn't work, I will give it another try and let you know. Meanwhile, can your delete your edit from the post edit history, I cannot delete it and it contains the key. Thanks.
I have a script that authenticates Mifare Classic 1K. However, the reader takes around 2 second to be ready to sense another card. This issue happens if I attempt to authenticate the card using stored key. If I remove the code that authenticates (or throw the error
Card not supported
always), it takes less than 0.1 sec to sense the card is removed. Any ideas of the reason? P.S. The buzzer and LED control don't affect the bug. If removed, the led is turned off for 2 seconds after the communication. I am using Python27x64 on Windows10.Here is my code: