On 2 Dec 2004, at 10:41, Karsten Ohme wrote:
Can I send and receive data simultaneously from a card with SCardTransmit()?
sendBufferLength = 5 + AIDLength + 1; sendBuffer = (LPBYTE)malloc(sizeof(BYTE)*sendBufferLength); sendBuffer[i++] = 0x00; sendBuffer[i++] = 0xA4; sendBuffer[i++] = 0x04; sendBuffer[i++] = 0x00; sendBuffer[i++] = (BYTE)AIDLength; memcpy(sendBuffer+i, AID, AIDLength); i+=AIDLength; sendBuffer[i] = 0x00;
Your code creates a fully formed case-4 APDU (including Le). The data should be returned in one call for both T=0 and T=1 cards. For a T=0 PC/SC (or something in the system) should transparently issue the GET RESPONSE and return the data: Since your code issues an application-level command (APDU), it should not care about the transport level formatting (TPDU).
In pcsc-lite, it is left to the ifdhandler (i.e. the driver) to perform this. Some drivers do, others don't.
The resemblance between a T=0 TPDU and an APDU has lead some application developers to include the GET RESPONSE in their code (which is obviously wrong as they mix 2 layers). AFAIK a lot of applications in the Windows world do this and this confusion has been brought along in pcsc-lite.
In my driver I think I implemented the following:
- when called with "sendBufferLength = 5 + AIDLength + 1", APDU is assumed and GET RESPONSE is issued automatically (if the reader is not doing it itself)
- when called with "sendBufferLength = 5 + AIDLength (missing Le), TPDU or case-2 command is assumed, "61 xx" is returned and the application is expected to issue the GET RESPONSE.
result = SCardTransmit( cardHandle,
SCARD_PCI_T0,
sendBuffer,
sendBufferLength,
NULL,
recvBuffer,
&recvBufferLength
Make sure you set the value of recvBufferLength to the size of your buffer: a well-behaved driver will use this to determine how much information to return.
Cheers, JLuc.
_______________________________________________ Muscle mailing list [EMAIL PROTECTED] http://lists.drizzle.com/mailman/listinfo/muscle
