Re: [PATCH 1/2] canbusload: count full payload for CANFD frames

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24.06.2021 05:21:10, Kurt Van Dijck wrote:
> Signed-off-by: Kurt Van Dijck <dev.kurt@xxxxxxxxxxxxxxxxxxxxxx>
> ---
>  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;

nitpick: Please add spaces around the "*", even if these are not in the
original code. Create a github pull request or send a v2 and I'll apply
the patches.

> +				stat[i].recv_bits_total += can_frame_length(&frame,
> +									    mode, nbytes);
>  			}
>  		}
>  	}

regard,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux