Changeset 7758
- Timestamp:
- 10/19/12 21:00:07 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/ifd_sci.c
r7757 r7758 88 88 return ERROR; 89 89 } 90 int32_t inverse = 0; // card is using inversion? 1=inversion / 0= no inversion91 90 if (buf[0] == 0x3F){ // 3F: card is using inverse convention, 3B = card is using direct convention 92 inverse = 0; // tryfix: inverse convention, does it apply to ATR?93 91 rdr_debug_mask(reader, D_IFD, "This card uses inverse convention"); 94 92 } … … 99 97 return ERROR; 100 98 } 101 if (inverse) buf[n] = ~(INVERT_BYTE (buf[n]));102 99 int32_t T0= buf[n]; 103 100 int32_t historicalbytes = T0&0x0F; // num of historical bytes in lower nibble of T0 byte … … 112 109 if (TDi&0x10){ //TA Present: //The value of TA(i) is always interpreted as XI || UI if i > 2 and T = 15 ='F'in TD(i1) 113 110 if (IO_Serial_Read(reader, timeout, 1, buf+n)) break; //In this case, TA(i) contains the clock stop indicator XI, which indicates the logical 114 if (inverse) buf[n] = ~(INVERT_BYTE (buf[n]));//state the clockline must assume when the clock is stopped, and the class indicator UI,111 //state the clockline must assume when the clock is stopped, and the class indicator UI, 115 112 rdr_debug_mask(reader, D_ATR, "TA%d: %02X",protocols,buf[n]); //which specifies the supply voltage class. 116 113 if ((protocols >2) && ((TDi&0x0F)==0x0F)){ // Protocol T15 does not exists, it means mandatory on all ATRs … … 157 154 if (TDi&0x20){ //TB Present 158 155 if (IO_Serial_Read(reader, timeout, 1, buf+n)) break; 159 if (inverse) buf[n] = ~(INVERT_BYTE (buf[n]));160 156 rdr_debug_mask(reader, D_ATR, "TB%d: %02X",protocols,buf[n]); 161 157 if ((protocols >2) && ((TDi&0x0F)==0x01)){ // Protocol T1 specfic (There is always an obsolete T0 protocol!) … … 173 169 if (TDi&0x40){ //TC Present 174 170 if (IO_Serial_Read(reader, timeout, 1, buf+n)) break; 175 if (inverse) buf[n] = ~(INVERT_BYTE (buf[n]));176 171 rdr_debug_mask(reader, D_ATR, "TC%d: %02X",protocols, buf[n]); 177 172 if ((protocols == 2) && ((TDi&0x0F)==0x00)){ … … 183 178 else rdr_debug_mask(reader, D_ATR, "Protocol T1: LRC is used to compute the error detection code"); 184 179 } 185 if((protocols == 1) && buf[n]<0xFF) rdr_debug_mask(reader, D_ATR, "Extra guardtime of %d ETU (N)", (int) buf[n]);186 if((protocols == 1) && buf[n]==0xFF) rdr_debug_mask(reader, D_ATR, "Protocol T1: Standard 2 ETU guardtime is lowered to 1 ETU");180 if((protocols == 1) && (buf[n]<0xFF)) rdr_debug_mask(reader, D_ATR, "Extra guardtime of %d ETU (N)", (int) buf[n]); 181 if((protocols == 1) && (buf[n]==0xFF)) rdr_debug_mask(reader, D_ATR, "Protocol T1: Standard 2 ETU guardtime is lowered to 1 ETU"); 187 182 188 183 n++; // next interface character … … 190 185 if (TDi&0x80){ //TD Present? Get next TDi there will be a next protocol 191 186 if (IO_Serial_Read(reader, timeout, 1, buf+n)) break; 192 if (inverse) buf[n] = ~(INVERT_BYTE (buf[n]));193 187 rdr_debug_mask(reader, D_ATR, "TD%d %02X",protocols,buf[n]); 194 188 TDi = buf[n]; … … 212 206 while(n < atrlength + tck){ // read all the rest and mandatory tck byte if other protocol than T0 is used. 213 207 if (IO_Serial_Read(reader, timeout, 1, buf+n)) break; 214 if (inverse) buf[n] = ~(INVERT_BYTE (buf[n]));215 208 n++; 216 209 } … … 221 214 buf[0] = 0x3B; 222 215 223 int32_t t=n; // just a counter224 while ((t>0) && inverse){ // in case of inverse atr invert whole readed ATR again for parsing by ATR_InitFromArray225 buf[t] = ~(INVERT_BYTE (buf[t]));226 t--;227 }228 229 230 216 statusreturn = ATR_InitFromArray (atr, buf, n); // n should be same as atrlength but in case of atr read error its less so do not use atrlenght here! 231 217
Note:
See TracChangeset
for help on using the changeset viewer.