Question

I am trying everything to read a serial id with a mifare card. I can use the atr from pyscard. But he will give the same id when i am using mulitiple cards.

Or do i write data on a mifare card. But how can i do this. I am useing the python script on a ubuntu server. My cardreader is a acr122u.

Please it will be very helpful

Thanks

Was it helpful?

Solution 2

The best way to use is pyscard (Python module) or Java Smart Card I/O (part of Java JDK)

OTHER TIPS

You should use APDU commands for this to work. The command to get UID is 0xFF,0xCA,0x00,0x00,0x00 in case of a mifare card.

Follow this link and look under high level api. This should give you an idea.

Here is some quick and dirty python code that uses pyscard and prints the UID (with assertions in lieu of actual error handling) by sending the APDU from Patrick's answer.

from smartcard.scard import *

hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)

assert hresult==SCARD_S_SUCCESS

hresult, readers = SCardListReaders(hcontext, [])

assert len(readers)>0

reader = readers[0]

hresult, hcard, dwActiveProtocol = SCardConnect(
    hcontext,
    reader,
    SCARD_SHARE_SHARED,
    SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1)

hresult, response = SCardTransmit(hcard,dwActiveProtocol,[0xFF,0xCA,0x00,0x00,0x00])

print(response)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top