Skip to content

Commit

Permalink
fix(isotp_sock.c): add CAN_ISOTP_WAIT_TX_DONE flag to ISOTP sockets
Browse files Browse the repository at this point in the history
As of now, an UDS client run on the Linux ISOTP kernel module was not able to recognize a timeout error of a Flow Control frame not arriving in time after a multi-frame request. To fix this, the flag CAN_ISOTP_WAIT_TX_DONE is set on the socket. Otherwise writing the bytes of the SEND buffer to the ISOTP socket would incorrectly return the expected SEND buffer size, creating further problems like e.g. a timeout waiting on the response of the "sent"  request, since it was not really sent so the UDS server is not sending a response.
  • Loading branch information
muehlke authored May 13, 2024
1 parent 8eaa0de commit bb6139f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/tp/isotp_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,21 @@ static int LinuxSockBind(const char *if_name, uint32_t rxid, uint32_t txid, bool
perror("setsockopt");
return -1;
}


struct can_isotp_options opts;
memset(&opts, 0, sizeof(opts));
// configure socket to wait for tx completion to catch FC frame timeouts
opts.flags |= CAN_ISOTP_WAIT_TX_DONE;

if (functional) {
printf("configuring fd: %d as functional\n", fd);
// configure the socket as listen-only to avoid sending FC frames
struct can_isotp_options opts;
memset(&opts, 0, sizeof(opts));
opts.flags |= CAN_ISOTP_LISTEN_MODE;
if (setsockopt(fd, SOL_CAN_ISOTP, CAN_ISOTP_OPTS, &opts, sizeof(opts)) < 0) {
perror("setsockopt (isotp_options):");
return -1;
}
}

if (setsockopt(fd, SOL_CAN_ISOTP, CAN_ISOTP_OPTS, &opts, sizeof(opts)) < 0) {
perror("setsockopt (isotp_options):");
return -1;
}

struct ifreq ifr;
Expand Down

0 comments on commit bb6139f

Please sign in to comment.