I-CAN-hack / automotive

Rust crate providing a variety of automotive related libraries, such as communicating with CAN interfaces and diagnostic APIs
MIT License
40 stars 7 forks source link

[SocketCAN] Drivers without `IFF_ECHO` fail to confirm all messages #52

Closed pd0wm closed 6 months ago

pd0wm commented 6 months ago

Everything seems fine up to burst of up to 238 messages, above that all MSG_CONFIRM/loopback messages are dropped. This is only an issues for drivers not setting the IFF_ECHO flag.

For example this happens on both vcan as well as the pcan driver. peak_usb is fine, as it's implementing IFF_ECHO.

pd0wm commented 6 months ago

Looks like the RX buffer fills up because all messages are instantly looped back. https://github.com/I-CAN-hack/automotive/pull/53 helps a bit.

Solution is probably to detect if IFF_ECHO is not set, disable recv_own_msgs and handle the loopback ourselves since it's fake anyway. Maybe do some throttling to simulate the speed of the CAN bus?