socketcan

How socketcan get send failure status?

可紊 提交于 2021-02-11 14:47:00
问题 As we all know, in the CAN bus communication protocol, sender know whether the data was successfully sent. I send socketcan data as follows. ret = write (socket, frame, sizeof (struct can_frame)); However, even if the CAN communication cable is disconnected, the return value of ret is still 16(=sizeof (struct can_frame)).I queried the information and found that the problem was due to the tx_queue of the network stack used by socketcan. When write is called multiple times, the buffer is full

Is it possible to generate CAN message in one device and dump CAN message in another device using SocketCAN?

﹥>﹥吖頭↗ 提交于 2019-12-25 00:38:34
问题 I am using SocketCAN and CANtact toolkit to send and receive CAN message. I am using two CANtact toolkits one to send CAN message and other to receive the CAN message both the CANtact toolkits are connected by DB9 female to DB9 female and the other ends are connected to the USB port of the laptop. I used the following SocketCAN commands to first configure them sudo modprobe can sudo modprobe can_raw sudo modprobe slcan sudo slcand -o -s6 -t hw -S 3000000 /dev/ttyACM0 slcan0 sudo ip link set

How does socketcan handle arbitration?

人盡茶涼 提交于 2019-12-11 01:34:06
问题 I pretty much understand how the CAN protocol works -- when two nodes attempt to use the network at the same time, the lower id can frame gets priority and the other node detects this and halts. This seems to get abstracted away when using socketcan - we simply write and read like we would any file descriptor. I may be misunderstanding something but I've gone through most of the docs (http://lxr.free-electrons.com/source/Documentation/networking/can.txt) and I don't think it's described

Socket-CAN virtual bus

大城市里の小女人 提交于 2019-12-06 01:57:16
问题 How can I create several virtual sockets and link them together to create a virtual bus? I want to simulate an application in which many nodes communicate to each other via CAN. 回答1: All you need is cangw tool from can-utils. Create two virtual interfaces: ip link add dev vcan0 type vcan ip link add dev vcan1 type vcan ip link set up vcan0 ip link set up vcan1 Create routing rule, so that all packets coming to vcan0 will be sent to vcan1 : cangw -A -s vcan0 -d vcan1 -e Listen to vcan1 in one

Socket-CAN virtual bus

痴心易碎 提交于 2019-12-04 05:20:21
How can I create several virtual sockets and link them together to create a virtual bus? I want to simulate an application in which many nodes communicate to each other via CAN. All you need is cangw tool from can-utils . Create two virtual interfaces: ip link add dev vcan0 type vcan ip link add dev vcan1 type vcan ip link set up vcan0 ip link set up vcan1 Create routing rule, so that all packets coming to vcan0 will be sent to vcan1 : cangw -A -s vcan0 -d vcan1 -e Listen to vcan1 in one terminal: candump vcan1 And send packet from another terminal: cansend vcan0 123#0011 You'll see, that