X-Git-Url: https://rtime.felk.cvut.cz/gitweb/coffee/mt-apps.git/blobdiff_plain/e17bf7ed8d01e48100100d4fea02cec478bb22f9..HEAD:/mt_rfid.h?ds=sidebyside diff --git a/mt_rfid.h b/mt_rfid.h index 7dfa6c9..01acb9b 100644 --- a/mt_rfid.h +++ b/mt_rfid.h @@ -2,14 +2,7 @@ #define MT_RFID_H #include - -// reader open parameters, see uFR manual -#define UFR_READER_TYPE 1 // uFR type (1Mbps) -#define UFR_PORT_INTERFACE 1 // serial; auto->ftdi->FAIL -#define UFR_PORT_NAME "/dev/ttyUSB0" // reader device -#define UFR_ASYNC_BAUD_RATE 1000000 // 1Mbps, otherwise UFR_COMMUNICATION_BREAK - -#define UFR_BEEP // define this to annoy people +#include typedef struct ev_io_ufr { ev_io w; // fd watcher @@ -23,10 +16,24 @@ typedef struct mt_rfid_t { int fd; // print JSON output here } mt_rfid_t; +// reader open parameters, see uFR manual +#define UFR_READER_TYPE 1 // uFR type (1Mbps) +#define UFR_PORT_INTERFACE 1 // serial; auto->ftdi->FAIL +#define UFR_PORT_NAME "/dev/ttyUSB0" // reader device +#define UFR_ASYNC_BAUD_RATE 1000000 // 1Mbps, otherwise UFR_COMMUNICATION_BREAK + +#define UFR_BEEP // define this to annoy people + // connect to the reader, add self to loop and make it write to fd +// return 0 on success, negative number otherwise int mt_rfid_init(mt_rfid_t *self, struct ev_loop *loop, int fd); // disconnect from reader void mt_rfid_deinit(mt_rfid_t *self); +#else + +#define mt_rfid_init(self, loop, fd) 0 +#define mt_rfid_deinit(self) 0 + #endif