Changeset 1020 for branches/monitor-improvement/reader-pcsc.c
- Timestamp:
- 01/01/10 13:51:05 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/monitor-improvement/reader-pcsc.c
r885 r1020 85 85 DWORD dwSendLength, dwRecvLength; 86 86 87 dwSendLength = l; 87 88 88 dwRecvLength = CTA_RES_LEN; 89 cs_debug("sending %d bytes to PCSC", dwSendLength); 90 91 if(pcsc_reader->dwActiveProtocol == SCARD_PROTOCOL_T0) 92 rv = SCardTransmit(pcsc_reader->hCard, SCARD_PCI_T0, buf, dwSendLength, &pioRecvPci, cta_res, &dwRecvLength); 93 else if(pcsc_reader->dwActiveProtocol == SCARD_PROTOCOL_T1) 94 rv = SCardTransmit(pcsc_reader->hCard, SCARD_PCI_T1, buf, dwSendLength, &pioRecvPci, cta_res, &dwRecvLength); 95 else { 96 cs_debug("PCSC invalid protocol (T=%d)", ( pcsc_reader->dwActiveProtocol == SCARD_PROTOCOL_T0 ? 0 : 1)); 97 return ERR_INVALID; 98 } 89 90 if(pcsc_reader->dwActiveProtocol == SCARD_PROTOCOL_T0) { 91 // explanantion as to why we do the test on buf[4] : 92 // Issuing a command without exchanging data : 93 //To issue a command to the card that does not involve the exchange of data (either sent or received), the send and receive buffers must be formatted as follows. 94 //The pbSendBuffer buffer must contain the CLA, INS, P1, and P2 values for the T=0 operation. The P3 value is not sent. (This is to differentiate the header from the case where 256 bytes are expected to be returned.) 95 //The cbSendLength parameter must be set to four, the size of the T=0 header information (CLA, INS, P1, and P2). 96 //The pbRecvBuffer will receive the SW1 and SW2 status codes from the operation. 97 //The pcbRecvLength should be at least two and will be set to two upon return. 98 if(buf[4]) 99 dwSendLength = l; 100 else 101 dwSendLength = l-1; 102 cs_debug("sending %d bytes to PCSC", dwSendLength); 103 rv = SCardTransmit(pcsc_reader->hCard, SCARD_PCI_T0, buf, dwSendLength, &pioRecvPci, cta_res, &dwRecvLength); 104 } 105 else if(pcsc_reader->dwActiveProtocol == SCARD_PROTOCOL_T1) { 106 dwSendLength = l; 107 cs_debug("sending %d bytes to PCSC", dwSendLength); 108 rv = SCardTransmit(pcsc_reader->hCard, SCARD_PCI_T1, buf, dwSendLength, &pioRecvPci, cta_res, &dwRecvLength); 109 } 110 else { 111 cs_debug("PCSC invalid protocol (T=%d)", pcsc_reader->dwActiveProtocol); 112 return ERR_INVALID; 113 } 99 114 100 115 *cta_lr=dwRecvLength;
Note:
See TracChangeset
for help on using the changeset viewer.