Changeset 959 for branches/monitor-improvement/csctapi/pps.c
- Timestamp:
- 12/26/09 22:54:46 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/monitor-improvement/csctapi/pps.c
r925 r959 58 58 59 59 static int PPS_InitProtocol (PPS * pps, int protocol_selected); 60 61 //static void PPS_SelectFirstProtocol (PPS * pps);62 60 63 61 static BYTE PPS_GetPCK (BYTE * block, unsigned length); … … 183 181 if (OffersT[i]) 184 182 numprottype ++; 183 cs_debug("%i protocol types detected. Historical bytes: %s",numprottype, cs_hexdump(1,atr->hb,atr->hbn)); 185 184 186 185 //If more than one protocol type and/or TA1 parameter values other than the default values and/or N equeal to 255 is/are indicated in the answer to reset, the card shall know unambiguously, after having sent the answer to reset, which protocol type or/and transmission parameter values (FI, D, N) will be used. Consequently a selection of the protocol type and/or the transmission parameters values shall be specified. 187 186 ATR_GetParameter (atr, ATR_PARAMETER_N, &(pps->parameters.n)); 188 187 ATR_GetProtocolType(atr,1,&(pps->parameters.t)); //get protocol from TD1 189 bool NeedsPTS = ((pps-> icc->ifd->io->com != RTYP_SCI) && (pps->parameters.t != 14) && (numprottype > 1 || (atr->ib[0][ATR_INTERFACE_BYTE_TA].present == TRUE && atr->ib[0][ATR_INTERFACE_BYTE_TA].value != 0x11) || pps->parameters.n == 255)); //needs PTS according to ISO 7816 , SCI gets stuck on our PTS190 if (NeedsPTS ) {188 bool NeedsPTS = ((pps->parameters.t != 14) && (numprottype > 1 || (atr->ib[0][ATR_INTERFACE_BYTE_TA].present == TRUE && atr->ib[0][ATR_INTERFACE_BYTE_TA].value != 0x11) || pps->parameters.n == 255)); //needs PTS according to ISO 7816 , SCI gets stuck on our PTS 189 if (NeedsPTS && (pps->icc->ifd->io->com != RTYP_SCI)) { 191 190 // PTSS PTS0 PTS1 PTS2 PTS3 PCK 192 191 // PTSS PTS0 PTS1 PCK … … 215 214 } 216 215 } 217 //FIXME: If the card is able to process more than one protocol type and if one of those protocol types is indicated as T=0, then the protocol type T=0 shall indicated in TD1 as the first offered protocol, and is assumed if no PTS is performed.218 216 219 217 //FIXME Currently InitICC sets baudrate to 9600 for all T14 cards, which is the old behaviour... 220 218 if (!PPS_success) {//last PPS not succesfull 221 219 BYTE TA1; 222 if ( !NeedsPTS &&ATR_GetInterfaceByte (atr, 1 , ATR_INTERFACE_BYTE_TA, &TA1) == ATR_OK && pps->parameters.t != 14) {220 if (ATR_GetInterfaceByte (atr, 1 , ATR_INTERFACE_BYTE_TA, &TA1) == ATR_OK && pps->parameters.t != 14) { 223 221 pps->parameters.FI = TA1 >> 4; 224 222 ATR_GetParameter (atr, ATR_PARAMETER_D, &(pps->parameters.d)); 225 223 } 226 else { //do not obey TA1 if T14 , or when PTS is needed according to ISO, but failed, so not obeying ISO224 else { //do not obey TA1 if T14 227 225 pps->parameters.FI = ATR_DEFAULT_FI; 228 226 pps->parameters.d = ATR_DEFAULT_D; … … 232 230 ATR_GetProtocolType (atr, 1, &(pps->parameters.t)); 233 231 protocol_selected = 1; 234 cs_debug("No PTS, selected protocol 1: T%i, F=%.0f, D=%.6f, N=%.0f\n", pps->parameters.t, (double) atr_f_table[pps->parameters.FI], pps->parameters.d, pps->parameters.n); 232 233 if (NeedsPTS) { //FIXME we MUST discover PTS routine for Dreambox reader, now all cards in DBreaders which need PTS come here!!! 234 if (OffersT[0]) { 235 //If the card is able to process more than one protocol type and if one of those protocol types is indicated as T=0, then the protocol type T=0 shall indicated in TD1 as the first offered protocol, and is assumed if no PTS is performed. 236 pps->parameters.t = ATR_PROTOCOL_TYPE_T0; 237 pps->parameters.FI = ATR_DEFAULT_FI; //ignoring TA1 is necessary at least for all viaccess cards on dreambox readers 238 pps->parameters.d = ATR_DEFAULT_D; //but perhaps it is the general thing to do... 239 } 240 } 241 /////Here all non-ISO behaviour 242 // Nagra HD+ 243 // ATR: 3F FF 95 00 FF 91 81 71 FE 47 00 44 4E 41 53 50 31 34 32 20 52 65 76 47 43 34 63 244 // Protocol 1: TA1=95 TB1=00 TC1=FF TD1=91 (T1) 245 // Protocol 2: TA2=81 TD2=71 (T1) 246 // Protocol 3: TA3=FE TB3=47 TC3=00 no TD3 means T0 247 // 248 // Problem1: card somehow fails all PTS attempts; perhaps because N=255 and we try PTS without it? 249 // Problem2: card reports to support T0 but TA1=FE , which values are (still) undefined . On failure of PTS card reverts to TA=11 which 250 // makes the card fail 251 // We know the card needs 115200 (with cardmhz = 368) after ATR 252 // Solution: longterm: implement PTS2 253 // Solution: shorterm: this hardcoding 254 // 255 unsigned char nagra_hdplus[] = {0x44, 0x4E, 0x41, 0x53, 0x50}; //DNASP, not sure about timings of TIGER & others 256 if (atr->hbn >= sizeof(nagra_hdplus)) 257 if (!memcmp(atr->hb, nagra_hdplus, sizeof(nagra_hdplus))) { 258 ATR_GetProtocolType (atr, 1, &(pps->parameters.t)); 259 protocol_selected = 1; 260 if (ATR_GetInterfaceByte (atr, 1 , ATR_INTERFACE_BYTE_TA, &TA1) == ATR_OK) { 261 pps->parameters.FI = TA1 >> 4; 262 ATR_GetParameter (atr, ATR_PARAMETER_D, &(pps->parameters.d)); 263 } 264 } 265 // 266 // 267 /////End all non-ISO behaviour 268 if (pps->icc->ifd->io->com == RTYP_SCI) { 269 //// Here all fixes that are needed until PTS routine for Dreambox is found 270 //// End all fixes that are needed until PTS routine for Dreambox is found 271 if (atr->hbn >=6) 272 if (!memcmp( atr->hb, "IRDETO", 6 )) { //IRDETO needs TA1 behaviour on /dev/sci ; which other cards need ignore TA1 on T14? 273 pps->parameters.FI = TA1 >> 4; 274 ATR_GetParameter (atr, ATR_PARAMETER_D, &(pps->parameters.d)); 275 } 276 } 277 278 cs_debug("No PTS %s, selected protocol 1: T%i, F=%.0f, D=%.6f, N=%.0f\n", NeedsPTS?"happened":"needed", pps->parameters.t, (double) atr_f_table[pps->parameters.FI], pps->parameters.d, pps->parameters.n); 235 279 } 236 280 }//end length<0 … … 387 431 return PPS_ICC_ERROR; 388 432 389 433 ATR *atr = ICC_Async_GetAtr (pps->icc); 390 434 391 435 params.T = pps->parameters.t; 392 436 393 437 BYTE oldFI = params.FI; 394 438 // params.FI = pps->parameters.FI; //somehow setting this gets "card unsupported" 395 439 /* if (pps->icc->ifd->io->mhz > 368) { … … 406 450 407 451 if (oldFI != params.FI) 408 409 410 452 cs_log("Forcing params.FI from %i to %i", oldFI, params.FI); 453 454 double F = (double) atr_f_table[pps->parameters.FI]; 411 455 params.ETU = F / pps->parameters.d; 412 456 if (pps->parameters.n == 255) … … 514 558 return PPS_PROTOCOL_ERROR; 515 559 } 516 /* 517 static void PPS_SelectFirstProtocol (PPS * pps) 518 { 519 ATR *atr = ICC_Async_GetAtr (pps->icc); 520 unsigned np; 521 522 pps->parameters.t = ATR_PROTOCOL_TYPE_T0; 523 524 ATR_GetNumberOfProtocols (atr, &np); 525 526 527 // Get protocol offered by interface bytes T*2 if available, 528 // (that is, if TD1 is available), * otherwise use default T=0 529 530 if (np>1) 531 ATR_GetProtocolType (atr, 2, &(pps->parameters.t)); 532 533 #ifdef DEBUG_PROTOCOL 534 printf ("PPS: Protocol T=%d selected\n", pps->parameters.t); 535 #endif 536 } 537 */ 560 538 561 static BYTE PPS_GetPCK (BYTE * block, unsigned length) 539 562 {
Note:
See TracChangeset
for help on using the changeset viewer.