-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
45 lines (42 loc) · 958 Bytes
/
main.c
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
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
char done;
unsigned char buf[256];
unsigned char recvbuf[256];
unsigned long recvlen;
int len = 254;
int i, k;
buf[0] = 0x00;
buf[1] = 0x84;
buf[2] = 0x00;
buf[3] = 0x00;
buf[4] = len;
unsigned long commlen;
if (!init_sc())
{
commlen = 5;
recvlen = (unsigned long) sizeof(recvbuf);
printf("-----> %02x %02x %02x %02x %02x\n", buf[0], buf[1], buf[2], buf[3], buf[4]);
for(k = 0; k < 1024; k++)
{
if ( !sendAPDU(buf, commlen, recvbuf, &recvlen))
{
printf("recvlen = %ld\n", recvlen);
printf("count - %d\n", k);
printf("<----- ");
for (i = 0; i < recvlen; i++) printf("%02x ", recvbuf[i]);
printf("\n\n");
}
else
{
printf("Error: sendAPDU\n");
}
}
}
else printf("\nInit SC......FAILURE\n");
return (0);
}