All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] canbusload: count full payload for CANFD frames
@ 2021-06-24  3:21 Kurt Van Dijck
  2021-06-24  3:21 ` [PATCH 2/2] canbusload: count databitrate seperately Kurt Van Dijck
  2021-06-24  6:22 ` [PATCH 1/2] canbusload: count full payload for CANFD frames Marc Kleine-Budde
  0 siblings, 2 replies; 6+ messages in thread
From: Kurt Van Dijck @ 2021-06-24  3:21 UTC (permalink / raw)
  To: linux-can; +Cc: Kurt Van Dijck

Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
---
 canbusload.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/canbusload.c b/canbusload.c
index d6bfd78..bd74cb5 100644
--- a/canbusload.c
+++ b/canbusload.c
@@ -237,7 +237,7 @@ int main(int argc, char **argv)
 	int opt;
 	char *ptr, *nptr;
 	struct sockaddr_can addr;
-	struct can_frame frame;
+	struct canfd_frame frame;
 	int nbytes, i;
 	struct ifreq ifr;
 	sigset_t sigmask, savesigmask;
@@ -351,6 +351,9 @@ int main(int argc, char **argv)
 #ifdef DEBUG
 		printf("using interface name '%s'.\n", ifr.ifr_name);
 #endif
+		/* try to switch the socket into CAN FD mode */
+		const int canfd_on = 1;
+		setsockopt(s[i], SOL_CAN_RAW, CAN_RAW_FD_FRAMES, &canfd_on, sizeof(canfd_on));
 
 		if (ioctl(s[i], SIOCGIFINDEX, &ifr) < 0) {
 			perror("SIOCGIFINDEX");
@@ -402,9 +405,9 @@ int main(int argc, char **argv)
 				}
 
 				stat[i].recv_frames++;
-				stat[i].recv_bits_payload += frame.can_dlc*8;
-				stat[i].recv_bits_total += can_frame_length((struct canfd_frame*)&frame,
-									    mode, sizeof(frame));
+				stat[i].recv_bits_payload += frame.len*8;
+				stat[i].recv_bits_total += can_frame_length(&frame,
+									    mode, nbytes);
 			}
 		}
 	}
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-24 10:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24  3:21 [PATCH 1/2] canbusload: count full payload for CANFD frames Kurt Van Dijck
2021-06-24  3:21 ` [PATCH 2/2] canbusload: count databitrate seperately Kurt Van Dijck
2021-06-24  6:25   ` Marc Kleine-Budde
2021-06-24 10:48     ` Kurt Van Dijck
2021-06-24 10:56       ` Marc Kleine-Budde
2021-06-24  6:22 ` [PATCH 1/2] canbusload: count full payload for CANFD frames Marc Kleine-Budde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.