From eb639c1b3d0da26eb63ebfb8510313834b635acc Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Sun, 26 Apr 2020 08:30:55 +0200 Subject: [PATCH] cansniffer: fix gap calculation output The gap between two consecutive frames of a specific has been calculated in handle_timeo() instead of handle_bcm() which lead to values that where at minimum the loop time of the display refresh. The effect can be seen when displaying a 10ms gap CAN frame with a 200ms display refresh (option -l 20 => default) in opposite to a 10ms display refresh (option -l 1). Signed-off-by: Oliver Hartkopp --- cansniffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cansniffer.c b/cansniffer.c index 0ff29b4..ccd6b4d 100644 --- a/cansniffer.c +++ b/cansniffer.c @@ -506,6 +506,7 @@ int handle_bcm(int fd, long currcms){ } id = bmsg.msg_head.can_id; + sniftab[id].laststamp = sniftab[id].currstamp; ioctl(fd, SIOCGSTAMP, &sniftab[id].currstamp); if (bmsg.msg_head.opcode != RX_CHANGED) { @@ -587,7 +588,6 @@ int handle_timeo(int fd, long currcms){ } } sniftab[i].last = sniftab[i].current; - sniftab[i].laststamp = sniftab[i].currstamp; } }