I have acr1281 reader with SAM slot (secure access module). I can communicate with card by pc/sc using python library smartcard. But I want to send commands to the SAM inserted to the reader.
How to 'switch commands channel' for that, is it even possible? smartcard library can send control command to reader (PC_to_RDR_Escape) but in the acr1281 documentation specified only GetFirmvareVersion command.
I even can see that SAM inserted or not - I call SCardStatus() and with SAM inserted get 0x34 code (as I understand this is SCARD_POWERED=0x10 | SCARD_NEGOTIABLE=0x20 | SCARD_PRESENT=0x04
), and without SAM it is 0x0c = SCARD_SWALLOWED=0x08 | SCARD_PRESENT=0x04
.
But all the commands I send go to MIFARE PICC placed on reader. And I want to send commands to SAM inserted into the reader.
In Ubuntu Linux with pscs driver installed I have 3 readers in smartcard
library:
from smartcard.System import readers
print(readers())
Reader 00 00
is inactive for me, I think it's for contact cards,
reader 00 01
is for PICC (MIFARE in my case),
reader 00 02
is for SAM slot in ACR,
So I use reader 01
to send card APDU and reader 02
to send commands to SAM and successfully solved my task.
Not sure how to find them automatically but I think that this 00 00
and so on is constants in names and I can select readers for PICC and for SAM by last symbol in their names.
I connect to PICC reader just by smartcard.CardRequest.CardRequest()
- waiting for card in proximity.
So I have to find only SAM reader and connect to it:
sam_connection = readers()[2].createConnection()
sam_connection.connect(mode=SCARD_SHARE_SHARED,
disposition=SCARD_LEAVE_CARD,
protocol=SCARD_PROTOCOL_ANY)