From 7741f7159cdca7b3675b34952ad82c5b946a48d5 Mon Sep 17 00:00:00 2001 From: Christina Quast Date: Mon, 6 Apr 2015 19:06:05 +0200 Subject: [PATCH] ccid_raw.py: Reset smartcard method --- usb_application/ccid_raw.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/usb_application/ccid_raw.py b/usb_application/ccid_raw.py index 9ac15d85..1a51b687 100755 --- a/usb_application/ccid_raw.py +++ b/usb_application/ccid_raw.py @@ -23,6 +23,14 @@ class SmartcardConnection: print 'State:', state print 'Protocol:', protocol print 'ATR:', smartcard.util.toHexString(atr, smartcard.util.HEX) + return array.array('B', atr) + + def reset_card(self): + hresult, self.dwActiveProtocol = SCardReconnect(self.hcard, SCARD_SHARE_SHARED, + SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, SCARD_RESET_CARD) + if hresult != SCARD_S_SUCCESS: + raise SmartcardException('Unable to retrieve Atr: ' + + SCardGetErrorMessage(hresult)) def connect_card(self): hresult, self.hcard, self.dwActiveProtocol = SCardConnect(self.hcontext, self.reader,