]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blobdiff - mt_rfid.c
tiny doc and macros
[coffee/mt-apps.git] / mt_rfid.c
index a16dffb267376c81b3968ee55c62eed95ece8c4c..d281371918f1d1238ff89eeadbe578fad8894cec 100644 (file)
--- a/mt_rfid.c
+++ b/mt_rfid.c
@@ -3,6 +3,10 @@
  * poll the uFR reader and print JSON formatted card info to stdout.
  */
 
+// shit to avoid constant repetition
+#define CONCAT_AGAIN(A,B) A ## B
+#define CONCAT(A,B) CONCAT_AGAIN(A,B)
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -119,7 +123,9 @@ static void ufr_read(char *uid)
     JSON_NUM(uid_size);  JSON_NEXT();
     JSON_STR(uid);    JSON_END();
 
+#ifdef UFR_BEEP
     ReaderUISignal(0, 1);
+#endif
 }
 
 static void ufr_cb(EV_P_ ev_io *w_, int revents)
@@ -199,15 +205,18 @@ int main(int argc, char **argv)
         return -1;
     }
 
-    int fd = tty_open(PORT_NAME, BASYNC_BAUD_RATE);
+    int fd = tty_open(PORT_NAME, CONCAT(B,ASYNC_BAUD_RATE));
     if (fd < 0) {
         return -2;
     }
 
        libev_run(fd);
 
-    close(fd);
-    fprintf(stderr, "closed %d\n", fd);
+    if (close(fd) == 0) {
+        fprintf(stderr, "closed %d\n", fd);
+    } else {
+        perror("close");
+    }
 
     UFR_STATUS status;
     status = ReaderClose();