]> www.vanbest.org Git - sasc-ng.git/commitdiff
sc-videoguard2: add delayed writing mode (untested)
authorleslie <unknown>
Wed, 15 Oct 2008 22:37:46 +0000 (06:37 +0800)
committerleslie <unknown>
Wed, 15 Oct 2008 22:37:46 +0000 (06:37 +0800)
smartcard.c
smartcard.h
systems/sc-videoguard2/sc-videoguard2.c

index fb3838e3f4484be66f4457c48be3aab83d9dadac..0f642bd248df6c1e68578d5919ce1d0dbdaaeb52 100644 (file)
@@ -161,7 +161,7 @@ bool cSerial::SetMode(int mode, int baud)
     LBPUT("%s: set serial options: %d,",devName,baud);
     tio.c_cflag = (CS8 | CREAD | HUPCL | CLOCAL);
     if(!(mode&SM_1SB)) tio.c_cflag |= CSTOPB;
-    tio.c_iflag = (INPCK | BRKINT);
+    tio.c_iflag = (INPCK | IGNBRK);
     tio.c_cc[VMIN] = 1;
     cfsetispeed(&tio,bconst);
     cfsetospeed(&tio,bconst);
@@ -761,8 +761,14 @@ static const float Dtable[16] = {
   
 cSmartCard::cSmartCard(const struct CardConfig *Cfg, const struct StatusMsg *Msg)
 {
-  cfg=Cfg; msg=Msg;
+  msg=Msg;
   ser=0; atr=0; idStr[0]=0; cardUp=false; needsReset=true;
+  NewCardConfig(Cfg);
+}
+
+void cSmartCard::NewCardConfig(const struct CardConfig *Cfg)
+{
+  cfg=Cfg;
 }
 
 bool cSmartCard::GetCardIdStr(char *str, int len)
@@ -965,7 +971,7 @@ int cSmartCard::Write(const unsigned char *data, int len)
     Invert(tmp,len);
     data=tmp;
     }
-  int r=ser->Write(data,len);
+  int r=ser->Write(data,len,cfg->serDL);
   if(r>0) {
     unsigned char *buff=AUTOMEM(r);
     int rr=ser->Read(buff,r,cfg->serTO);
index f1eb72fb01882eec3db3327faf0fe7b5cc4c6aab..838ab07cd59a9348a076567d098fa83f50d813f4 100644 (file)
@@ -74,7 +74,7 @@ public:
 
 struct CardConfig {
   int SerMode;
-  int workTO, serTO; // values in ms
+  int workTO, serTO, serDL; // values in ms
   };
 
 struct StatusMsg {
@@ -117,6 +117,7 @@ protected:
   bool IsoWrite(const unsigned char *cmd, const unsigned char *data);
   bool Status(void);
   bool Test(bool res);
+  void NewCardConfig(const struct CardConfig *Cfg);
   int CheckSctLen(const unsigned char *data, int off);
   void TriggerReset(void) { needsReset=true; }
   static void Invert(unsigned char *data, int n);
index 9dcdc1132273df3bc8fb83018d428bc80f8c94a9..3080e88a484df21a5636278242f408a2db188801 100644 (file)
@@ -498,6 +498,10 @@ static const struct CardConfig cardCfg = {
   SM_8O2,2000,1400
   };
 
+static const struct CardConfig cardCfgDelay = {
+  SM_8O2,2000,1400,20
+  };
+
 cSmartCardVideoGuard2::cSmartCardVideoGuard2(void)
 :cSmartCard(&cardCfg,msgs)
 {
@@ -531,7 +535,11 @@ bool cSmartCardVideoGuard2::Init(void)
 
   static unsigned char ins7401[] = { 0xD0,0x74,0x01,0x00,0x00 };
   int l;
-  if((l=ReadCmdLen(ins7401))<0) return false;
+  if((l=ReadCmdLen(ins7401))<0) {
+    PRINTF(L_SC_ERROR,"bogus answer. Now try delayed mode");
+    NewCardConfig(&cardCfgDelay);
+    if((l=ReadCmdLen(ins7401))<0) return false;
+    }
   ins7401[4]=l;
   unsigned char buff[256];
   if(!IsoRead(ins7401,buff) || !Status()) {