Transmit speed
LostOctopus opened this issue · 2 comments
Your system information
- Operating system used: Windows
- pyscard version: 2.0.5
- Python version: 3.10.5
- Editor: Pycharm and also in command line
Please describe your issue in as much detail as possible:
The transmit command speed differs even if the script is the same. I run the same script but one time on two, the speed is two times slower. After a quick investigation I observe the behavior described below. Using a profiling tool it seems that it comes from SCardTransmit, I guess this correspond to the PCSC driver or maybe the connection with the interface maybe. The script works each time, but it takes twice longer.
Steps for reproducing this issue:
- Insert a card in the reader
- Run the script, check the speed denoted Speed1
- Re-run the same script, the speed is different denoted Speed2
- Re-run the same script, the speed go back to Speed1
- Re-run the same script, the speed switch to Speed2
Remark the speed is always Speed1 just after inserting the card in the reader. If I remove and insert back the card I stay on Speed1 in all cases.
Code
from smartcard.System import readers
from tqdm import tqdm
if __name__ == '__main__':
# Init reader
r = readers()
print(r)
connection = r[0].createConnection()
connection.connect()
# start run using iteration parameter
nr_commands = 100
for i in tqdm(range(nr_commands), desc="Progress"):
my_cmd = "88A000000B11223344556677880A0B0C08"
data, sw1, sw2 = connection.transmit(list(bytes.fromhex(my_cmd )))
I think the "problem" comes from the reader and/or driver.
pyscard has no mechanism to slow down a .transmit()
.
You can try to write a C program (instead of Python) just to be sure.
You can contact the smart card reader manufacturer.
I changed the reader and effectively this comes from here. Thank you Ludovic. Now I have to find a fast reader.