Logo Search packages:      
Sourcecode: pcsc-lite version File versions  Download package

LONG SCardTransmit ( SCARDHANDLE  hCard,
LPCSCARD_IO_REQUEST  pioSendPci,
LPCBYTE  pbSendBuffer,
DWORD  cbSendLength,
LPSCARD_IO_REQUEST  pioRecvPci,
LPBYTE  pbRecvBuffer,
LPDWORD  pcbRecvLength 
)

This function sends an APDU to the smart card contained in the reader connected to by SCardConnect().

The card responds from the APDU and stores this response in pbRecvBuffer and it's length in SpcbRecvLength. SSendPci and SRecvPci are structures containing the following:

 typedef struct {
    DWORD dwProtocol;    // SCARD_PROTOCOL_T0 or SCARD_PROTOCOL_T1
    DWORD cbPciLength;   // Length of this structure - not used
 } SCARD_IO_REQUEST;

Parameters:
[in] hCard Connection made from SCardConnect().
pioSendPci [inout] Structure of protocol information.
  • SCARD_PCI_T0 - Pre-defined T=0 PCI structure.
  • SCARD_PCI_T1 - Pre-defined T=1 PCI structure.
[in] pbSendBuffer APDU to send to the card.
[in] cbSendLength Length of the APDU.
pioRecvPci [inout] Structure of protocol information.
[out] pbRecvBuffer Response from the card.
pcbRecvLength [inout] Length of the response.
Returns:
Error code.
Return values:
SCARD_S_SUCCESS Successful.
SCARD_E_INVALID_HANDLE Invalid hCard handle.
SCARD_E_NOT_TRANSACTED APDU exchange not successful.
SCARD_E_PROTO_MISMATCH Connect protocol is different than desired.
SCARD_E_INVALID_VALUE Invalid Protocol, reader name, etc.
SCARD_E_READER_UNAVAILABLE The reader has been removed.
SCARD_W_RESET_CARD The card has been reset by another application.
SCARD_W_REMOVED_CARD The card has been removed from the reader.
Test:
 LONG rv;
 SCARDCONTEXT hContext;
 SCARDHANDLE hCard;
 DWORD dwActiveProtocol, dwSendLength, dwRecvLength;
 SCARD_IO_REQUEST pioRecvPci;
 BYTE pbRecvBuffer[10];
 BYTE pbSendBuffer[] = { 0xC0, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00 };
 ...
 rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
 rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol);
 dwSendLength = sizeof(pbSendBuffer);
 dwRecvLength = sizeof(pbRecvBuffer);
 rv = SCardTransmit(hCard, SCARD_PCI_T0, pbSendBuffer, dwSendLength, &pioRecvPci, pbRecvBuffer, &dwRecvLength);

Definition at line 1111 of file winscard_scf.c.

References SCARD_PROTOCOL_ANY_OLD, SCardLockThread(), and SCardUnlockThread().

Referenced by MSGFunctionDemarshall().

{
      long rv;

      SCardLockThread();
      rv = SCardTransmitTH(hCard, pioSendPci, pbSendBuffer, cbSendLength,
            pioRecvPci, pbRecvBuffer, pcbRecvLength);
      SCardUnlockThread();

      return rv;
}


Generated by  Doxygen 1.6.0   Back to index