Closed muehlke closed 1 year ago
Realized my txqueuelen was set to 10. That's why beginning from the 11th frame things got messed up. Solved by setting a bigger value with:
ip link set dev can0 txqueuelen 4096
Realized my txqueuelen was set to 10. That's why beginning from the 11th frame things got messed up. Solved by setting a bigger value with:
ip link set dev can0 txqueuelen 4096
Hi @muehlke ,
in Linux 5.18+ the CAN frame handling has been reworked which makes the txqueuelen
tweak obsolete:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/net/can?h=linux-5.18.y&id=4b7fe92c06901f4563af0e36d25223a5ab343782
If you are able to upgrade your Linux kernel (e.g. with Ubuntu ppa packages), I would suggest to update to the latest longterm kernel Linux 6.1.x which has some more stability improvements in can-isotp.
Thanks @hartkopp for your advice! I'll take it into consideration for my project. Thanks for the investment into this topic.
Hello,
I'm using an UDS client that uses the can-isotp Linux kernel module as the transport layer to carry out a firmware update on an ECU.
After requesting a download and receiving a confirmation from the ECU I proceed to transfer blocks of 3074 bytes over CAN-ISOTP to deliver the firmware to the ECU. For this, I call
write(int fd, const void *buf, size_t count)
with the file descriptor obtained from callingsocket(AF_CAN, SOCK_DGRAM | SOCK_NONBLOCK, CAN_ISOTP)
and bound to an specified address. This transfer is performed by a development board with a Linux Gateway (to which I'm connected over SSH) to the ECU. I sniff out the whole bus traffic with the PCAN-USB adapter (https://www.peak-system.com/PCAN-USB.199.0.html?&L=1) connected to an Ubuntu VM with thecandump
command from can-utils.That's when I observe that after the eleventh consecutive frame (CF) is sent, the next sequence number is not right (
0x0
instead of0xC
) and further down it gets even worse; some sequence numbers get sent twice or three times. It also does not transmit all required 3074 bytes. Here the example "candumped" trace (IDs hidden):I have come to a few ideas why this might not be working like e.g. that there is maybe interference on the CAN bus (physical reason) because I don't want to think that there might be something wrong with this kernel module. After double-checking my code I came to the realization that it all happens after the already mentioned
write()
call and then the kernel module takes care of the ISOTP part of the transfer.I would highly appreciate any input as to why this might be happening - hardware or software related. Thanks in advance!