Changeset 4107 for trunk/csctapi
- Timestamp:
- 12/14/10 10:36:23 (13 years ago)
- Location:
- trunk/csctapi
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/icc_async.c
r3794 r4107 81 81 switch(reader->typ) { 82 82 case R_SC8in1: 83 pthread_mutex_init(&sc8in1, NULL); 83 //pthread_mutex_init(&sc8in1, NULL); 84 pthread_mutex_lock(&sc8in1); 85 if (reader->handle != 0) {//this reader is already initialized 86 pthread_mutex_unlock(&sc8in1); 87 return OK; 88 } 89 90 //this reader is uninitialized, thus the first one, since the first one initializes all others 91 92 //get physical device name 84 93 int pos = strlen(reader->device)-2; //this is where : should be located; is also valid length of physical device name 85 94 if (reader->device[pos] != 0x3a) //0x3a = ":" … … 87 96 reader->slot=(int)reader->device[pos+1] - 0x30;//FIXME test boundaries 88 97 reader->device[pos]= 0; //slot 1 reader now gets correct physicalname 98 99 //open physical device 100 reader->handle = open (reader->device, O_RDWR | O_NOCTTY| O_NONBLOCK); 101 if (reader->handle < 0) { 102 cs_log("ERROR opening device %s",reader->device); 103 pthread_mutex_unlock(&sc8in1); 104 return ERROR; 105 } 106 107 //copy physical device name and file handle to other slots 108 struct s_reader *rdr; 109 for (rdr=first_reader; rdr ; rdr=rdr->next) //copy handle to other slots, FIXME change this if multiple sc8in1 readers 110 if (rdr->typ == R_SC8in1 && rdr != reader) { //we have another sc8in1 reader 111 unsigned char save = rdr->device[pos]; 112 rdr->device[pos]=0; //set to 0 so we can compare device names 113 if (!strcmp(reader->device, rdr->device)) {//we have a match to another slot with same device name 114 rdr->handle = reader->handle; 115 rdr->slot=(int)rdr->device[pos+1] - 0x30;//FIXME test boundaries 116 } 117 else 118 rdr->device[pos] = save; //restore character 119 } 120 break; 89 121 case R_MP35: 90 122 case R_MOUSE: … … 160 192 } 161 193 162 if (reader->typ == R_SC8in1) 194 if (reader->typ == R_SC8in1) { 163 195 call(Sc8in1_Init(reader)); 196 pthread_mutex_unlock(&sc8in1); 197 } 164 198 165 199 cs_debug_mask (D_IFD, "IFD: Device %s succesfully opened\n", reader->device); -
trunk/csctapi/ifd_sc8in1.c
r4083 r4107 175 175 //init all stored termios to default comm settings after device init, before ATR 176 176 memcpy(&stored_termio[i],&termio,sizeof(termio)); 177 177 } 178 178 179 179 // check for a MCR device and how many slots it has. 180 180 unsigned char buff[] = { 0x74 }; 181 181 sc8in1_command(reader, buff, 1, 1); … … 189 189 tcflush(reader->handle, TCIOFLUSH); // a non MCR reader might give longer answer 190 190 191 struct s_reader *rdr;192 for (rdr=first_reader; rdr ; rdr=rdr->next) //copy handle to other slots, FIXME change this if multiple sc8in1 readers193 if (rdr->typ == R_SC8in1) {194 if (rdr->slot == 0) {//not initialized yet195 pos = strlen(rdr->device)-2; //this is where : should be located; is also valid length of physical device name196 if (rdr->device[pos] != 0x3a) //0x3a = ":"197 cs_log("ERROR: '%c' detected instead of slot separator `:` at second to last position of device %s", rdr->device[pos], rdr->device);198 rdr->slot=(int)rdr->device[pos+1] - 0x30;//FIXME test boundaries199 rdr->device[pos]= 0; //slot 1 reader now gets correct physicalname200 }201 rdr->handle = fd;202 }203 204 191 if (is_mcr) { 192 //determine clockspeeds for all slots 193 struct s_reader *rdr; 194 for (rdr=first_reader; rdr ; rdr=rdr->next) 195 if (rdr->handle == reader->handle) { //corresponding slot 196 205 197 //if MCR set clock 206 switch (r eader->mhz) {198 switch (rdr->mhz) { 207 199 case 357: 208 200 case 358: … … 221 213 default: 222 214 speed = 0; 223 cs_log("ERROR Sc8in1, cannot set clockspeed to %i", r eader->mhz);215 cs_log("ERROR Sc8in1, cannot set clockspeed to %i", rdr->mhz); 224 216 break; 225 217 } 226 sc8in1_clock |= (speed << (reader->slot - 1) * 2); 218 sc8in1_clock |= (speed << (rdr->slot - 1) * 2); 219 } 220 221 //set clockspeeds for all slots 227 222 buff[0] = 0x63; //MCR set clock 228 223 buff[1] = (sc8in1_clock >> 8) & 0xFF; 229 224 buff[2] = sc8in1_clock & 0xFF; 230 sc8in1_command(reader, buff, 3, 0); 225 sc8in1_command(reader, buff, 3, 0); 226 227 /* //DEBUG get clockspeeds 228 buff[0] = 0x67; 229 sc8in1_command(reader, buff, 1, 2); 230 static char * clock[] = { "3,57", "3,68", "6,00", "8,00" }; 231 uint16 result = buff[0]<<8 | buff[1]; 232 cs_log("Buff = %X %X, result = %02X",buff[0], buff[1], result); 233 for(i=0; i<8; i++) { 234 cs_log("Slot %i is clocked with %s mhz", i+1, clock[(result>>(i*2))&0X0003]); 235 }*/ 231 236 } 232 237
Note:
See TracChangeset
for help on using the changeset viewer.