Skip to content

Commit

Permalink
cyphal socketcan driver: treat EAGAIN as a timeout instead of an erro…
Browse files Browse the repository at this point in the history
…r to retry sending later
  • Loading branch information
PonomarevDA committed Sep 10, 2024
1 parent 43add7c commit 6f96987
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/drivers/cyphal/CanardSocketCAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,15 @@ int16_t CanardSocketCAN::transmit(const CanardTxQueueItem &txf, int timeout_ms)
#ifdef CONFIG_NET_CAN_RAW_TX_DEADLINE
return sendmsg(_fd, &_send_msg, 0);
#else
return sendmsg(_fd, &_send_msg, MSG_DONTWAIT);
/* Use non-blocking calls for devices that don't implement TX deadline*/
auto res = sendmsg(_fd, &_send_msg, MSG_DONTWAIT);

/* Treat EAGAIN as a timeout instead of an error. Return 0, so CanardHandle will send the frame again later. */
if (res < 0 && errno == EAGAIN) {
return 0;
}

return res;
#endif
}

Expand Down

0 comments on commit 6f96987

Please sign in to comment.