Closed consulttelecom closed 8 years ago
What is the result of the execution of the script bellow:
#! /usr/bin/env python
from smartcard.scard import *
def test_getReturnCodes():
errors = (
SCARD_S_SUCCESS,
SCARD_F_INTERNAL_ERROR,
SCARD_E_CANCELLED,
SCARD_E_INVALID_HANDLE,
SCARD_E_INVALID_PARAMETER,
SCARD_E_INVALID_TARGET,
SCARD_E_NO_MEMORY,
SCARD_F_WAITED_TOO_LONG,
SCARD_E_INSUFFICIENT_BUFFER,
SCARD_E_UNKNOWN_READER,
SCARD_E_TIMEOUT,
SCARD_E_SHARING_VIOLATION,
SCARD_E_NO_SMARTCARD,
SCARD_E_UNKNOWN_CARD,
SCARD_E_CANT_DISPOSE,
SCARD_E_PROTO_MISMATCH,
SCARD_E_NOT_READY,
SCARD_E_INVALID_VALUE,
SCARD_E_SYSTEM_CANCELLED,
SCARD_F_COMM_ERROR,
SCARD_F_UNKNOWN_ERROR,
SCARD_E_INVALID_ATR,
SCARD_E_NOT_TRANSACTED,
SCARD_E_READER_UNAVAILABLE,
SCARD_E_PCI_TOO_SMALL,
SCARD_E_READER_UNSUPPORTED,
SCARD_E_DUPLICATE_READER,
SCARD_E_CARD_UNSUPPORTED,
SCARD_E_NO_SERVICE,
SCARD_E_SERVICE_STOPPED,
SCARD_E_UNEXPECTED,
SCARD_E_ICC_INSTALLATION,
SCARD_E_ICC_CREATEORDER,
SCARD_E_UNSUPPORTED_FEATURE,
SCARD_E_DIR_NOT_FOUND,
SCARD_E_FILE_NOT_FOUND,
SCARD_E_NO_DIR,
SCARD_E_NO_FILE,
SCARD_E_NO_ACCESS,
SCARD_E_WRITE_TOO_MANY,
SCARD_E_BAD_SEEK,
SCARD_E_INVALID_CHV,
SCARD_E_UNKNOWN_RES_MNG,
SCARD_E_NO_SUCH_CERTIFICATE,
SCARD_E_CERTIFICATE_UNAVAILABLE,
SCARD_E_NO_READERS_AVAILABLE,
SCARD_E_COMM_DATA_LOST,
SCARD_E_NO_KEY_CONTAINER,
SCARD_E_SERVER_TOO_BUSY,
SCARD_W_UNSUPPORTED_CARD,
SCARD_W_UNRESPONSIVE_CARD,
SCARD_W_UNPOWERED_CARD,
SCARD_W_RESET_CARD,
SCARD_W_REMOVED_CARD,
SCARD_W_SECURITY_VIOLATION,
SCARD_W_WRONG_CHV,
SCARD_W_CHV_BLOCKED,
SCARD_W_EOF,
SCARD_W_CANCELLED_BY_USER,
SCARD_W_CARD_NOT_AUTHENTICATED,
)
for e in errors:
print(hex((e+0x100000000) & 0xFFFFFFFF), SCardGetErrorMessage(e))
if __name__ == '__main__':
test_getReturnCodes()
Traceback (most recent call last):
File "C:/Python34/testsimscript.py", line 74, in
It looks like an string encoding issue. Can you help debug the issue? I do not use Windows.
I think it is the issue of string encoding between Python 3 and Python 2. Sure, I can help. What kind of debug do you need?
I also think it is a encoding issue. The problem is that I do not use Windows myself so it is hard for me to debug this Windows only problem.
I have no problem with Python 3.4 on Windows 7 32-Bits using the .msi installer available at https://ci.appveyor.com/project/LudovicRousseau/pyscard/build/job/sktrggp6yxxofqgb/artifacts
What version of Windows do you use? How have you installed pyscard?
No answer since 2 months. I guess you solved the problem. Closing.
data, sw1, sw2 = self.cardservice.connection.transmit(apdu) File "C:\Python34\lib\site-packages\pyscard-1.9.0-py3.4-win-amd64.egg\smartcard\CardConnectionDecorator.py", line 82, in transmit return self.component.transmit(bytes, protocol) File "C:\Python34\lib\site-packages\pyscard-1.9.0-py3.4-win-amd64.egg\smartcard\CardConnection.py", line 142, in transmit data, sw1, sw2 = self.doTransmit(bytes, protocol) File "C:\Python34\lib\site-packages\pyscard-1.9.0-py3.4-win-amd64.egg\smartcard\pcsc\PCSCCardConnection.py", line 205, in doTransmit SCardGetErrorMessage(hresult)) File "C:\Python34\lib\site-packages\pyscard-1.9.0-py3.4-win-amd64.egg\smartcard\scard\scard.py", line 1241, in SCardGetErrorMessage return _scard.SCardGetErrorMessage(lErrCode) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 0: invalid continuation byte