Ignore:
Timestamp:
01/14/10 19:07:30 (13 years ago)
Author:
alno
Message:

WebIf:

  • Command: Merging revisions 1212-1227 of trunk
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/monitor-improvement/csctapi/ifd_towitoko.c

    r1210 r1228  
    343343int IFD_Towitoko_SetLED ()
    344344{   
    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 card
    357 
    358 #ifdef SCI_DEV
    359     if(ifd->io->reader_type==R_INTERNAL)
    360     {
    361         if(!Sci_GetStatus(ifd->io->fd, &in))
    362             return IFD_TOWITOKO_IO_ERROR;           
    363     }
    364     else
    365 #elif COOL
    366     if(ifd->io->reader_type==R_INTERNAL)
    367     {   
    368         if (!Cool_GetStatus(&in))
    369             return IFD_TOWITOKO_IO_ERROR;
    370     }
    371     else
    372 #endif
    373 
    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         else
    384             in=((msr & 0x0f00) == 0x0f00);
    385         IO_Serial_Ioctl_Lock(ifd->io, 0);
    386     }
    387     else
    388 #endif
    389 #ifdef USE_GPIO
    390     if (gpio_detect)
    391         in=get_gpio();
    392     else
    393 #endif
    394     {
    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;      // dummy
    405         }
    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_GPIO
    417             if (gpio_detect) set_gpio1(0);
    418 #endif
    419         }
    420         else if(ifd->status == 1)
    421         {
    422             status[0] = IFD_TOWITOKO_CARD_NOCHANGE;
    423         }
    424         else
    425         {
    426             status[0] = IFD_TOWITOKO_CARD_CHANGE;
    427             ifd->status = 1;
    428 #ifdef USE_GPIO
    429             if (gpio_detect) set_gpio1(0);
    430 #endif
    431         }
    432     }
    433     else
    434     {
    435         if(ifd->status == 0)
    436         {
    437             status[0] = IFD_TOWITOKO_NOCARD_CHANGE;
    438             ifd->status = 2;
    439 #ifdef USE_GPIO
    440             if (gpio_detect) set_gpio1(1);
    441 #endif
    442         }
    443         else if(ifd->status == 1)
    444         {
    445             status[0] = IFD_TOWITOKO_NOCARD_CHANGE;
    446             ifd->status = 2;
    447 #ifdef USE_GPIO
    448             if (gpio_detect) set_gpio1(1);
    449 #endif
    450         }
    451         else
    452         {
    453             status[0] = IFD_TOWITOKO_NOCARD_NOCHANGE;
    454         }
    455     }
    456    
    457        
    458     (*result) = status[0];
    459    
    460 #ifdef DEBUG_IFD
    461     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 #endif
    463    
    464345    return IFD_TOWITOKO_OK;
    465346}
     
    556437        {
    557438            parity = par[i];
    558             IO_Serial_Flush(ifd->io);
     439            IO_Serial_Flush();
    559440
    560441            ret = IFD_Towitoko_SetParity (ifd, parity);
     
    564445            ret = IFD_TOWITOKO_IO_ERROR;
    565446
    566             IO_Serial_Ioctl_Lock(ifd->io, 1);
     447            IO_Serial_Ioctl_Lock(1);
    567448#ifdef USE_GPIO
    568449            if (gpio_detect)
     
    590471                IO_Serial_RTS_Clr(ifd->io);
    591472           
    592             IO_Serial_Ioctl_Lock(ifd->io, 0);
     473            IO_Serial_Ioctl_Lock(0);
    593474
    594475            (*atr) = ATR_New ();
    595476
    596             if(ATR_InitFromStream ((*atr), ifd->io, IFD_TOWITOKO_ATR_TIMEOUT) == ATR_OK)
     477            if(ATR_InitFromStream ((*atr), IFD_TOWITOKO_ATR_TIMEOUT) == ATR_OK)
    597478                ret = IFD_TOWITOKO_OK;
    598479
     
    612493        }
    613494   
    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();
    618496
    619497/*
     
    660538        if ((sent == 0) && (block_delay != char_delay))
    661539        {
    662             if (!IO_Serial_Write (ifd->io, block_delay, 1, buffer))
     540            if (!IO_Serial_Write (block_delay, 1, buffer))
    663541                return IFD_TOWITOKO_IO_ERROR;
    664542           
    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))
    666544                return IFD_TOWITOKO_IO_ERROR;
    667545        }
    668546        else
    669547        {
    670             if (!IO_Serial_Write (ifd->io, char_delay, to_send, buffer+sent))
     548            if (!IO_Serial_Write (char_delay, to_send, buffer+sent))
    671549                return IFD_TOWITOKO_IO_ERROR;
    672550        }
     
    694572    {
    695573        /* 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))
    697575            return IFD_TOWITOKO_IO_ERROR;
    698576       
     
    700578        {
    701579            /* 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))
    703581                return IFD_TOWITOKO_IO_ERROR;
    704582        }
     
    707585    {
    708586        /* 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))
    710588            return IFD_TOWITOKO_IO_ERROR;
    711589    }
     
    824702    ifd->type = 0x00;
    825703    ifd->firmware = 0x00;
    826     ifd->status = 0;
    827 }
     704    reader[ridx].status = 0;
     705}
Note: See TracChangeset for help on using the changeset viewer.