]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blobdiff - mt_rfid.h
doc, cleaning, no per session data
[coffee/mt-apps.git] / mt_rfid.h
index 2c98dd709f37c267b67297cef345fb1ac48c2cbe..7dfa6c98c64cd1b7c68c56ca59f63ca8d98ca5d3 100644 (file)
--- a/mt_rfid.h
+++ b/mt_rfid.h
@@ -1,36 +1,32 @@
-/**
- * mt_rfid.h
- */
-
 #ifndef MT_RFID_H
 #define MT_RFID_H
 
 #include <ev.h>
 
 // reader open parameters, see uFR manual
-#define READER_TYPE    1 // uFR type (1Mbps)
-#define PORT_INTERFACE 1 // serial, auto -> ftdi -> FAIL (some shity drivers missing)
-#define PORT_NAME "/dev/ttyUSB0"
-
-// async uid sending parameters
-#define ASYNC_SUFFIX            0 // keep it zero: + separates uids, + terminates strings
-#define ASYNC_BAUD_RATE   1000000 // 1Mbps, otherwise UFR_COMMUNICATION_BREAK
+#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
+#define UFR_BEEP // define this to annoy people
 
 typedef struct ev_io_ufr {
-    ev_io w;
-    char uid_data[24]; // this is enough (10 bytes max)
-    char *uid;
-    int fd;
+    ev_io w;           // fd watcher
+    char uid_data[24]; // store uid here (uid is 10 bytes max)
+    char *uid;         // current position in uid_data
+    int fd;            // PORT_NAME file descriptor
 } ev_io_ufr;
 
 typedef struct mt_rfid_t {
-    ev_io_ufr w;
-    int fd;
+    ev_io_ufr w; // reader watcher
+    int fd;      // print JSON output here
 } mt_rfid_t;
 
+// connect to the reader, add self to loop and make it write to fd
 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);
 
 #endif