After sending the message, I am waiting for MSG_CONFIRM.
How to correctly receive MSG_FLAGS?
I don't understand why temp
is always equal -1
.
struct msghdr msg;
struct sockaddr_can addr;
struct can_frame frame;
struct ifreq ifr
setsockopt(s, SOL_CAN_RAW, CAN_RAW_ERR_FILTER, &(int){ 1 }, sizeof(int));
setsockopt(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK, &(int){ 1 }, sizeof(int));
setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS, &(int){ 1 }, sizeof(int));
strcpy(ifr.ifr_name, ifname);
ioctl(s, SIOCGIFINDEX, &ifr);
addr.can_family = AF_CAN;
addr.can_ifindex = ifr.ifr_ifindex;
write(s, &frame, sizeof(struct can_frame));
temp = recvmsg(s, &msg, MSG_CONFIRM);
printf("%02X \n", temp);
printf("%02X \n", errno);
if (msg.msg_flags==MSG_CONFIRM){
printf("MSG_CONFIRM"); }