Changeset 1253 for trunk/csctapi/ifd_towitoko.c
- Timestamp:
- 01/16/10 17:29:40 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/ifd_towitoko.c
r1252 r1253 146 146 } 147 147 148 int IFD_Towitoko_Init (IFD * ifd, IO_Serial * io,BYTE slot)148 int IFD_Towitoko_Init (IFD * ifd, BYTE slot) 149 149 { 150 150 int ret; … … 173 173 if(reader[ridx].typ == R_INTERNAL) 174 174 { 175 ifd->io = io;176 175 ifd->slot = slot; 177 176 ifd->type = IFD_TOWITOKO_MULTICAM; … … 186 185 /* Default ifd settings */ 187 186 188 ifd->io = io;189 187 ifd->slot = slot; 190 188 ifd->type = IFD_TOWITOKO_MULTICAM; … … 197 195 198 196 if (!IO_Serial_SetParity (PARITY_EVEN)) 197 { 198 IFD_Towitoko_Clear (ifd); 199 199 return IFD_TOWITOKO_IO_ERROR; 200 201 if (ret != IFD_TOWITOKO_OK)202 {203 IFD_Towitoko_Clear (ifd);204 return ret;205 200 } 206 201 … … 213 208 else 214 209 { 215 IO_Serial_Flush( ifd->io);210 IO_Serial_Flush(); 216 211 } 217 212 … … 221 216 int IFD_Towitoko_Close (IFD * ifd) 222 217 { 223 int ret;224 225 218 #ifdef USE_GPIO 226 219 if(gpio_detect) … … 242 235 } 243 236 244 int IFD_Towitoko_ActivateICC ( IFD * ifd)237 int IFD_Towitoko_ActivateICC () 245 238 { 246 239 #ifdef DEBUG_IFD … … 279 272 } 280 273 281 int IFD_Towitoko_DeactivateICC ( IFD * ifd)274 int IFD_Towitoko_DeactivateICC () 282 275 { 283 276 #ifdef DEBUG_IFD … … 311 304 312 305 //extern void print_hex_data(unsigned char *data, int len); 313 314 int IFD_Towitoko_ResetAsyncICC (IFD * ifd, ATR ** atr)315 {316 317 #ifdef DEBUG_IFD318 printf ("IFD: Resetting card:\n");319 #endif320 321 int ret;322 int parity;323 int i;324 int par[3] = {PARITY_EVEN, PARITY_ODD, PARITY_NONE};325 #ifdef HAVE_NANOSLEEP326 struct timespec req_ts;327 req_ts.tv_sec = 0;328 req_ts.tv_nsec = 50000000;329 #endif330 331 (*atr) = NULL;332 for(i=0; i<3; i++)333 {334 parity = par[i];335 IO_Serial_Flush();336 337 if (!IO_Serial_SetParity (parity))338 return IFD_TOWITOKO_IO_ERROR;339 340 ret = IFD_TOWITOKO_IO_ERROR;341 342 IO_Serial_Ioctl_Lock(1);343 #ifdef USE_GPIO344 if (gpio_detect)345 {346 set_gpio(0);347 set_gpio1(0);348 }349 else350 #endif351 IO_Serial_RTS_Set();352 353 #ifdef HAVE_NANOSLEEP354 nanosleep (&req_ts, NULL);355 #else356 usleep (50000L);357 #endif358 #ifdef USE_GPIO359 if (gpio_detect)360 {361 set_gpio_input();362 set_gpio1(1);363 }364 else365 #endif366 IO_Serial_RTS_Clr();367 368 IO_Serial_Ioctl_Lock(0);369 370 (*atr) = ATR_New ();371 372 if(ATR_InitFromStream ((*atr), IFD_TOWITOKO_ATR_TIMEOUT) == ATR_OK)373 ret = IFD_TOWITOKO_OK;374 375 /* Succesfully retrive ATR */376 if (ret == IFD_TOWITOKO_OK)377 {378 break;379 }380 else381 {382 ATR_Delete (*atr);383 (*atr) = NULL;384 #ifdef USE_GPIO385 if (gpio_detect) set_gpio1(0);386 #endif387 }388 }389 390 IO_Serial_Flush();391 392 /*393 //PLAYGROUND faking ATR for test purposes only394 //395 // sky 919 unsigned char atr_test[] = { 0x3F, 0xFF, 0x13, 0x25, 0x03, 0x10, 0x80, 0x33, 0xB0, 0x0E, 0x69, 0xFF, 0x4A, 0x50, 0x70, 0x00, 0x00, 0x49, 0x54, 0x02, 0x00, 0x00 };396 // HD+ unsigned char atr_test[] = { 0x3F, 0xFF, 0x95, 0x00, 0xFF, 0x91, 0x81, 0x71, 0xFE, 0x47, 0x00, 0x44, 0x4E, 0x41, 0x53, 0x50, 0x31, 0x34, 0x32, 0x20, 0x52, 0x65, 0x76, 0x47, 0x43, 0x34, 0x63 };397 // S02 = irdeto unsigned char atr_test[] = { 0x3B, 0x9F, 0x21, 0x0E, 0x49, 0x52, 0x44, 0x45, 0x54, 0x4F, 0x20, 0x41, 0x43, 0x53, 0x03};398 //cryptoworks unsigned char atr_test[] = { 0x3B, 0x78, 0x12, 0x00, 0x00, 0x65, 0xC4, 0x05, 0xFF, 0x8F, 0xF1, 0x90, 0x00 };399 ATR_Delete(*atr); //throw away actual ATR400 (*atr) = ATR_New ();401 ATR_InitFromArray ((*atr), atr_test, sizeof(atr_test));402 //END OF PLAYGROUND403 */404 405 return ret;406 }407 306 408 307 BYTE IFD_Towitoko_GetType (IFD * ifd) … … 495 394 static void IFD_Towitoko_Clear (IFD * ifd) 496 395 { 497 ifd->io = NULL;498 396 ifd->slot = 0x00; 499 397 ifd->type = 0x00;
Note:
See TracChangeset
for help on using the changeset viewer.