Changeset 1183


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

Move Coolstream Transmit,Receive,SetBaudrate to ifd_cool.c

Location:
trunk/csctapi
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/csctapi/icc_async.c

    r1182 r1183  
    266266}
    267267
    268 #ifdef COOL
    269 extern unsigned char cardbuffer[255];
    270 extern int cardbuflen;
    271 #endif
    272 
    273268int ICC_Async_Transmit (ICC_Async * icc, unsigned size, BYTE * data)
    274269{
     
    292287   
    293288#ifdef COOL
    294 //transmit buffer to SC and put answer in cardbuffer
    295289    if (icc->ifd->io->com == RTYP_SCI) {
    296 #define TIMEOUT 4000 //max 4294
    297     cardbuflen = 256;//it needs to know max buffer size to respond?
    298   if (cnxt_smc_read_write(handle, FALSE, sent, size, cardbuffer, &cardbuflen, TIMEOUT, 0))
    299         return ICC_ASYNC_IFD_ERROR;
    300 
    301 #ifdef DEBUG_IFD
    302   //usually done in IFD_Towitoko, for COOL do it here
    303     printf ("COOLIFD: Transmit: ");
    304     int i;
    305     for (i = 0; i < size; i++)
    306       printf ("%X ", sent[i]);
    307     printf ("\n");
    308 #endif
    309     }
    310     else
    311 #else
     290        if (!Cool_Transmit(sent, size))
     291            return ICC_ASYNC_IFD_ERROR;
     292    }
     293    else
     294#endif
    312295    if (IFD_Towitoko_Transmit (icc->ifd, &timings, size, sent) != IFD_TOWITOKO_OK)
    313296        return ICC_ASYNC_IFD_ERROR;
    314 #endif
    315297   
    316298    if (icc->convention == ATR_CONVENTION_INVERSE)
     
    328310   
    329311#ifdef COOL
    330 //receive  buffer to SC
    331     if (size > cardbuflen)
    332         size = cardbuflen; //never read past end of buffer
    333   memcpy(data,cardbuffer,size);
    334     cardbuflen -= size;
    335     memmove(cardbuffer,cardbuffer+size,cardbuflen);
    336 
    337 #ifdef DEBUG_IFD
    338   int i;
    339   printf ("COOLIFD: Receive: "); //I think
    340   for (i = 0; i < size; i++)
    341     printf ("%X ", data[i]);
    342   printf ("\n");
    343     fflush(stdout);
    344 #endif
    345   return ICC_ASYNC_OK;
     312    if (icc->ifd->io->com == RTYP_SCI) {
     313        if (!Cool_Receive(data, size))
     314            return ICC_ASYNC_IFD_ERROR;
     315    }
     316    else
    346317#else
    347318    if (IFD_Towitoko_Receive (icc->ifd, &timings, size, data) != IFD_TOWITOKO_OK)
  • trunk/csctapi/ifd_cool.c

    r1182 r1183  
    77#include <stdio.h>
    88#include <time.h>
     9#include <string.h>
    910#include"ifd_cool.h"
    10 
    11 // all other IFD_Towitoko functions should be
    12 // -eliminated (like SetLed or administrative jobs)
    13 // -rewritten eg. setparity should become a call to getproperties, setproperties
    14 // ActivateICC should call ResetICC automagically
    15 // DeactivateICC for symmetry and cleanup
    16 //
    1711
    1812#define OK      1
     
    5347    //state = 0 no card, 1 = not ready, 2 = ready
    5448    if (state)
    55       *in = 1; //CARD, even if not ready report card is in, or it will never get activated
     49        *in = 1; //CARD, even if not ready report card is in, or it will never get activated
    5650    else
    5751        *in = 0; //NOCARD
     
    6155int Cool_Reset (ATR ** atr)
    6256{
    63     //Cool_Reset(atr);
    64     //reset needs clock to be reset by hand
    65     typedef unsigned long u_int32;
    66     u_int32 clk;
    67     clk = 357*10000; // MHZ
    68     if (cnxt_smc_set_clock_freq(handle, clk))
     57    if (!Cool_SetBaudrate(357))
    6958        return ERROR;
    7059
     
    9584    }
    9685}
    97 /*
    98 int Cool_DeactivateICC ()
    99 {
    100 #ifdef DEBUG_IFD
    101     printf ("IFD: Deactivating card\n");
    102 #endif
    103 /*
    104         int in;
    105        
    106 #if defined(TUXBOX) && (defined(MIPSEL) || defined(PPC) || defined(SH4))
    107         if(ioctl(ifd->io->fd, IOCTL_GET_IS_CARD_PRESENT, &in)<0)
    108 #else
    109         if(ioctl(ifd->io->fd, IOCTL_GET_IS_CARD_ACTIVATED, &in)<0)
    110 #endif
    111             return IFD_TOWITOKO_IO_ERROR;
    112            
    113         if(in)
    114         {
    115             if(ioctl(ifd->io->fd, IOCTL_SET_DEACTIVATE)<0)
    116                 return IFD_TOWITOKO_IO_ERROR;
    117         }
    118 */     
    119 /*
    120     return OK;
    121 }
    122 */
    12386
    12487int Cool_Transmit (BYTE * sent, unsigned size)
     
    12689#define TIMEOUT 4000 //max 4294
    12790    cardbuflen = 256;//it needs to know max buffer size to respond?
    128     int rc = cnxt_smc_read_write(handle, FALSE, sent, size, cardbuffer, &cardbuflen, TIMEOUT, 0);
     91    if (cnxt_smc_read_write(handle, FALSE, sent, size, cardbuffer, &cardbuflen, TIMEOUT, 0))
     92        return ERROR;
    12993
    13094#ifdef DEBUG_IFD
     
    136100    printf ("\n");
    137101#endif
    138 
    139     //FIXME implement rc
     102    return OK;
    140103}
    141104
    142 int Cool_Receive (BYTE * buffer, unsigned size)
    143 { //receive buffer to SC
    144     //memcpy(buffer,cardbuffer,cardbuflen);
    145     //size = cardbuflen;
     105int Cool_Receive (BYTE * data, unsigned size)
     106{
     107    if (size > cardbuflen)
     108        size = cardbuflen; //never read past end of buffer
     109    memcpy(data,cardbuffer,size);
     110    cardbuflen -= size;
     111    memmove(cardbuffer,cardbuffer+size,cardbuflen);
    146112
    147113#ifdef DEBUG_IFD
    148114    int i;
    149     printf ("IFD: Receive: "); //I think
     115    printf ("COOLIFD: Receive: "); //I think
    150116    for (i = 0; i < size; i++)
    151         printf ("%X ", buffer[i]);
     117        printf ("%X ", data[i]);
    152118    printf ("\n");
     119    fflush(stdout);
    153120#endif
    154 
    155121    return OK;
    156122}   
     
    160126    typedef unsigned long u_int32;
    161127    u_int32 clk;
    162     //clk = 357 * 10000;        // MHZ
    163     clk = mhz * 10000;  // MHZ
     128    clk = mhz * 10000;
    164129    if (cnxt_smc_set_clock_freq (handle, clk))
    165130        return ERROR;
  • trunk/csctapi/pps.c

    r1171 r1183  
    471471#elif COOL
    472472    if(pps->icc->ifd->io->com==RTYP_SCI) {
    473         typedef unsigned long u_int32;
    474         u_int32 clk;
    475         clk = atr_fs_table[pps->parameters.FI];
    476         if (cnxt_smc_set_clock_freq(handle, clk))
    477             return ICC_ASYNC_IFD_ERROR;
    478 #ifdef DEBUG_PROTOCOL
    479         printf("Coolstream: set clock to %lu Hz\n", clk);
    480 #endif
    481         return ICC_ASYNC_OK;
     473        int mhz = atr_fs_table[pps->parameters.FI] / 10000;
     474        if (!Cool_SetBaudrate(mhz))
     475            return PPS_ICC_ERROR;
     476#ifdef DEBUG_PROTOCOL
     477        printf("Coolstream: set clock to %i * 10kHz\n", mhz);
     478#endif
     479        return PPS_OK;
    482480    }
    483481    else
Note: See TracChangeset for help on using the changeset viewer.