Skip to content

Commit

Permalink
linuxeth.c: try non-blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed May 21, 2021
1 parent 7623667 commit 8ef9eb2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/tl/can/linux_socket_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ int locate_interface(int socket, char const * name)
void XcpTl_Init(void)
{
int enable_sockopt = 1;
int flags;
struct sockaddr_can addr;
struct can_filter rfilter[2];

memset(&XcpTl_Connection, '\x00', sizeof(XcpTl_ConnectionType));


XcpTl_Connection.can_socket = socket(PF_CAN, SOCK_RAW, CAN_RAW);
if (XcpTl_Connection.can_socket== -1){
errno_abort("XcpTl_Init::socket()");
Expand All @@ -99,6 +101,16 @@ void XcpTl_Init(void)
errno_abort("Your kernel doesn't supports CAN-FD.\n\r");
}
}
#if 0
flags = fcntl(XcpTl_Connection.can_socket, F_GETFL, 0);
if (flags == -1) {
errno_abort("fcntl(F_GETFL)");
}
flags |= O_NONBLOCK;
if (fcntl(XcpTl_Connection.can_socket, F_SETFL, flags) == -1) {
errno_abort("fcntl(F_SETFL)");
}
#endif
if (setsockopt(XcpTl_Connection.can_socket, SOL_SOCKET, SO_TIMESTAMP, &enable_sockopt, sizeof(enable_sockopt)) < 0) {
// Enable precision timestamps.
errno_abort("setsockopt(SO_TIMESTAMP)");
Expand Down

0 comments on commit 8ef9eb2

Please sign in to comment.