V
V
Vasya Borisevich2019-08-08 15:15:01
Python
Vasya Borisevich, 2019-08-08 15:15:01

How to read card number using pyscard?

I ask for help in reading the card through pyscard. I'm trying to read the number from the manual. What I'm doing wrong I can't say.
The request is simple to give a code who already faced it. I know it's rude, but time is running out.
My code:

from smartcard.System import readers
from smartcard.util import toHexString

r = readers()
print(r)

connection = r[0].createConnection()
connection.connect()
SELECT = [0xA0, 0xA4, 0x00, 0x02]
DF_TELECOM = [0x7F, 0x10]
data, sw1, sw2 = connection.transmit( SELECT + DF_TELECOM )
print("%x %x" % (sw1, sw2))

Exhaust:
['ACS ACR1252 Dual Reader PICC 0', 'ACS ACR1252 Dual Reader SAM 0']
Traceback (most recent call last):
  File "reader.py", line 11, in <module>
    data, sw1, sw2 = connection.transmit( SELECT + DF_TELECOM )
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\
smartcard\CardConnectionDecorator.py", line 82, in transmit
    return self.component.transmit(bytes, protocol)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\
smartcard\CardConnection.py", line 146, in transmit
    data, sw1, sw2 = self.doTransmit(bytes, protocol)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\
smartcard\pcsc\PCSCCardConnection.py", line 205, in doTransmit
    SCardGetErrorMessage(hresult))
smartcard.Exceptions.CardConnectionException: Failed to transmit with protocol T
1. Idldroc? aaiar/auaiar auer ddldarir cc-cr craldrlic? dinier eieria cec di crd
dino ddceiclic?.

It can be seen that the name of the reader is received and an error follows.
I say right away that I am far from the protocols for the operation of smart cards and readers, which is why I am asking for help here.
Platform Windows 7
Python v3.6.8 x64

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question