- Timestamp:
- 02/08/12 22:07:38 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sc8in1/csctapi/ifd_sc8in1.c
r6349 r6361 25 25 #include "icc_async.h" 26 26 27 #define SC8IN1_TIMEOUT_HACK 128 29 27 #define LOCK_SC8IN1 \ 30 28 { \ … … 137 135 } 138 136 } 139 while (1) {140 int32_t tcdrain_ret = tcdrain(reader->handle);141 if (tcdrain_ret==-1) {142 if (errno==EINTR) {143 //try again in case of Interrupted system call144 continue;145 } else146 cs_log("ERROR in sc8in1_command - tcdrain: (errno=%d %s)", errno, strerror(errno));147 return ERROR;148 }149 break;150 }151 137 152 138 if (IO_Serial_Read(reader, 1000, lenread, buff) == ERROR) { … … 155 141 } 156 142 157 #ifdef SC8IN1_TIMEOUT_HACK 158 // On some system, at least my dockstar, tcdrain returns before the transmitted bytes actually 159 // reach the serial port. This here is an awful hack, to workaround the issue. 160 // We transmit the ECHO command to the device and wait until it sends back the echo char 'A' 161 // to us. This way we can be sure that the main command in buff has been received by the device. 162 // Another way to workaround this issue is to wait for an appropriate amount of time, but i think 163 // thats even worse. 143 // If we dont expect an answer use the echo function of the 144 // mcr to actually receive an answer. This way tcdrain can 145 // be skipped which either slow or doesnt even work properly. 164 146 if (lenread <= 0 && reader->sc8in1_config->mcr_type) { 165 147 unsigned char buff_echo_hack[2] = { 0x65, 'A' }; 166 148 cs_ddump_mask(D_DEVICE, &buff_echo_hack[0], 2, "IO: Sending: "); 167 149 if (write(reader->handle, &buff_echo_hack[0], 2) != 2) { 168 cs_log("SC8in1 Command write error");150 cs_log("SC8in1 Echo command write error"); 169 151 return ERROR; 170 152 } 171 tcdrain(reader->handle); // should be useless.. but what the hell 172 if (IO_Serial_Read(reader, 1000, 1, &buff_echo_hack[0]) == ERROR) { 173 cs_log("SC8in1 Command read error"); 153 if (IO_Serial_Read(reader, 1000, 1, &buff_echo_hack[0]) == ERROR || buff_echo_hack[0] != 'A') { 154 cs_log("SC8in1 Echo command read error"); 174 155 return ERROR; 175 156 } 176 157 } 177 #endif 158 else if (lenread <= 0 && ! reader->sc8in1_config->mcr_type) { 159 while (1) { 160 int32_t tcdrain_ret = tcdrain(reader->handle); 161 if (tcdrain_ret==-1) { 162 if (errno==EINTR) { 163 //try again in case of Interrupted system call 164 continue; 165 } else 166 cs_log("ERROR in sc8in1_command - tcdrain: (errno=%d %s)", errno, strerror(errno)); 167 return ERROR; 168 } 169 break; 170 } 171 } 178 172 if (selectSlotMode) { 179 173 memcpy(&termiobackup, &reader->sc8in1_config->stored_termio[selectSlotMode - 1],
Note:
See TracChangeset
for help on using the changeset viewer.