1

我想确认我的消息已通过 socketCAN 库保存在 CAN 总线上。socketCAN 文档描述了使用 recvmsg() 函数时的这种可能性,我在实现时遇到了问题。

我要实现的功能是确认我的消息赢得了仲裁过程。

4

2 回答 2

3

我认为提到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 驱动程序支持驱动程序级别的帧回显时”,因此您必须首先确保这一点。接下来,您需要启用相应的标志。最后,这种确认与仲裁无关。当一个帧失去仲裁时,控制器会在总线空闲时尝试重新发送它。

于 2019-07-19T07:11:52.527 回答
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>)
于 2019-08-29T12:10:09.220 回答