Changeset 1182


Ignore:
Timestamp:
01/11/10 12:11:53 (11 years ago)
Author:
dingo35
Message:

Move Coolstream Reset and Getstatus to ifd_cool.c

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/CMakeLists.txt

    r1178 r1182  
    202202elseif (OSCamOperatingSystem MATCHES "Tuxbox")
    203203    target_link_libraries ( ${exe_name} dl)
    204 elseif (OSCamOperatingSystem MATCHES "NeutrinoHD")
    205204elseif (OSCamOperatingSystem MATCHES "SlugOS")
    206205elseif (OSCamOperatingSystem MATCHES "Fonera2")
  • trunk/csctapi/icc_async.c

    r1179 r1182  
    7878        return ICC_ASYNC_IFD_ERROR;
    7979    /* Reset ICC */
     80#ifdef COOL
     81    if (ifd->io->com == RTYP_SCI) {
     82        if (!Cool_Reset(&(icc->atr)))
     83        {
     84            icc->atr = NULL;
     85            return ICC_ASYNC_IFD_ERROR;
     86        }
     87    }
     88    else
     89#endif
    8090    if (IFD_Towitoko_ResetAsyncICC (ifd, &(icc->atr)) != IFD_TOWITOKO_OK)
    8191    {
     
    8393        return ICC_ASYNC_IFD_ERROR;
    8494    }
    85    
    8695    /* Get ICC convention */
    8796    if (ATR_GetConvention (icc->atr, &(icc->convention)) != ATR_OK)
  • trunk/csctapi/ifd_cool.c

    r1171 r1182  
    88#include <time.h>
    99#include"ifd_cool.h"
    10 /*
    11 #include "io_serial.h"
    12 #include "sci_global.h"
    13 #include "sci_ioctl.h"
    14 */
    1510
    16 // these should be called from icc, t0, cardterminal etc. like this:
    17 // switch (reader[ridx].type) {
    18 //   case INTERN:
    19 // #ifdef COOL
    20 //       Cool_Init();
    21 //       break;
    22 // #endif
    23 // #ifdef SCI_DEV
    24 // //still in towitoko shit
    25 // #endif
    26 //   case SMART:
    27 //   case MOUSE:
    28 //       IFD_Towitoko_Init(ifd, io, slot);
    29 //       break;
    30 //   default:
    31 //       return ERROR;
    32 // }
    3311// all other IFD_Towitoko functions should be
    3412// -eliminated (like SetLed or administrative jobs)
     
    4826int Cool_Init ()
    4927{
    50     //initialize properties(input_bitrate, output_bitrate, bits, stopbits, parity,dtr, rts) of device to default values
    51     //initialize ifd settings
    52     //and get reader info
    5328    if (cnxt_kal_initialize ())
    5429        return FALSE;
     
    7045}
    7146
    72 /*
    73 int Cool_GetStatus (BYTE * result)
    74 {
    75 // return status : 0 -start, 1 - card, 2- no card
    7647
    77     //extern int cnxt_smc_get_state();
     48int Cool_GetStatus (int * in)
     49{
     50    int state;
     51    if (cnxt_smc_get_state(handle, &state))
     52        return ERROR;
     53    //state = 0 no card, 1 = not ready, 2 = ready
     54    if (state)
     55      *in = 1; //CARD, even if not ready report card is in, or it will never get activated
     56    else
     57        *in = 0; //NOCARD
    7858    return OK;
    7959}
    80 */
     60
    8161int Cool_Reset (ATR ** atr)
    8262{
    83 printf("Entering coolreset");
    84 fflush(stdout);
     63    //Cool_Reset(atr);
    8564    //reset needs clock to be reset by hand
    8665    typedef unsigned long u_int32;
     
    9675
    9776    int n = 40;
    98     //int atr_len = 40;
    9977    unsigned char buf[40];
    10078    if (cnxt_smc_get_atr (handle, buf, &n))
    10179        return ERROR;
    102     //atr_len = n;
    103 //  atr = buf;
    104     /////////////
    105         (*atr) = ATR_New ();
    106         if(ATR_InitFromArray ((*atr), buf, n) == ATR_OK)
    107         {
    108             struct timespec req_ts;
    109             req_ts.tv_sec = 0;
    110             req_ts.tv_nsec = 50000000;
    111             nanosleep (&req_ts, NULL);
    112 #ifdef SCI_DEV
    113             if (ioctl(ifd->io->fd, IOCTL_SET_ATR_READY)<0)
    114                 return ERROR;
    115 #endif
    116             return OK;
    117         }
    118         else
    119         {
    120             ATR_Delete (*atr);
    121             (*atr) = NULL;
    122             return ERROR;
    123         }
    124     ///////////
     80       
     81    (*atr) = ATR_New ();
     82    if(ATR_InitFromArray ((*atr), buf, n) == ATR_OK)
     83    {
     84        struct timespec req_ts;
     85        req_ts.tv_sec = 0;
     86        req_ts.tv_nsec = 50000000;
     87        nanosleep (&req_ts, NULL);
     88        return OK;
     89    }
     90    else
     91    {
     92        ATR_Delete (*atr);
     93        (*atr) = NULL;
     94        return ERROR;
     95    }
    12596}
    12697/*
     
    155126#define TIMEOUT 4000 //max 4294
    156127    cardbuflen = 256;//it needs to know max buffer size to respond?
    157   int rc = cnxt_smc_read_write(handle, FALSE, sent, size, cardbuffer, &cardbuflen, TIMEOUT, 0);
     128    int rc = cnxt_smc_read_write(handle, FALSE, sent, size, cardbuffer, &cardbuflen, TIMEOUT, 0);
    158129
    159130#ifdef DEBUG_IFD
    160   //usually done in IFD_Towitoko, for COOL do it here
     131    //usually done in IFD_Towitoko, for COOL do it here
    161132    printf ("COOLIFD: Transmit: ");
    162133    int i;
    163134    for (i = 0; i < size; i++)
    164       printf ("%X ", sent[i]);
     135        printf ("%X ", sent[i]);
    165136    printf ("\n");
    166137#endif
  • trunk/csctapi/ifd_towitoko.c

    r1171 r1182  
    364364#elif COOL
    365365    if(ifd->io->com==RTYP_SCI)
    366     {
    367     //  in=1;//FIXME
    368         int state;
    369         if (cnxt_smc_get_state(handle, &state))
    370             return IFD_TOWITOKO_IO_ERROR;
    371         //guessing: state = 0 no card, 1 = not ready, 2 = ready
    372         if (state)
    373           in = 1; //CARD, even if not ready report card is in, or it will never get activated
    374         else
    375             in = 0; //Nocard
     366    {   
     367        if (!Cool_GetStatus(&in))
     368            return IFD_TOWITOKO_IO_ERROR;
    376369    }
    377370    else
     
    627620        if(n==0)
    628621            return IFD_TOWITOKO_IO_ERROR;
    629 #elif COOL
    630     if(ifd->io->com==RTYP_SCI) {
    631         //Cool_Reset(atr);
    632         //reset needs clock to be reset by hand
    633         typedef unsigned long u_int32;
    634         u_int32 clk;
    635         clk = 357*10000; // MHZ
    636         if (cnxt_smc_set_clock_freq(handle, clk))
    637             return IFD_TOWITOKO_IO_ERROR;
     622#endif
    638623           
    639         //reset card
    640         int timeout = 5000; // Timout in ms?
    641         if (cnxt_smc_reset_card (handle, timeout, NULL, NULL))
    642             return IFD_TOWITOKO_IO_ERROR;
    643 
    644         int n = 40;
    645         unsigned char buf[40];
    646         if (cnxt_smc_get_atr (handle, buf, &n))
    647             return IFD_TOWITOKO_IO_ERROR;
    648 #endif
    649            
    650 #if defined(SCI_DEV) || defined(COOL)
     624#ifdef SCI_DEV
    651625        (*atr) = ATR_New ();
    652626        if(ATR_InitFromArray ((*atr), buf, n) == ATR_OK)
Note: See TracChangeset for help on using the changeset viewer.