santigimeno / node-pcsclite

Bindings over pcsclite to access Smart Cards
ISC License
170 stars 125 forks source link

Desfire 4k EV2 GetVersion command getting 911C response #103

Closed cyrstron closed 3 months ago

cyrstron commented 3 months ago

I'm using ACR122U-A9 NFC card reader for communication with a DESFire EV2 card.

I am sending GetVersion command which implies this series:

CMD 1: 90 60 00 00 00 Response: XX XX XX XX XX XX XX 91 AF

CMD 2: 90 AF 00 00 00 Response: XX XX XX XX XX XX XX 91 AF

CMD 3: 90 AF 00 00 00 Response: XX XX XX XX XX XX XX XX XX XX XX XX XX XX 91 00

But after sending CMD2 I get 911C error. The problem can be kinda fixed by adding setTimeout around 400ms between the card connection event and GetVersion request, but that seems like a very poor workaround.

cyrstron commented 3 months ago

The issue was fixed by using SCARD_SHARE_EXCLUSIVE share_mode instead of SCARD_SHARE_SHARED.

I guess, WIN sends some APDU commands to a card under the hood and breaks the command transaction.