]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blob - main.c
read card id, retab
[coffee/mt-apps.git] / main.c
1 /*
2  ============================================================================
3  Name        : main.c
4  Author      : Digital Logic
5  Version     : 1.0
6  Copyright   :
7  Description : Very simple test of uFR library
8  ============================================================================
9  */
10
11 #include <stdio.h>
12 #include <stdlib.h>
13
14 #include "uFCoder.h"
15
16 #define READER_TYPE    1              //uFR type (1Mbps)
17 #define PORT_NAME      "/dev/ttyUSB0" //"" to check all
18 #define PORT_INTERFACE 1              //Serial
19
20 int main(void)
21 {
22     UFR_STATUS status;
23
24     printf("uFCoder library version: %s\n", GetDllVersionStr());
25
26     status = ReaderOpenEx(READER_TYPE, PORT_NAME, PORT_INTERFACE, 0);
27     printf("ReaderOpenEx: %s\n", UFR_Status2String(status));
28
29     //status = ReaderUISignal(0, 0);
30     //printf("ReaderUISignal: %s\n", UFR_Status2String(status));
31
32     puts(GetReaderDescription());
33
34     uint8_t lpucCardType;
35     status = GetDlogicCardType(&lpucCardType);
36     printf("GetDlogicCardType: %s\n", UFR_Status2String(status));
37     if (status != UFR_OK) {
38         return status;
39     }
40     printf("card type: %x\n", lpucCardType);
41
42     uint8_t lpucSak;
43     uint8_t aucUid[10];
44     uint8_t lpucUidSize;
45     status = GetCardIdEx(&lpucSak, aucUid, &lpucUidSize);
46     printf("GetCardIdEx: %s\n", UFR_Status2String(status));
47     if (status != UFR_OK) {
48         return status;
49     }
50     printf("lpucSak: %d, lpucUidSize: %d, aucUid: ", lpucSak, lpucUidSize);
51     for (uint8_t i = 0; i < lpucUidSize; i++) {
52         printf("%x", aucUid[i]);
53     }
54     printf("\n");
55
56     status = ReaderClose();
57     printf("ReaderClose: %s\n", UFR_Status2String(status));
58
59     return status;
60 }