我想确认我的消息已经通过socketCAN库保存在CAN总线上了。 当使用recvmsg()函数时,socketCAN文档描述了这种可能性,我对其实现有疑问。
我要实现的功能是确认我的消息赢得了仲裁过程。
答案 0 :(得分:2)
我认为提到recvmsg(2)
是指SocketCAN文档的以下段落:
MSG_CONFIRM: set when the frame was sent via the socket it is received on.
This flag can be interpreted as a 'transmission confirmation' when the
CAN driver supports the echo of frames on driver level, see 3.2 and 6.2.
In order to receive such messages, CAN_RAW_RECV_OWN_MSGS must be set.
这里的关键词是“ CAN驱动程序支持驱动程序级别上的帧回显”。,因此必须首先确保。下一步,需要启用相应的标志。最后,这种确认与 arbitration 。当一个帧失去仲裁时,一旦总线空闲,控制器就会尝试重新传输它。
答案 1 :(得分:0)
我认为您可以在PC上使用命令“ candump can0 / can1”,它将显示在给定的CAN接口上收到的CAN数据包。
Usage: candump [options] <CAN interface>+
(use CTRL-C to terminate candump)
Options: -t <type> (timestamp: (a)bsolute/(d)elta/(z)ero/(A)bsolute w date)
-c (increment color mode level)
-i (binary output - may exceed 80 chars/line)
-a (enable additional ASCII output)
-b <can> (bridge mode - send received frames to <can>)
-B <can> (bridge mode - like '-b' with disabled loopback)
-u <usecs> (delay bridge forwarding by <usecs> microseconds)
-l (log CAN-frames into file. Sets '-s 2' by default)
-L (use log file format on stdout)
-n <count> (terminate after receiption of <count> CAN frames)
-r <size> (set socket receive buffer to <size>)