]> www.vanbest.org Git - sasc-ng.git/commitdiff
smartcards: add single reset mode
authorleslie <unknown>
Sun, 22 Mar 2009 04:59:36 +0000 (12:59 +0800)
committerleslie <unknown>
Sun, 22 Mar 2009 04:59:36 +0000 (12:59 +0800)
smartcard.c

index f0715f74e072aa07b0b03996336658085894b97d..b5924046192a455a1527f8cd5eaad3b789e15f26 100644 (file)
@@ -78,7 +78,7 @@ protected:
   const struct CardConfig *cfg;
   unsigned char sb[SB_LEN];
   struct Atr atr;
-  bool localecho;
+  bool localecho, singlereset;
   //
   char devName[256];
   int currMode;
@@ -106,7 +106,8 @@ static const char *serModes[] = { 0,"8e2","8o2","8n2" };
 cSmartCardSlot::cSmartCardSlot(void)
 {
   card=0; cfg=0; usecount=0; slotnum=-1; currMode=SM_NONE; clock=ISO_FREQ;
-  firstRun=true; needsReset=false; dead=false; localecho=true;
+  firstRun=true; needsReset=false; dead=false;
+  localecho=true; singlereset=false;
 }
 
 cSmartCardSlot::~cSmartCardSlot()
@@ -223,9 +224,10 @@ void cSmartCardSlot::Action(void)
     else if(DeviceIsInserted()) {
       if(!dead) {
         PRINTF(L_CORE_SC,"%d: new card inserted",slotnum);
+        bool resetdone=false;
         for(int mode=SM_NONE+1 ; mode<SM_MAX ; mode++) {
           if(DeviceSetMode(mode,ISO_BAUD)) {
-            if(CardReset()) {
+            if((singlereset && resetdone) || (resetdone=CardReset())) {
               for(cSmartCardLink *scl=smartcards.First(); scl; scl=smartcards.Next(scl)) {
                 if(!Running()) goto done;
                 PRINTF(L_CORE_SC,"%d: checking for %s card",slotnum,scl->Name());
@@ -1080,6 +1082,7 @@ protected:
   //
   virtual bool Reset(void);
 public:
+  cSmartCardSlotCCID(void);
   virtual bool IsoRead(const unsigned char *cmd, unsigned char *data);
   virtual bool IsoWrite(const unsigned char *cmd, const unsigned char *data);
   virtual int RawRead(unsigned char *data, int len, int to=0) { return -1; }
@@ -1088,6 +1091,11 @@ public:
 
 static cSmartCardSlotLinkReg<cSmartCardSlotCCID> __scs_ccid("ccid");
 
+cSmartCardSlotCCID::cSmartCardSlotCCID(void)
+{
+  singlereset=true;
+}
+
 bool cSmartCardSlotCCID::DeviceOpen(const char *cfg)
 {
   if(!cfg || sscanf(cfg,"%255[^:]",devName)==1) {