【问题标题】:Confirmation that the message was sent to the CAN bus using socketCAN使用 socketCAN 确认消息已发送到 CAN 总线
【发布时间】:2019-07-15 10:48:53
【问题描述】:

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

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

【问题讨论】:

标签: c sockets can-bus socketcan recvmsg


【解决方案1】:

我认为提到 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驱动支持驱动层面的帧回显”,所以首先要保证,接下来需要开启相应的flags。最后,这样的确认与此无关仲裁。当一个帧失去仲裁时,控制器会在总线空闲时尝试重新传输它。

【讨论】:

    【解决方案2】:

    我想你可以在你的电脑上使用命令“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>)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-07
      相关资源
      最近更新 更多