1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#include <stdio.h>
#include<ctacs/ct_api.h>
int main(int argc, char *argv[])
{
char ret;
unsigned short ctn;
unsigned short pn;
unsigned short sad;
unsigned short dad;
// REQUEST ICC
unsigned char command[] = { 0x20, 0x12, 0x01, 0x00, 0x00 };
unsigned short lenc = sizeof(command);
unsigned char response[300];
unsigned short lenr = sizeof(response);
ctn = 1;
pn = 1;
// Initialize card terminal
ret = CT_init(ctn, pn);
if (ret != OK)
{
printf("Error: CT_init failed with error %d\n", ret);
return 1;
}
sad = 2; // Source = Host
dad = 1; // Destination = Card Terminal
// Send command
ret = CT_data(ctn, (unsigned char*)&dad, (unsigned char*)&sad, lenc, command, &lenr, response);
if (ret != OK)
printf("Error: CT_data failed with error %d\n", ret);
else
{
// Display response
printf("Response: ");
for (int i = 0; i < lenr; i++)
printf("%02X ", response[i]);
printf("\n");
}
// Close card terminal
ret = CT_close(ctn);
if (ret != OK)
printf("Error: CT_close failed with error %d\n", ret);
return 0;
}
|