]> rtime.felk.cvut.cz Git - can-benchmark.git/blobdiff - latester/latester.c
Merge branch 'master' of rtime.felk.cvut.cz:/can-benchmark
[can-benchmark.git] / latester / latester.c
index b7bb38b49bea7489d0bbe3a08d060155dc6e98d0..61b2b433f45afe5c20bba5bc5830ff82a99ca83a 100644 (file)
@@ -133,7 +133,7 @@ void sprint_canframe(char *buf , struct can_frame *cf, int sep) {
                }
 }
 
                }
 }
 
-static inline struct msg_info *frame2info(struct can_frame *frame)
+static inline uint16_t frame_index(struct can_frame *frame)
 {
        uint16_t idx;
        if (frame->can_dlc >= 2) {
 {
        uint16_t idx;
        if (frame->can_dlc >= 2) {
@@ -144,7 +144,12 @@ static inline struct msg_info *frame2info(struct can_frame *frame)
 
                error(1, 0, "%s error", __FUNCTION__);
        }
 
                error(1, 0, "%s error", __FUNCTION__);
        }
-       return &msg_infos[idx];
+       return idx;
+}
+
+static inline struct msg_info *frame2info(struct can_frame *frame)
+{
+       return &msg_infos[frame_index(frame)];
 }
 
 static inline char *tstamp_str(const void *ctx, struct timespec *tstamp)
 }
 
 static inline char *tstamp_str(const void *ctx, struct timespec *tstamp)
@@ -606,13 +611,15 @@ void *measure_thread(void *arg)
                        }
                        pfd[0].revents = 0;
 
                        }
                        pfd[0].revents = 0;
 
-                       if (num_interfaces == 3 && pfd[1].revents != 0) {
+                       if (num_interfaces == 3 && pfd[1].revents & POLLIN) {
                                process_on_wire_rx(pfd[1].fd);
                                pfd[1].revents = 0;
                        }
                                process_on_wire_rx(pfd[1].fd);
                                pfd[1].revents = 0;
                        }
+                       if (num_interfaces == 3 && pfd[1].revents & ~POLLIN)
+                               error(1, 0, "Unexpected pfd[1].revents: 0x%04x\n", pfd[1].revents);
 
                        i = (num_interfaces == 2) ? 1 : 2;
 
                        i = (num_interfaces == 2) ? 1 : 2;
-                       if (pfd[i].revents != 0) {
+                       if (pfd[i].revents & POLLIN) {
                                consecutive_timeouts = 0;
                                process_final_rx(pfd[i].fd);
                                msg_in_progress--;
                                consecutive_timeouts = 0;
                                process_final_rx(pfd[i].fd);
                                msg_in_progress--;
@@ -622,6 +629,8 @@ void *measure_thread(void *arg)
                                        SEND();
                                }
                        }
                                        SEND();
                                }
                        }
+                       if (pfd[i].revents & ~POLLIN)
+                               error(1, 0, "Unexpected pfd[%d].revents: 0x%04x\n", pfd[i].revents);
                }
        }
 
                }
        }