]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blobdiff - mt_aio.c
Add simulator mode (for debugging without terminal)
[coffee/mt-apps.git] / mt_aio.c
index 92f2354421687827a08d9269e1ba62391d332da7..076d49d44138c328cc1433695b30b7e8c2836140 100644 (file)
--- a/mt_aio.c
+++ b/mt_aio.c
@@ -4,6 +4,7 @@
 #include "mt_server.h"
 #include "signal_exit.h"
 #include "mt_blank.h"
+#include "mt_sim.h"
 
 int main(int argc, char **argv)
 {
@@ -20,6 +21,7 @@ int main(int argc, char **argv)
 
     set_signal_exit(loop);
 
+#if !defined(SIM)
     if (mt_rfid_init(&rfid, loop, pipefd[1]) != 0) {
         return -1;
     }
@@ -28,19 +30,28 @@ int main(int argc, char **argv)
         return -1;
     }
 
-    if (mt_server_init(&server, loop, pipefd[0]) != 0) {
-        return -2;
-    }
-
     if (mt_blank_init(loop) != 0) {
         return -3;
     }
+#else
+    if (mt_sim_init(loop, pipefd[1]) != 0) {
+        return -1;
+    }
+#endif
+
+    if (mt_server_init(&server, loop, pipefd[0]) != 0) {
+        return -2;
+    }
 
     ev_run(loop, 0);
 
     mt_server_deinit(&server);
+#if !defined(SIM)
     mt_keys_deinit(&keys);
     mt_rfid_deinit(&rfid);
+#else
+    mt_sim_deinit();
+#endif
     ev_loop_destroy(loop);
 
     return 0;