Re: CAN: TX frames marked as RX after the sending socket is closed

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

 



On Mon, May 10, 2021 at 05:35:40PM +0200, Marc Kleine-Budde wrote:
> Can you provide the program to reproduce the issue?

See attached below this email (tx only, rx done with candump).

> Have you increased the CAN interface's txqueuelen?

Yup, qlen is 1000.

--
Regards,

Torin Cooper-Bennun
Software Engineer | maxiluxsystems.com

#include <errno.h>
#include <linux/can.h>
#include <net/if.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
	const char *if_name = "can0";
	int sockfd;
	struct ifreq req = {};
	struct sockaddr_can sockaddr = {};
	struct can_frame frame = {};
	struct timeval tv;
	char timestr[16];

	sockfd = socket(AF_CAN, SOCK_RAW, CAN_RAW);

	strncpy(req.ifr_name, if_name, IF_NAMESIZE);
	ioctl(sockfd, SIOCGIFINDEX, &req);

	sockaddr.can_family = AF_CAN;
	sockaddr.can_ifindex = req.ifr_ifindex;

	bind(sockfd, (const struct sockaddr *) &sockaddr, sizeof(sockaddr));

	frame.can_dlc = 8;
	memset(frame.data, 0xee, 8);
	for (int i = 0; i < 1000; ++i)
	{
		frame.can_id = (i & 0x7ff);
		send(sockfd, &frame, sizeof(frame), 0);
	}

	close(sockfd);

	gettimeofday(&tv, NULL);
	strftime(timestr, sizeof(timestr), "%H:%M:%S", localtime(&tv.tv_sec));
	printf("Socket closed at %s.%06ld\n", timestr, tv.tv_usec);

	return 0;
}

[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