]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/proxmark3.c
cleaning up endless copy-paste of trace functionality
[proxmark3-svn] / client / proxmark3.c
index 4c6076bc83cbac16b52aecb65cc48a63e2d9f048..2e8ef41820e16da24ffd0c6530f37ada96df0b5d 100644 (file)
@@ -26,7 +26,7 @@ static void *usb_receiver(void *targ) {
        UsbCommand cmdbuf;
 
        while(arg->run) {
        UsbCommand cmdbuf;
 
        while(arg->run) {
-               if (ReceiveCommandP(&cmdbuf) > 0) {
+               if (ReceiveCommandPoll(&cmdbuf)) {
                        int i;
 
                        for (i=0; i<strlen(PROXPROMPT); i++)
                        int i;
 
                        for (i=0; i<strlen(PROXPROMPT); i++)
@@ -44,22 +44,18 @@ static void *usb_receiver(void *targ) {
 static void *main_loop(void *targ)
 {
        struct main_loop_arg *arg = (struct main_loop_arg*)targ;
 static void *main_loop(void *targ)
 {
        struct main_loop_arg *arg = (struct main_loop_arg*)targ;
+       struct usb_receiver_arg rarg;
        char *cmd = NULL;
        char *cmd = NULL;
+       pthread_t reader_thread;
+
+       if (arg->usb_present == 1) {
+               rarg.run=1;
+               pthread_create(&reader_thread, NULL, &usb_receiver, &rarg);
+       }
 
        while(1) {
 
        while(1) {
-               struct usb_receiver_arg rarg;
-               pthread_t reader_thread;
 
 
-               rarg.run=1;
-               if (arg->usb_present == 1) {
-                       pthread_create(&reader_thread, NULL, &usb_receiver, &rarg);
-               }
                cmd = readline(PROXPROMPT);
                cmd = readline(PROXPROMPT);
-               rarg.run=0;
-               if (arg->usb_present == 1) {
-                       pthread_join(reader_thread, NULL);
-               }
-
                if (cmd) {
                        if (cmd[0] != 0x00) {
                                CommandReceived(cmd);
                if (cmd) {
                        if (cmd[0] != 0x00) {
                                CommandReceived(cmd);
@@ -71,6 +67,11 @@ static void *main_loop(void *targ)
                        break;
                }
        }
                        break;
                }
        }
+       
+       if (arg->usb_present == 1) {
+               rarg.run = 0;
+               pthread_join(reader_thread, NULL);
+       }
 
        ExitGraphics();
        pthread_exit(NULL);
 
        ExitGraphics();
        pthread_exit(NULL);
Impressum, Datenschutz