Changeset 1208


Ignore:
Timestamp:
01/13/10 16:47:27 (11 years ago)
Author:
dingo35
Message:

Integrate the two different reader_type mechanisms

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/csctapi/cardterminal.c

    r1160 r1208  
    7171}
    7272
    73 char CardTerminal_Init (CardTerminal * ct, unsigned short pn, int reader_type, int mhz, int cardmhz)
     73char CardTerminal_Init (CardTerminal * ct, int reader_type, int mhz, int cardmhz)
    7474{
    7575    char ret;
    7676    int i;
    77     bool usbserial;
    7877   
    7978    /* Create a new IO_Serial */
    80     ct->io = IO_Serial_New (reader_type, mhz, cardmhz);
     79    ct->io = IO_Serial_New (mhz, cardmhz);
    8180   
    8281    /* Memory error */
     
    8483        return ERR_MEMORY;
    8584   
    86     /*
    87     * Handle USB port numbers: first USB serial port starts at 0x8000,
    88     * 0x8001 if CTAPI_WIN32_COM is set
    89     */
    90     if ((pn & 0x8000) == 0x8000)
    91     {
    92         usbserial = TRUE;
    93         pn &= 0x7FFF;
    94     }
    95     else
    96     {
    97         usbserial = FALSE;
    98     }
    99    
    10085    /* Initialise serial port */
    101     if (!IO_Serial_Init (ct->io, pn + 1, usbserial))
     86    if (!IO_Serial_Init (ct->io, reader_type))
    10287    {
    10388        free (ct->io);
  • trunk/csctapi/cardterminal.h

    r1160 r1208  
    6868/* Intialice a CardTerminal in a given port */
    6969extern char
    70 CardTerminal_Init (CardTerminal * ct, unsigned short pn, int reader_type, int mhz, int cardmhz);
     70CardTerminal_Init (CardTerminal * ct, int reader_type, int mhz, int cardmhz);
    7171
    7272/* Send a CT-BCS command to a CardTerminal */
  • trunk/csctapi/ctapi.c

    r615 r1208  
    5050 */
    5151
    52 char CT_init (unsigned short ctn, unsigned short pn, int reader_type, int mhz, int cardmhz)
     52char CT_init (unsigned short ctn, int reader_type, int mhz, int cardmhz)
    5353{
    5454    CardTerminal *ct;
     
    6969        {   
    7070            /* Initialize CardTerminal */
    71             ret = CardTerminal_Init (ct, pn, reader_type, mhz, cardmhz);
     71            ret = CardTerminal_Init (ct, reader_type, mhz, cardmhz);
    7272           
    7373            /* Add CardTerminal to list */
  • trunk/csctapi/ctapi.h

    r615 r1208  
    2121extern char CT_init (
    2222      unsigned short Ctn,                  /* Terminal Number */
    23       unsigned short pn,                    /* Port Number */
    2423      int reader_type,                      /* reader type (mouse, smartreader) */
    2524      int mhz,
     
    4948#define ERR_HTSI        -128             /* HTSI Error */
    5049
    51 #define PORT_COM1      0             /* COM 1 */
    52 #define PORT_COM2      1             /* COM 2 */
    53 #define PORT_COM3      2             /* COM 3 */
    54 #define PORT_COM4      3             /* COM 4 */
    55 #define PORT_Printer       4             /* Printer Port (MAC) */
    56 #define PORT_Modem         5             /* Modem Port (MAC)   */
    57 #define PORT_LPT1      6             /* LPT 1 */
    58 #define PORT_LPT2      7             /* LPT 2 */
    59 
    6050    /* #define DAD */
    6151#define CARD            0
    6252#define CT              1
    6353#define HOST            2
    64 
    65     /* #define port-types */
    66 #define PORT_STD    PORT_COM1
    67 #define PORT_SCI    PORT_COM2
    68 #define PORT_DB2COM1    PORT_COM3
    69 #define PORT_DB2COM2    PORT_COM4
    7054
    7155#ifdef __cplusplus
  • trunk/csctapi/defines.h

    r957 r1208  
    8989#endif
    9090
    91 #define RTYP_STD    1
    92 #define RTYP_SCI    2
    93 #define RTYP_DB2COM1    3
    94 #define RTYP_DB2COM2    4
    95 #define RTYP_SMART  5
    9691#endif /* DEFINES_H */
  • trunk/csctapi/icc_async.c

    r1205 r1208  
    7979    /* Reset ICC */
    8080#ifdef SCI_DEV
    81     if (ifd->io->com == RTYP_SCI) {
     81    if (ifd->io->reader_type == R_INTERNAL) {
    8282        if (!Sci_Reset(ifd, &(icc->atr)))
    8383        {
     
    8989#endif
    9090#ifdef COOL
    91     if (ifd->io->com == RTYP_SCI) {
     91    if (ifd->io->reader_type == R_INTERNAL) {
    9292        if (!Cool_Reset(&(icc->atr)))
    9393        {
     
    159159    }
    160160#ifdef COOL
    161     if (icc->ifd->io->com != RTYP_SCI)
     161    if (icc->ifd->io->reader_type != R_INTERNAL)
    162162#endif
    163163    IO_Serial_Flush(ifd->io);
     
    184184#include "sci_global.h"
    185185#include "sci_ioctl.h"
    186     if (icc->ifd->io->com == RTYP_SCI) {
     186    if (icc->ifd->io->reader_type == R_INTERNAL) {
    187187        SCI_PARAMETERS params;
    188188        if (ioctl(icc->ifd->io->fd, IOCTL_GET_PARAMETERS, &params) < 0 )
     
    223223    icc->baudrate = baudrate;
    224224/*#ifdef COOL
    225     if (icc->ifd->io->com==RTYP_SCI) {
     225    if (icc->ifd->io->reader_type==R_INTERNAL) {
    226226    typedef unsigned long u_int32;
    227227    u_int32 clk;
     
    281281    IFD_Timings timings;
    282282   
    283     if (icc->convention == ATR_CONVENTION_INVERSE && icc->ifd->io->com!=RTYP_SCI)
     283    if (icc->convention == ATR_CONVENTION_INVERSE && icc->ifd->io->reader_type != R_INTERNAL)
    284284    {
    285285        buffer = (BYTE *) calloc(sizeof (BYTE), size);
     
    297297   
    298298#ifdef COOL
    299     if (icc->ifd->io->com == RTYP_SCI) {
     299    if (icc->ifd->io->reader_type == R_INTERNAL) {
    300300        if (!Cool_Transmit(sent, size))
    301301            return ICC_ASYNC_IFD_ERROR;
     
    320320   
    321321#ifdef COOL
    322     if (icc->ifd->io->com == RTYP_SCI) {
     322    if (icc->ifd->io->reader_type == R_INTERNAL) {
    323323        if (!Cool_Receive(data, size))
    324324            return ICC_ASYNC_IFD_ERROR;
     
    330330#endif
    331331   
    332     if (icc->convention == ATR_CONVENTION_INVERSE && icc->ifd->io->com!=RTYP_SCI)
     332    if (icc->convention == ATR_CONVENTION_INVERSE && icc->ifd->io->reader_type!=R_INTERNAL)
    333333        ICC_Async_InvertBuffer (size, data);
    334334   
  • trunk/csctapi/ifd_towitoko.c

    r1205 r1208  
    4848#include "sci_ioctl.h"
    4949#include "ifd.h"
     50#include "../globals.h"
    5051
    5152/*
     
    163164   
    164165#ifdef DEBUG_IFD
    165     printf ("IFD: Initializing slot number %d, com=%d\n", slot, io->com);
     166    printf ("IFD: Initializing slot number %d, com=%d\n", slot, io->reader_type);
    166167#endif
    167168   
     
    170171        return IFD_TOWITOKO_PARAM_ERROR;
    171172       
    172     if(io->com==RTYP_SCI)
     173    if(io->reader_type==R_INTERNAL)
    173174    {
    174175        ifd->io = io;
     
    259260int IFD_Towitoko_SetBaudrate (IFD * ifd, unsigned long baudrate)
    260261{
    261     if(ifd->io->com==RTYP_SCI)
     262    if(ifd->io->reader_type==R_INTERNAL)
    262263    {
    263264        return IFD_TOWITOKO_OK;
     
    295296int IFD_Towitoko_GetBaudrate (IFD * ifd, unsigned long *baudrate)
    296297{
    297     if(ifd->io->com==RTYP_SCI)
     298    if(ifd->io->reader_type==R_INTERNAL)
    298299    {
    299300        return IFD_TOWITOKO_OK;
     
    311312extern int IFD_Towitoko_SetParity (IFD * ifd, BYTE parity)
    312313{
    313     if(ifd->io->com==RTYP_SCI)
     314    if(ifd->io->reader_type==R_INTERNAL)
    314315    {
    315316        return IFD_TOWITOKO_OK;
     
    356357
    357358#ifdef SCI_DEV
    358     if(ifd->io->com==RTYP_SCI)
     359    if(ifd->io->reader_type==R_INTERNAL)
    359360    {
    360361        if(!Sci_GetStatus(ifd->io->fd, &in))
     
    363364    else
    364365#elif COOL
    365     if(ifd->io->com==RTYP_SCI)
     366    if(ifd->io->reader_type==R_INTERNAL)
    366367    {   
    367368        if (!Cool_GetStatus(&in))
     
    372373
    373374#if defined(TUXBOX) && defined(PPC)
    374     if ((ifd->io->com==RTYP_DB2COM1) || (ifd->io->com==RTYP_DB2COM2))
     375    if ((ifd->io->reader_type==R_DB2COM1) || (ifd->io->reader_type==R_DB2COM2))
    375376    {
    376377        ushort msr=1;
     
    378379        IO_Serial_Ioctl_Lock(ifd->io, 1);
    379380        ioctl(fdmc, GET_PCDAT, &msr);
    380         if (ifd->io->com==RTYP_DB2COM2)
     381        if (ifd->io->reader_type==R_DB2COM2)
    381382            in=(!(msr & 1));
    382383        else
     
    458459   
    459460#ifdef DEBUG_IFD
    460     printf ("IFD: com%d Status = %s / %s\n", ifd->io->com, IFD_TOWITOKO_CARD(status[0])? "card": "no card", IFD_TOWITOKO_CHANGE(status[0])? "change": "no change");
     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");
    461462#endif
    462463   
     
    470471#endif
    471472#ifdef SCI_DEV
    472     if(ifd->io->com==RTYP_SCI)
     473    if(ifd->io->reader_type==R_INTERNAL)
    473474    {
    474475        int in;
     
    508509
    509510#ifdef SCI_DEV
    510     if(ifd->io->com==RTYP_SCI)
     511    if(ifd->io->reader_type==R_INTERNAL)
    511512    {
    512513        int in;
  • trunk/csctapi/io_serial.c

    r1185 r1208  
    7979{
    8080  extern int *oscam_sem;
    81   if ((io->com!=RTYP_DB2COM1) && (io->com!=RTYP_DB2COM2)) return;
     81  if ((io->reader_type!=R_DB2COM1) && (io->reader_type!=R_DB2COM2)) return;
    8282  if (!flag)
    8383    *oscam_sem=0;
    84   else while (*oscam_sem!=io->com)
     84  else while (*oscam_sem!=io->reader_type)
    8585  {
    8686    while (*oscam_sem)
    87     usleep((io->com)*2000);
    88     *oscam_sem=io->com;
     87    usleep((io->reader_type)*2000);
     88    *oscam_sem=io->reader_type;
    8989    usleep(1000);
    9090  }
     
    136136
    137137#if defined(TUXBOX) && defined(PPC)
    138     if ((io->com==RTYP_DB2COM1) || (io->com==RTYP_DB2COM2))
    139         return(IO_Serial_DTR_RTS_dbox2(io->com==RTYP_DB2COM2, dtr, set));
     138    if ((io->reader_type==R_DB2COM1) || (io->reader_type==R_DB2COM2))
     139        return(IO_Serial_DTR_RTS_dbox2(io->reader_type==R_DB2COM2, dtr, set));
    140140#endif
    141141
     
    159159 */
    160160
    161 IO_Serial * IO_Serial_New (int reader_type, int mhz, int cardmhz)
     161IO_Serial * IO_Serial_New (int mhz, int cardmhz)
    162162{
    163163    IO_Serial *io;
     
    168168        IO_Serial_Clear (io);
    169169   
    170     io->reader_type=reader_type;
    171170    io->mhz=mhz;
    172171    io->cardmhz=cardmhz;
     
    175174}
    176175
    177 bool IO_Serial_Init (IO_Serial * io, unsigned com, bool usbserial)
     176bool IO_Serial_Init (IO_Serial * io, int reader_type)
    178177{
    179178    char filename[IO_SERIAL_FILENAME_LENGTH];
     
    185184#endif
    186185   
    187     if (com < 1)
    188         return FALSE;
    189    
    190     io->com = com;
     186    io->reader_type = reader_type;
    191187
    192188#if defined(SCI_DEV) || defined(COOL)
    193     if (com==RTYP_SCI)
     189    if (com==R_INTERNAL)
    194190#ifdef SH4
    195191        io->fd = open (filename, O_RDWR|O_NONBLOCK|O_NOCTTY);
     
    216212
    217213#if defined(TUXBOX) && defined(PPC)
    218     if ((com==RTYP_DB2COM1) || (com==RTYP_DB2COM2))
     214    if ((reader_type == R_DB2COM1) || (reader_type == R_DB2COM2))
    219215        if ((fdmc = open(DEV_MULTICAM, O_RDWR)) < 0)
    220216        {
     
    224220#endif
    225221   
    226     if (com!=RTYP_SCI)
     222    if (reader_type != R_INTERNAL)
    227223        IO_Serial_InitPnP (io);
    228224   
    229     io->usbserial=usbserial;
    230    
    231     if(io->com!=RTYP_SCI)
     225    if(io->reader_type!=R_INTERNAL)
    232226        IO_Serial_Flush(io);
    233227       
     
    242236
    243237#ifdef SCI_DEV
    244     if(io->com==RTYP_SCI)
     238    if(io->reader_type==R_INTERNAL)
    245239        return FALSE;
    246240#endif
     
    511505   
    512506#ifdef SCI_DEV
    513    if(io->com==RTYP_SCI)
     507   if(io->reader_type==R_INTERNAL)
    514508      return FALSE;
    515509#endif
    516510   
    517    //   printf("IO: Setting properties: com%d, %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", io->com, io->input_bitrate, io->bits, io->parity == IO_SERIAL_PARITY_EVEN ? "Even" : io->parity == IO_SERIAL_PARITY_ODD ? "Odd" : "None", io->stopbits, io->dtr, io->rts);
     511   //   printf("IO: Setting properties: com%d, %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", io->reader_type, io->input_bitrate, io->bits, io->parity == IO_SERIAL_PARITY_EVEN ? "Even" : io->parity == IO_SERIAL_PARITY_ODD ? "Odd" : "None", io->stopbits, io->dtr, io->rts);
    518512   memset (&newtio, 0, sizeof (newtio));
    519513
     
    621615   
    622616#ifdef DEBUG_IO
    623     printf("IO: Setting properties: com%d, %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", io->com, io->input_bitrate, io->bits, io->parity == IO_SERIAL_PARITY_EVEN ? "Even" : io->parity == IO_SERIAL_PARITY_ODD ? "Odd" : "None", io->stopbits, io->dtr, io->rts);
     617    printf("IO: Setting properties: com%d, %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", io->reader_type, io->input_bitrate, io->bits, io->parity == IO_SERIAL_PARITY_EVEN ? "Even" : io->parity == IO_SERIAL_PARITY_ODD ? "Odd" : "None", io->stopbits, io->dtr, io->rts);
    624618#endif
    625619    return TRUE;
     
    641635unsigned IO_Serial_GetCom (IO_Serial * io)
    642636{
    643     return io->com;
     637    return io->reader_type;
    644638}
    645639
     
    654648#endif
    655649   
    656     if((io->com!=RTYP_SCI) && (io->wr>0))
     650    if((io->reader_type!=R_INTERNAL) && (io->wr>0))
    657651    {
    658652        BYTE buf[256];
     
    750744    for (count = 0; count < size; count += to_send)
    751745    {
    752 //      if(io->com==RTYP_SCI)
     746//      if(io->reader_type==R_INTERNAL)
    753747//          to_send = 1;
    754748//      else
     
    771765                fflush (stdout);
    772766#endif
    773                 if(io->com!=RTYP_SCI)
     767                if(io->reader_type!=R_INTERNAL)
    774768                    io->wr += u;
    775769                return FALSE;
    776770            }
    777771           
    778             if(io->com!=RTYP_SCI)
     772            if(io->reader_type!=R_INTERNAL)
    779773                io->wr += to_send;
    780774           
     
    951945   
    952946#ifdef SCI_DEV
    953    if(io->com==RTYP_SCI)
     947   if(io->reader_type==R_INTERNAL)
    954948      return TRUE;
    955949#endif
     
    1004998{
    1005999    io->fd = -1;
    1006     io->com = 0;
     1000    io->reader_type = 0;
    10071001    memset (io->PnP_id, 0, IO_SERIAL_PNPID_SIZE);
    10081002    io->PnP_id_size = 0;
    1009     io->usbserial = FALSE;
    10101003    io->wr = 0;
    10111004    //modifyable properties:
  • trunk/csctapi/io_serial.h

    r1185 r1208  
    6565    int rts;   
    6666    /* end settings that can be modified */
    67     unsigned com;               /* Com port number (1..4) */
     67    int reader_type;
    6868    BYTE PnP_id[IO_SERIAL_PNPID_SIZE];  /* PnP Id of the serial device */
    6969    unsigned PnP_id_size;           /* Length of PnP Id */
    70     bool usbserial;         /* Is serial USB device */
    7170    int wr;
    72     int reader_type;
    7371    int mhz;            /* mhz specified in config = actual reader clock speed */
    7472    int cardmhz;            /* mhz specified in config = standard (non overclocked) clock speed of card*/
     
    8381//extern void IO_Serial_Reopen (IO_Serial * io);
    8482extern void IO_Serial_Flush (IO_Serial * io);
    85 extern IO_Serial *IO_Serial_New (int reader_type, int mhz, int cardmhz);
     83extern IO_Serial *IO_Serial_New (int mhz, int cardmhz);
    8684extern void IO_Serial_Delete (IO_Serial * io);
    8785
    8886/* Initialization and closing */
    89 extern bool IO_Serial_Init (IO_Serial * io, unsigned com, bool usbserial);
     87extern bool IO_Serial_Init (IO_Serial * io, int reader_type);
    9088extern bool IO_Serial_Close (IO_Serial * io);
    9189
  • trunk/csctapi/pps.c

    r1204 r1208  
    431431#include "sci_global.h"
    432432#include "sci_ioctl.h"
    433     if(pps->icc->ifd->io->com==RTYP_SCI)
     433    if(pps->icc->ifd->io->com==R_INTERNAL)
    434434    {
    435435        int n;
     
    465465    }
    466466#elif COOL
    467     if(pps->icc->ifd->io->com==RTYP_SCI) {
     467    if(pps->icc->ifd->io->com==R_INTERNAL) {
    468468        int mhz = atr_fs_table[pps->parameters.FI] / 10000;
    469469        if (!Cool_SetBaudrate(mhz))
  • trunk/csctapi/protocol_t0.c

    r1179 r1208  
    10211021    }
    10221022   
    1023     if(t14->icc->ifd->io->com!=RTYP_SCI)
     1023    if(t14->icc->ifd->io->reader_type!=R_INTERNAL)
    10241024    {
    10251025        /* Send 0x01 byte */
  • trunk/globals.h

    r1196 r1208  
    124124#define R_MOUSE     0x1 // Reader smartcard mouse
    125125#define R_INTERNAL  0x2 // Reader smartcard intern
     126#define R_DB2COM1       0x3 // Reader Dbox2 @ com1
     127#define R_DB2COM2       0x4 // Reader Dbox2 @ com1
    126128#define R_SMART     0x5 // Smartreader+
     129#ifdef HAVE_PCSC
     130    #define R_PCSC          0x6 // PCSC
     131#endif
    127132#define R_CAMD35    0x10  // Reader cascading camd 3.5x
    128133#define R_CAMD33    0x11  // Reader cascading camd 3.3x
     
    136141#define R_IS_CASCADING  0xF0
    137142
    138 #ifdef HAVE_PCSC
    139     #define R_PCSC          0x6 // PCSC
    140 #endif
    141143
    142144#define CS_MAX_MOD 12
  • trunk/reader-common.c

    r1145 r1208  
    2020#ifdef TUXBOX
    2121static int reader_device_type(char *device)
    22 #else
    23 static int reader_device_type()
    24 #endif
    25 {
    26   int rc=PORT_STD;
    27 #ifdef TUXBOX
     22{
     23  int rc=reader[ridx].typ;
    2824  struct stat sb;
    29 #endif
    30 
    31   switch(reader[ridx].typ)
    32   {
    33     case R_MOUSE:
    34     case R_SMART:
    35       rc=PORT_STD;
    36 #ifdef TUXBOX
     25  if (reader[ridx].typ == RMOUSE)
     26  {
    3727      if (!stat(device, &sb))
    3828      {
     
    4535            switch(dev_minor & 0x3F)
    4636            {
    47               case 0: rc=PORT_DB2COM1; break;
    48               case 1: rc=PORT_DB2COM2; break;
     37              case 0: rc=R_DB2COM1; break;
     38              case 1: rc=R_DB2COM2; break;
    4939            }
    5040          cs_debug("device is major: %d, minor: %d, typ=%d", dev_major, dev_minor, rc);
    5141        }
    5242      }
    53 #endif
    54       break;
    55     case R_INTERNAL:
    56       rc=PORT_SCI;
    57       break;
    5843  }
    5944  return(rc);
    6045}
     46#endif
    6147
    6248static void reader_nullcard(void)
     
    324310  snprintf(oscam_device, sizeof(oscam_device), "%s", device);
    325311#ifdef TUXBOX
    326   if ((rc=CT_init(1, reader_device_type(device),reader[ridx].typ,reader[ridx].mhz,reader[ridx].cardmhz))!=OK)
     312  if ((rc=CT_init(1, reader_device_type(device),reader[ridx].mhz,reader[ridx].cardmhz))!=OK)
    327313    cs_log("[tuxbox] Cannot open device: %s", device);
    328314#else
    329   if ((rc=CT_init(1, reader_device_type(),reader[ridx].typ,reader[ridx].mhz,reader[ridx].cardmhz))!=OK)
     315  if ((rc=CT_init(1, reader[ridx].typ,reader[ridx].mhz,reader[ridx].cardmhz))!=OK)
    330316    cs_log("Cannot open device: %s", device);
    331317#endif
Note: See TracChangeset for help on using the changeset viewer.