Changeset 1960
- Timestamp:
- 04/05/10 19:30:24 (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/icc_async.c
r1951 r1960 29 29 #include "defines.h" 30 30 #include "icc_async.h" 31 #include "ifd.h"32 31 #include "mc_global.h" 33 32 #include "protocol_t0.h" 34 33 #include "protocol_t1.h" 35 34 #include "io_serial.h" 36 37 extern struct termios stored_termio[8]; //FIXME no globals please 35 #include "ifd_cool.h" 36 #include "ifd_phoenix.h" 37 #include "ifd_sc8in1.h" 38 #include "ifd_sci.h" 39 #include "ifd_smartreader.h" 40 38 41 // Default T0/T14 settings 39 42 #define DEFAULT_WI 10 … … 138 141 Sc8in1_GetStatus(reader, &i); //Initialize cardstatus 139 142 } 140 if (reader->typ <= R_MOUSE) 141 if (Phoenix_Init(reader)) { 142 cs_log("ERROR: Phoenix_Init returns error"); 143 Phoenix_Close (reader); 144 return ERROR; 143 144 if (reader->typ <= R_MOUSE) 145 if (Phoenix_Init(reader)) { 146 cs_log("ERROR: Phoenix_Init returns error"); 147 Phoenix_Close (reader); 148 return ERROR; 145 149 } 146 if (reader->typ == R_SC8in1) { 147 struct termios termio; 148 tcgetattr(reader->handle,&termio); 149 int i; 150 for (i=0; i<8; i++) 151 //init all stored termios to default comm settings after device init, before ATR 152 memcpy(&stored_termio[i],&termio,sizeof(termio)); 153 } 150 151 if (reader->typ == R_SC8in1) 152 call(Sc8in1_Init(reader)); 153 154 154 cs_debug_mask (D_IFD, "IFD: Device %s succesfully opened\n", reader->device); 155 155 return OK; -
trunk/csctapi/ifd_phoenix.c
r1952 r1960 163 163 while(n<PHOENIX_MAX_ATR_SIZE && !IO_Serial_Read(reader, ATR_TIMEOUT, 1, buf+n)) 164 164 n++; 165 if(n==0) { 166 cs_log("WARNING: 0 characters found in ATR"); 167 //FIXME: No parity switching was done if we exit here 168 //return ERROR; 169 } 165 if(n==0) 166 continue; 170 167 if (ATR_InitFromArray (atr, buf, n) == ATR_OK) 171 168 ret = OK; -
trunk/csctapi/ifd_sc8in1.c
r1953 r1960 28 28 #include "icc_async.h" 29 29 30 struct termios stored_termio[8];//FIXME no globals please 30 static struct termios stored_termio[8];//FIXME no globals please 31 static int current_slot; //FIXME should not be a global, but one per SC8in1 32 static unsigned char cardstatus; //FIXME not global but one per SC8in1 //if not static, the threads dont share same cardstatus! 33 31 34 #define MAX_TRANSMIT 255 32 35 33 static int readsc8in1(struct s_reader * reader) { 34 // Reads the card status 35 // 36 // the bits in the return bytes: 37 // bit0=1 means Slot1=Smartcard inside 38 // bit1=1 means Slot2=Smartcard inside 39 // bit2=1 means Slot3=Smartcard inside 40 // bit3=1 means Slot4=Smartcard inside 41 // bit4=1 means Slot5=Smartcard inside 42 // bit5=1 means Slot6=Smartcard inside 43 // bit6=1 means Slot7=Smartcard inside 44 // bit7=1 means Slot8=Smartcard inside 45 int res; 46 unsigned char tmp[128]; 36 static int sc8in1_command(struct s_reader * reader, unsigned char * buff, unsigned short lenwrite, unsigned short lenread) 37 { 47 38 struct termios termio, termiobackup; 48 39 … … 61 52 if (tcsetattr(reader->handle,TCSANOW,&termio) < 0) { 62 53 cs_log("ERROR: SC8in1 readsc8in1 set RS232 attributes\n"); 63 return (-1);54 return ERROR; 64 55 } 65 // get SC8in1 info 66 tmp[0]=0x47; 67 IO_Serial_Write (reader, 0, 1, tmp); 56 IO_Serial_Write (reader, 0, lenwrite, buff); 68 57 tcdrain(reader->handle); 69 res=IO_Serial_Read (reader, 1000, 8, tmp); 70 71 if ( res==ERROR ) { 58 if (IO_Serial_Read (reader, 1000, lenread, buff) == ERROR) { 72 59 cs_log("READSC8in1 read error"); 73 return (-1); // ERROR !60 return ERROR; 74 61 } 75 62 76 63 // switch SC8in1 to normal mode 77 tcdrain(reader->handle);64 //cs_sleepms(10); FIXME do I need this? 78 65 IO_Serial_DTR_Clr(reader); 79 66 … … 82 69 if (tcsetattr(reader->handle,TCSANOW,&termio) < 0) { 83 70 cs_log("ERROR: SC8in1 readsc8in1 restore RS232 attributes\n"); 84 return (-1);71 return ERROR; 85 72 } 73 return OK; 74 } 86 75 87 if (tmp[0]!=0x90) return(-1); // ERROR ! 76 static int readsc8in1(struct s_reader * reader) 77 { 78 // Reads the card status 79 // 80 // the bits in the return bytes: 81 // bit0=1 means Slot1=Smartcard inside 82 // bit1=1 means Slot2=Smartcard inside 83 // bit2=1 means Slot3=Smartcard inside 84 // bit3=1 means Slot4=Smartcard inside 85 // bit4=1 means Slot5=Smartcard inside 86 // bit5=1 means Slot6=Smartcard inside 87 // bit6=1 means Slot7=Smartcard inside 88 // bit7=1 means Slot8=Smartcard inside 89 unsigned char buf[10]; 90 buf[0]=0x47; 91 if (sc8in1_command(reader, buf, 1, 8) < 0) return (-1); 92 if (buf[0]!=0x90) return(-1); 88 93 89 94 // return result byte 90 return( tmp[1]);95 return(buf[1]); 91 96 } 92 97 93 int selectslot(struct s_reader * reader, int slot) {98 int Sc8in1_Selectslot(struct s_reader * reader, int slot) { 94 99 // selects the Smartcard Socket "slot" 95 100 // 96 101 if (slot == current_slot) 97 return (0);102 return OK; 98 103 cs_log("SC8in1: select slot %i", slot); 99 104 int res; … … 113 118 if (tcsetattr(reader->handle,TCSANOW,&termio) < 0) { 114 119 cs_log("ERROR: SC8in1 selectslot set RS232 attributes\n"); 115 return (-1);120 return ERROR; 116 121 } 117 122 tcflush(reader->handle, TCIOFLUSH); … … 132 137 if (tcsetattr(reader->handle,TCSANOW,&termio) < 0) { 133 138 cs_log("ERROR: SC8in1 selectslot restore RS232 attributes\n"); 134 return (-1);139 return ERROR; 135 140 } 136 141 //cs_sleepms(10); //FIXME do I need this? 137 return(0); 142 return OK; 143 } 144 145 int Sc8in1_Init(struct s_reader * reader) 146 { 147 //additional init, Phoenix_Init is also called for Sc8in1 ! 148 struct termios termio; 149 tcgetattr(reader->handle,&termio); 150 int i; 151 for (i=0; i<8; i++) 152 //init all stored termios to default comm settings after device init, before ATR 153 memcpy(&stored_termio[i],&termio,sizeof(termio)); 154 return OK; 138 155 } 139 156 -
trunk/csctapi/ifd_sc8in1.h
r1926 r1960 19 19 #include <pthread.h> 20 20 21 int Sc8in1_Init (struct s_reader * reader); 21 22 int Sc8in1_GetStatus (struct s_reader * reader, int * status); 23 int Sc8in1_Card_Changed (struct s_reader * reader); 24 int Sc8in1_Selectslot(struct s_reader * reader, int slot); 22 25 23 pthread_mutex_t sc8in1; //semaphore for SC8in1, FIXME should not be global, but one per SC8in1 24 //not sure why mutex seems to be global for all threads in one reader, and variables below only if they are defined static ... 25 static int current_slot; //FIXME should not be a global, but one per SC8in1 26 static unsigned char cardstatus; //FIXME not global but one per SC8in1 //if not static, the threads dont share same cardstatus! 26 static pthread_mutex_t sc8in1; //semaphore for SC8in1, FIXME should not be global, but one per SC8in1 -
trunk/csctapi/ifd_sci.c
r1926 r1960 4 4 */ 5 5 6 #include "atr.h" 7 #include "../globals.h" 6 #include "ifd_sci.h" 8 7 9 8 #ifdef SCI_DEV -
trunk/reader-common.c
r1953 r1960 4 4 #include "atr.h" 5 5 #include "icc_async_exports.h" 6 #include "csctapi/ifd_sc8in1.h" 6 7 7 8 static int cs_ptyp_orig; //reinit=1, 8 extern int Sc8in1_Card_Changed (struct s_reader * reader);9 extern int selectslot(struct s_reader * reader, int slot);10 extern pthread_mutex_t sc8in1; //FIXME11 9 12 10 #define SC_IRDETO 1 … … 76 74 pthread_mutex_lock(&sc8in1); 77 75 cs_debug("SC8in1: locked for CardWrite of slot %i", reader->slot); 78 selectslot(reader, reader->slot);76 Sc8in1_Selectslot(reader, reader->slot); 79 77 } 80 78 rc=ICC_Async_CardWrite(reader, buf, (unsigned short)l, cta_res, p_cta_lr); … … 142 140 pthread_mutex_lock(&sc8in1); 143 141 cs_debug_mask(D_ATR, "SC8in1: locked for Activation of slot %i", reader->slot); 144 selectslot(reader, reader->slot);142 Sc8in1_Selectslot(reader, reader->slot); 145 143 } 146 144 for (i=0; i<5; i++) {
Note:
See TracChangeset
for help on using the changeset viewer.