]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blob - mt_rfid.h
doc, cleaning, no per session data
[coffee/mt-apps.git] / mt_rfid.h
1 #ifndef MT_RFID_H
2 #define MT_RFID_H
3
4 #include <ev.h>
5
6 // reader open parameters, see uFR manual
7 #define UFR_READER_TYPE     1       // uFR type (1Mbps)
8 #define UFR_PORT_INTERFACE  1       // serial; auto->ftdi->FAIL
9 #define UFR_PORT_NAME       "/dev/ttyUSB0" // reader device
10 #define UFR_ASYNC_BAUD_RATE 1000000 // 1Mbps, otherwise UFR_COMMUNICATION_BREAK
11
12 #define UFR_BEEP // define this to annoy people
13
14 typedef struct ev_io_ufr {
15     ev_io w;           // fd watcher
16     char uid_data[24]; // store uid here (uid is 10 bytes max)
17     char *uid;         // current position in uid_data
18     int fd;            // PORT_NAME file descriptor
19 } ev_io_ufr;
20
21 typedef struct mt_rfid_t {
22     ev_io_ufr w; // reader watcher
23     int fd;      // print JSON output here
24 } mt_rfid_t;
25
26 // connect to the reader, add self to loop and make it write to fd
27 int mt_rfid_init(mt_rfid_t *self, struct ev_loop *loop, int fd);
28
29 // disconnect from reader
30 void mt_rfid_deinit(mt_rfid_t *self);
31
32 #endif