]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blob - mt_rfid.h
async uid + libev
[coffee/mt-apps.git] / mt_rfid.h
1 /**
2  * mt_rfid.h
3  * Start your own mt-rfid pthread.
4  */
5
6 #ifndef MT_RFID_H
7 #define MT_RFID_H
8
9 // setup structure
10 // it might tempt you to run multiple instances with one reader, don't.
11 // running each instance with its own reader (port name) should fine.
12 typedef struct {
13     unsigned reader_type;    // 0: auto, 1: 1Mbps, 2,3: slooow
14     char *port_name;         // "COM9", "/dev/ttyUSB0", "" for auto selection
15     unsigned port_interface; // 0: auto, 1: serial, 2: ftdi
16     unsigned beep;           // beep when a card is beeing read
17     unsigned run;            // polling condition
18 } mt_rfid_t;
19
20 // macros for convenience
21 #define READER_TYPE    1 // uFR type (1Mbps)
22 #define PORT_INTERFACE 1 // serial
23 #define PORT_NAME "/dev/ttyUSB0"
24
25 #define ASYNC_SUFFIX 0
26 #define ASYNC_BAUD_RATE 1000000
27 #define BASYNC_BAUD_RATE B1000000
28
29 // really simple JSON helpers
30 #define JSON_NUM(NAME) printf("\"" #NAME "\": %d", NAME)
31 #define JSON_STR(NAME) printf("\"" #NAME "\": \"%s\"", NAME)
32 #define JSON_START() printf("{\n")
33 #define JSON_NEXT() printf(",\n")
34 #define JSON_END() printf("\n}\n")
35
36 #endif