* 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>
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)
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();