Changeset 1228 for branches/monitor-improvement/csctapi/ifd_towitoko.c
- Timestamp:
- 01/14/10 19:07:30 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/monitor-improvement/csctapi/ifd_towitoko.c
r1210 r1228 343 343 int IFD_Towitoko_SetLED () 344 344 { 345 return IFD_TOWITOKO_OK;346 }347 348 int IFD_Towitoko_GetStatus (IFD * ifd, BYTE * result)349 {350 BYTE status[2];351 unsigned int modembits=0;352 int in;353 354 // printf("\n%08X\n", (int)ifd->io);355 356 // status : 0 -start, 1 - card, 2- no card357 358 #ifdef SCI_DEV359 if(ifd->io->reader_type==R_INTERNAL)360 {361 if(!Sci_GetStatus(ifd->io->fd, &in))362 return IFD_TOWITOKO_IO_ERROR;363 }364 else365 #elif COOL366 if(ifd->io->reader_type==R_INTERNAL)367 {368 if (!Cool_GetStatus(&in))369 return IFD_TOWITOKO_IO_ERROR;370 }371 else372 #endif373 374 #if defined(TUXBOX) && defined(PPC)375 if ((ifd->io->reader_type==R_DB2COM1) || (ifd->io->reader_type==R_DB2COM2))376 {377 ushort msr=1;378 extern int fdmc;379 IO_Serial_Ioctl_Lock(ifd->io, 1);380 ioctl(fdmc, GET_PCDAT, &msr);381 if (ifd->io->reader_type==R_DB2COM2)382 in=(!(msr & 1));383 else384 in=((msr & 0x0f00) == 0x0f00);385 IO_Serial_Ioctl_Lock(ifd->io, 0);386 }387 else388 #endif389 #ifdef USE_GPIO390 if (gpio_detect)391 in=get_gpio();392 else393 #endif394 {395 extern int oscam_card_detect;396 if (ioctl(ifd->io->fd, TIOCMGET,&modembits)<0)397 return IFD_TOWITOKO_IO_ERROR;398 switch(oscam_card_detect&0x7f)399 {400 case 0: in=(modembits & TIOCM_CAR); break;401 case 1: in=(modembits & TIOCM_DSR); break;402 case 2: in=(modembits & TIOCM_CTS); break;403 case 3: in=(modembits & TIOCM_RNG); break;404 default: in=0; // dummy405 }406 if (!(oscam_card_detect&0x80))407 in=!in;408 }409 410 if (in)411 {412 if(ifd->status == 0)413 {414 status[0] = IFD_TOWITOKO_CARD_CHANGE;415 ifd->status = 1;416 #ifdef USE_GPIO417 if (gpio_detect) set_gpio1(0);418 #endif419 }420 else if(ifd->status == 1)421 {422 status[0] = IFD_TOWITOKO_CARD_NOCHANGE;423 }424 else425 {426 status[0] = IFD_TOWITOKO_CARD_CHANGE;427 ifd->status = 1;428 #ifdef USE_GPIO429 if (gpio_detect) set_gpio1(0);430 #endif431 }432 }433 else434 {435 if(ifd->status == 0)436 {437 status[0] = IFD_TOWITOKO_NOCARD_CHANGE;438 ifd->status = 2;439 #ifdef USE_GPIO440 if (gpio_detect) set_gpio1(1);441 #endif442 }443 else if(ifd->status == 1)444 {445 status[0] = IFD_TOWITOKO_NOCARD_CHANGE;446 ifd->status = 2;447 #ifdef USE_GPIO448 if (gpio_detect) set_gpio1(1);449 #endif450 }451 else452 {453 status[0] = IFD_TOWITOKO_NOCARD_NOCHANGE;454 }455 }456 457 458 (*result) = status[0];459 460 #ifdef DEBUG_IFD461 printf ("IFD: com%d Status = %s / %s\n", ifd->io->reader_type, IFD_TOWITOKO_CARD(status[0])? "card": "no card", IFD_TOWITOKO_CHANGE(status[0])? "change": "no change");462 #endif463 464 345 return IFD_TOWITOKO_OK; 465 346 } … … 556 437 { 557 438 parity = par[i]; 558 IO_Serial_Flush( ifd->io);439 IO_Serial_Flush(); 559 440 560 441 ret = IFD_Towitoko_SetParity (ifd, parity); … … 564 445 ret = IFD_TOWITOKO_IO_ERROR; 565 446 566 IO_Serial_Ioctl_Lock( ifd->io,1);447 IO_Serial_Ioctl_Lock(1); 567 448 #ifdef USE_GPIO 568 449 if (gpio_detect) … … 590 471 IO_Serial_RTS_Clr(ifd->io); 591 472 592 IO_Serial_Ioctl_Lock( ifd->io,0);473 IO_Serial_Ioctl_Lock(0); 593 474 594 475 (*atr) = ATR_New (); 595 476 596 if(ATR_InitFromStream ((*atr), ifd->io,IFD_TOWITOKO_ATR_TIMEOUT) == ATR_OK)477 if(ATR_InitFromStream ((*atr), IFD_TOWITOKO_ATR_TIMEOUT) == ATR_OK) 597 478 ret = IFD_TOWITOKO_OK; 598 479 … … 612 493 } 613 494 614 IO_Serial_Flush(ifd->io); 615 #ifndef NO_PAR_SWITCH 616 IFD_Towitoko_SetParity (ifd, IFD_TOWITOKO_PARITY_NONE); 617 #endif 495 IO_Serial_Flush(); 618 496 619 497 /* … … 660 538 if ((sent == 0) && (block_delay != char_delay)) 661 539 { 662 if (!IO_Serial_Write ( ifd->io,block_delay, 1, buffer))540 if (!IO_Serial_Write (block_delay, 1, buffer)) 663 541 return IFD_TOWITOKO_IO_ERROR; 664 542 665 if (!IO_Serial_Write ( ifd->io,char_delay, to_send-1, buffer+1))543 if (!IO_Serial_Write (char_delay, to_send-1, buffer+1)) 666 544 return IFD_TOWITOKO_IO_ERROR; 667 545 } 668 546 else 669 547 { 670 if (!IO_Serial_Write ( ifd->io,char_delay, to_send, buffer+sent))548 if (!IO_Serial_Write (char_delay, to_send, buffer+sent)) 671 549 return IFD_TOWITOKO_IO_ERROR; 672 550 } … … 694 572 { 695 573 /* Read first byte using block timeout */ 696 if (!IO_Serial_Read ( ifd->io,block_timeout, 1, buffer))574 if (!IO_Serial_Read (block_timeout, 1, buffer)) 697 575 return IFD_TOWITOKO_IO_ERROR; 698 576 … … 700 578 { 701 579 /* Read remaining data bytes using char timeout */ 702 if (!IO_Serial_Read ( ifd->io,char_timeout, size - 1, buffer + 1))580 if (!IO_Serial_Read (char_timeout, size - 1, buffer + 1)) 703 581 return IFD_TOWITOKO_IO_ERROR; 704 582 } … … 707 585 { 708 586 /* Read all data bytes with the same timeout */ 709 if (!IO_Serial_Read ( ifd->io,char_timeout, size, buffer))587 if (!IO_Serial_Read (char_timeout, size, buffer)) 710 588 return IFD_TOWITOKO_IO_ERROR; 711 589 } … … 824 702 ifd->type = 0x00; 825 703 ifd->firmware = 0x00; 826 ifd->status = 0;827 } 704 reader[ridx].status = 0; 705 }
Note:
See TracChangeset
for help on using the changeset viewer.