csocketscan-bussocketcanrecvmsg

Confirmation that the message was sent to the CAN bus using socketCAN


I would like to confirm that my message has been saved on the CAN bus with socketCAN library. The socketCAN documentation describes this possibility when using the recvmsg() function, I have problems with its implementation.

The function I want to achieve is to confirm that my message won the arbitration process.


Solution

  • I think mentioning recvmsg(2) you refer to the following paragraph of the SocketCAN docs:

    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.
    

    The key words here are "when the CAN driver supports the echo of frames on driver level", so you have to ensure that first. Next, you need to enable the corresponding flags. Finally, such confirmation has nothing to do with arbitration. When a frame looses arbitration, the controller tries to re-transmit it as soon as the bus becomes free.