LudovicRousseau / pyscard

pyscard smartcard library for python
http://pyscard.sourceforge.net/
GNU Lesser General Public License v2.1
379 stars 108 forks source link

IndexError: list index out of range #85

Closed mcy567 closed 4 years ago

mcy567 commented 4 years ago

Hello,I have a problem!

root@raspberrypi:~# python3 Python 3.4.2 (default, Oct 19 2014, 13:31:11) [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information.

from smartcard.System import readers r = readers() r ['ACS ACR122U PICC Interface 00 00'] connection = r[0].createConnection() connection.connect() SELECT1 = [0x00,0xA4,0x04,0x00,0x07,0xA0,0x00,0x00,0x03,0x33,0x01,0x01] data1, sw1, sw2 = connection.transmit(SELECT1) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.4/dist-packages/pyscard-1.9.9-py3.4-linux-armv7l.egg/smartcard/CardConnectionDecorator.py", line 82, in transmit return self.component.transmit(bytes, protocol) File "/usr/local/lib/python3.4/dist-packages/pyscard-1.9.9-py3.4-linux-armv7l.egg/smartcard/CardConnection.py", line 146, in transmit data, sw1, sw2 = self.doTransmit(bytes, protocol) File "/usr/local/lib/python3.4/dist-packages/pyscard-1.9.9-py3.4-linux-armv7l.egg/smartcard/pcsc/PCSCCardConnection.py", line 205, in doTransmit sw1 = (response[-2] + 256) % 256 IndexError: list index out of range

KeyboardInterrupt

root@raspberrypi:~# nfc-list nfc-list uses libnfc 1.7.1 NFC device: ACS / ACR122U PICC Interface opened 1 ISO14443A passive target(s) found: ISO/IEC 14443A (106 kbps) target: ATQA (SENS_RES): 00 04
UID (NFCID1): cf b9 e4 f8
SAK (SEL_RES): 28
ATS: 78 80 81 02 4b 4f 4e 41 12 21

I don't know why the code retrun a error.I print the 'response'.It's value is '[]'. Can you help me?

LudovicRousseau commented 4 years ago

It is not an error in pyscard. The reader sent a response with 0 bytes.

You should read the reader documentation to know what command to use.

mcy567 commented 4 years ago

Thank you!