Skip to content

Commit

Permalink
pcsc_demo: add tests for SCardGetAttrib() and SCardControl()
Browse files Browse the repository at this point in the history
  • Loading branch information
LudovicRousseau committed May 22, 2024
1 parent 6243772 commit c5c89b0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions doc/example/pcsc_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string.h>

#include <winscard.h>
#include <reader.h>

/* PCSC error message pretty print */
#define PCSC_ERROR(rv, text) \
Expand Down Expand Up @@ -266,6 +267,24 @@ int main(int argc, char *argv[])
rv = SCardEndTransaction(hCard, SCARD_LEAVE_CARD);
PCSC_ERROR(rv, "SCardEndTransaction")

/* get Attribute */
dwAtrLen = sizeof(pbAtr);
rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, pbAtr, &dwAtrLen);
printf("Received: ");
for (i=0; i<dwAtrLen; i++)
printf("%02X ", pbAtr[i]);
printf("\n");
PCSC_ERROR(rv, "SCardGetAttrib")

/* control */
rv = SCardControl(hCard, CM_IOCTL_GET_FEATURE_REQUEST, NULL, 0,
pbRecvBuffer, sizeof pbRecvBuffer, &dwRecvLength);
printf("Received: ");
for (i=0; i<dwRecvLength; i++)
printf("%02X ", pbRecvBuffer[i]);
printf("\n");
PCSC_ERROR(rv, "SCardControl")

/* card disconnect */
rv = SCardDisconnect(hCard, SCARD_UNPOWER_CARD);
PCSC_ERROR(rv, "SCardDisconnect")
Expand Down

0 comments on commit c5c89b0

Please sign in to comment.