Increase count only at one place
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 29 Nov 2010 19:15:40 +0000 (20:15 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 29 Nov 2010 19:15:40 +0000 (20:15 +0100)
latester/latester.c

index e32f960..8d38540 100644 (file)
@@ -371,10 +371,11 @@ void *measure_thread(void *arg)
        set_sched_policy_and_prio(SCHED_FIFO, 99);
 
 #define SEND()                                         \
-       do {    printf("send\n");                               \
+       do {    printf("send\n");                       \
                ret = send_frame(pfd[0].fd);            \
                if (ret != sizeof(struct can_frame))    \
-                       error(1, errno, "send_frame");  \
+                       error(1, errno, "send_frame %d", __LINE__);     \
+               count++;                                \
                msg_in_progress++;                      \
        } while (0)
 
@@ -398,7 +399,7 @@ void *measure_thread(void *arg)
                        break;
                case 0: // Timeout
                        if (opt.period_us) {
-                               if (opt.count == 0 || count++ < opt.count) {
+                               if (opt.count == 0 || count < opt.count) {
                                        SEND();
                                } else {
                                        error(1, 0, "poll timeout");
@@ -410,7 +411,7 @@ void *measure_thread(void *arg)
                                process_tx(pfd[0].fd);
                        }
                        if (pfd[0].revents & POLLOUT) {
-                               if (opt.count == 0 || count++ < opt.count)
+                               if (opt.count == 0 || count < opt.count)
                                        SEND();
                        }
                        pfd[0].revents = 0;
@@ -425,7 +426,7 @@ void *measure_thread(void *arg)
                                process_final_rx(pfd[i].fd);
                                msg_in_progress--;
                                pfd[i].revents = 0;
-                               if ((opt.count == 0 || count++ < opt.count) &&
+                               if ((opt.count == 0 || count < opt.count) &&
                                    opt.oneattime) {
                                        SEND();
                                }