- Timestamp:
- 02/05/12 23:28:44 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sc8in1/csctapi/ifd_sc8in1.c
r6338 r6349 75 75 memcpy(&termiobackup, &termio, sizeof(termio)); 76 76 77 if (selectSlotMode) { 78 if (reader->sc8in1_config->current_slot != 0) { 79 memcpy(&reader->sc8in1_config->stored_termio[reader->sc8in1_config->current_slot - 1], 80 &termiobackup, sizeof(termiobackup)); //not if current_slot is undefined 81 } 82 } 83 77 84 // set communication parameters 78 85 termio.c_oflag = 0; … … 169 176 } 170 177 #endif 171 // restore baudrate only if changed 172 if (currentBaudrate) { 173 if (Sc8in1_SetBaudrate(reader, currentBaudrate, &termiobackup, 1)) { 174 cs_log("ERROR: SC8in1 selectslot restore Bitrate attributes\n"); 175 return ERROR; 178 if (selectSlotMode) { 179 memcpy(&termiobackup, &reader->sc8in1_config->stored_termio[selectSlotMode - 1], 180 sizeof(termiobackup)); 181 if (Sc8in1_NeedBaudrateChange(reader, reader->current_baudrate, &termio, &termiobackup, 1)) { 182 cs_debug_mask(D_TRACE, "Sc8in1_SetTermioForSlot for select slot"); 183 if (Sc8in1_SetBaudrate(reader, reader->current_baudrate, &termiobackup, 0)) { 184 cs_log("ERROR: SC8in1 Command Sc8in1_SetBaudrate\n"); 185 return ERROR; 186 } 187 } 188 else { 189 if (tcsetattr(reader->handle, TCSANOW, &termiobackup) < 0) { 190 cs_log("ERROR: SC8in1 Command error in set RS232 attributes\n"); 191 return ERROR; 192 } 176 193 } 177 194 } 178 195 else { 179 // restore data 180 if (tcsetattr(reader->handle, TCSANOW, &termiobackup) < 0) { 181 cs_log("ERROR: SC8in1 Command error in restore RS232 attributes\n"); 182 return ERROR; 183 } 184 } 196 // restore baudrate only if changed 197 if (currentBaudrate) { 198 if (Sc8in1_SetBaudrate(reader, currentBaudrate, &termiobackup, 1)) { 199 cs_log("ERROR: SC8in1 selectslot restore Bitrate attributes\n"); 200 return ERROR; 201 } 202 } 203 else { 204 // restore data 205 if (tcsetattr(reader->handle, TCSANOW, &termiobackup) < 0) { 206 cs_log("ERROR: SC8in1 Command error in restore RS232 attributes\n"); 207 return ERROR; 208 } 209 } 210 } 211 185 212 Sc8in1_DebugSignals(reader, reader->slot, "CMD12"); 186 213 if (reader->sc8in1_dtrrts_patch == 1) { … … 637 664 } 638 665 639 int32_t Sc8in1_SetTermioForSlot(struct s_reader *reader, uint16_t slot) {640 641 Sc8in1_DebugSignals(reader, reader->slot, "SL100");642 // switch SC8in1 to command mode643 IO_Serial_DTR_Set(reader);644 645 struct termios termio_current, termio_new;646 tcgetattr(reader->handle, &termio_current);647 if (reader->sc8in1_config->current_slot != 0) {648 memcpy(&reader->sc8in1_config->stored_termio[reader->sc8in1_config->current_slot - 1],649 &termio_current, sizeof(termio_current)); //not if current_slot is undefined650 }651 memcpy(&termio_new, &reader->sc8in1_config->stored_termio[slot - 1],652 sizeof(termio_new));653 654 if (Sc8in1_NeedBaudrateChange(reader, reader->current_baudrate, &termio_current, &termio_new, 0)) {655 cs_debug_mask(D_TRACE, "Sc8in1_SetTermioForSlot for select slot");656 // save current baudrate for later restore657 if (Sc8in1_SetBaudrate(reader, reader->current_baudrate, &termio_new, 0)) {658 cs_log("ERROR: SC8in1 Command Sc8in1_SetBaudrate\n");659 return ERROR;660 }661 }662 else {663 if (tcsetattr(reader->handle, TCSANOW, &termio_new) < 0) {664 cs_log("ERROR: SC8in1 Command error in set RS232 attributes\n");665 return ERROR;666 }667 }668 Sc8in1_DebugSignals(reader, reader->slot, "SL101");669 if (reader->sc8in1_dtrrts_patch == 1) {670 IO_Serial_DTR_Set(reader);671 }672 673 tcflush(reader->handle, TCIOFLUSH);674 675 IO_Serial_DTR_Clr(reader);676 677 Sc8in1_DebugSignals(reader, reader->slot, "SL102");678 679 return OK;680 }681 682 666 int32_t Sc8in1_Selectslot(struct s_reader * reader, uint16_t slot) { 683 667 // selects the Smartcard Socket "slot" 684 668 // 685 #ifdef WITH_DEBUG686 struct timeval tv_start, tv_mid, tv_end;687 gettimeofday(&tv_start,0);688 #endif689 690 669 if (slot == reader->sc8in1_config->current_slot) 691 670 return OK; 692 671 cs_debug_mask(D_TRACE, "SC8in1: select slot %i", slot); 693 672 673 #ifdef WITH_DEBUG 674 struct timeval tv_start, tv_end; 675 gettimeofday(&tv_start,0); 676 #endif 677 694 678 int32_t status = ERROR; 695 679 if (reader->sc8in1_config->mcr_type) { 696 680 status = mcrSelectSlot(reader, slot); 697 #ifdef WITH_DEBUG698 gettimeofday(&tv_mid,0);699 uint32_t elapsed = (tv_mid.tv_sec-tv_start.tv_sec)*1000000 + tv_mid.tv_usec-tv_start.tv_usec;700 cs_debug_mask(D_DEVICE, "SC8in1 Selectslot Phase1 in %ums", elapsed/1000);701 #endif702 status |= Sc8in1_SetTermioForSlot(reader, slot);703 681 } 704 682 else { … … 804 782 return ERROR; 805 783 } 784 785 // set initial current_baudrate which is needed by sc8in1_command 786 rdr->current_baudrate = reader->current_baudrate; 806 787 807 788 if (reader->sc8in1_config->mcr_type) {
Note:
See TracChangeset
for help on using the changeset viewer.